Problem:


Score : 300 points

Problem Statement

N tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.

The i-th tile from the left is painted black if the i-th character of S is 0, and painted white if that character is 1.

You want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.

At least how many tiles need to be repainted to satisfy the condition?

Constraints

1 \leq |S| \leq 10^5

S_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

S

Output

Print the minimum number of tiles that need to be repainted to satisfy the condition.

Sample Input 1

000

Sample Output 1

1

The condition can be satisfied by repainting the middle tile white.

Sample Input 2

10010010

Sample Output 2

3

Sample Input 3

0

Sample Output 3

0



Sample input:
000


Sample output:
1

Submission status: Wrong Answer

Solution code:
from itertools import repeat
S = input()
N = len(S)
if N<2:
    print('0')
else:
    a = int(S, 2)
    r = "".join(list(repeat('10', int(N/2)+1)))
    s1 = int(r[:-1], 2)
    s2 = int(r[1:], 2)
    print(min(bin(s1^a).count("1"), bin(s2^a).count("1")))

Submission status: Wrong Answer

Solution code:
from itertools import repeat
S = input()
N = len(S)
if N<2:
    print('0')
else:
    a = int(S, 2)
    r = "".join(list(repeat('10', int(N/2)+1)))
    r = r[:-1]
    s1 = int(r[:-1], 2)
    s2 = int(r[1:], 2)
    print(min(bin(s1^a).count("1"), bin(s2^a).count("1")))

Submission status: Wrong Answer

Solution code:
s = input()
cnt, cnt_ = 0, 0
a = "10" * (len(s)//2+1)
print(a)
for i in range(len(s)):
    if s[i] != a[i]:
        cnt += 1
    if s[i] != a[i + 1]:
        cnt_ += 1
print(min(cnt, cnt_))

Submission status: Wrong Answer

Solution code:
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    S = input()
    S_ = S[::-1]
    N = len(S)
    count = 0
    count_ = 0
    for i in range(N):
        if i % 2 == 0:
            if S[i] == '0':
                count += 1
            if S_[i] == '0':
                count_ += 1
        if i % 2 == 1:
            if S[i] == '1':
                count += 1
            if S_[i] == '1':
                count_ += 1
    if count < count_:
        print(count)
    else:
        print(count_)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    S = input()
    S_ = S[::-1]
    N = len(S)
    count = 0
    count_ = 0
    for i in range(N):
        if i % 2 == 0:
            if S[i] == '0':
                count += 1
            if S_[i] == '1':
                count_ += 1
        if i % 2 == 1:
            if S[i] == '1':
                count += 1
            if S_[i] == '0':
                count_ += 1
    if count < count_:
        print(count)
    else:
        print(count_)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
a = S[0]

if len(set(S))==1:
	print(len(S)//2)
	exit()

cnt=0
for i in range(len(S)):
	if i % 2 ==0:
		if S[i]!=a:
			cnt +=1
tmp=0
for i in range(len(S)):
	if i % 2 ==1:
		if S[i]!=a:
			tmp +=1
print(max(tmp,cnt))

Submission status: Wrong Answer

Solution code:
S = input()
S1 = S[::2]
S2 = S[1::2]
if S1.count('0') > S2.count('0'):
    ans = S1.count('1') + S2.count('0')
elif S1.count('0') < S2.count('0'):
    ans = S1.count('0') + S2.count('1')
else:
    if S1.count('0') < S1.count('1'):
        ans = S1.count('0') + S2.count('0')
    elif S1.count('0') > S1.count('1'):
        ans = S1.count('1') + S2.count('1')
    else:
        ans = len(S1)
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
S1 = S[::2]
S2 = S[1::2]
if S1.count('0') >= S2.count('0'):
    ans = S1.count('1') + S2.count('0')
else:
    ans = S1.count('0') + S2.count('1')
print(ans)

Submission status: Wrong Answer

Solution code:
s = list(input())
count = 0
n = len(s)
if n % 2 == 0:
    for i in range(0,int(n/2)):
        if s[(2*i)+1] == "0":
            count = count + 1
            print(i)
    for j in range(0,int(n/2)):
        if s[2*j] == "1":
            count = count + 1
            print(j)
else:
    for i in range(0,int((n-1)/2)+1):
        if s[2*i] == "0":
            count = count + 1
    for j in range(0,int(((n-1)/2))):
        if s[2*j + 1] == "1":
            count = count + 1
count2 = n - count
print(min(count,count2))

Submission status: Wrong Answer

Solution code:
s = list(input())
count = 0
n = len(s)
if n % 2 == 0:
    for i in range(0,int((n/2)-1)):
        if s[(2*i)+1] == "0":
            count = count + 1
    for j in range(0,int((n/2)-1)):
        if s[2*j] == "1":
            count = count + 1
else:
    for i in range(0,int((n-1)/2)+1):
        if s[2*i] == "0":
            count = count + 1
    for j in range(0,int(((n-1)/2))):
        if s[2*j + 1] == "1":
            count = count + 1
count2 = n - count
print(min(count,count2))

Submission status: Wrong Answer

Solution code:
s = list(input())
count = 0
n = len(s)
if n % 2 == 0:
    for i in range(0,int((n/2)-1)):
        if s[(2*i)+1] == "0":
            count = count + 1
    for i in range(0,int((n/2)-1)):
        if s[2*i] == "1":
            count = count + 1
else:
    for i in range(0,int((n-1)/2)):
        if s[2*i] == "0":
            count = count + 1
    for i in range(0,int(((n-1)/2)-1)):
        if s[2*i + 1] == "1":
            count = count + 1
count2 = n - count
print(min(count,count2))

Submission status: Wrong Answer

Solution code:
# -*- Coding: utf-8 -*-
def reverse(str):
  if str == '0':
    str = '1'
  else:
    str = '0'

  return str


S = raw_input()
S = list(S)
N = len(S)
ans = 0

i = 1
while i<(N-1):
  if S[i-1]==S[i+1]:
    if S[i-1]==S[i]:
      S[i] = reverse(S[i])
      ans += 1
    else:
      i += 2
      continue
  else:
    if S[i-1]==S[i]:
      S[i-1] = reverse(S[i-1])
      ans += 1
    else:
      S[i+1] = reverse(S[i+1])
      ans += 1
  i += 2

print ans

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# sys.stdin.readline()
import sys
input = sys.stdin.readline

s = input()
#a = sorted(map(int, input().split()))
c1 = 0
c2 = 0
for i in range(len(s)):
  if i % 2 == 0:
    if s[i] == '0':
      c1 = c1 + 1
    else:
      c2 = c2 + 1
  else:
    if s[i] == '1':
      c1 = c1 + 1
    else:
      c2 = c2 + 1
print(min(c1, c2))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
s = input()
c1 = 0
c2 = 0
for i in range(len(s)):
  if i % 2 == 0:
    if s[i] == "0":
      c1 = c1 + 1
    else:
      c2 = c2 + 1
  else:
    if s[i] == "1":
      c1 = c1 + 1
    else:
      c2 = c2 + 1
print(min(c1, c2))

Submission status: Wrong Answer

Solution code:
s = input()[:-1]

a, b = 0, 0

for i in range(len(s)):
	if i % 2 == 0:
		if s[i] == "1":
			a += 1
		else:
			b += 1
	else:
		if s[i] == "0":
			a += 1
		else:
			b += 1


print(min(a,b))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

S = list(input())

count_0 = 0
count_1 = 0

for i in range(len(S)):
	if (i % 2 == 1) ^ (S[i] == '1'):
		count_0 += 1
	else:
		count_1 += 1
		
print(min(count_0, count_1))

Submission status: Wrong Answer

Solution code:
"""
for a in range(10):
    v = bin(a)
    #print(v)
    v = v.replace("0b", "")
"""

v=input()

if len(v)%2 != 0 and len(v) > 1:
    v += (str(int(not(v[len(v)-1]))))


s = [v[i: i+2] for i in range(0, len(v), 2)]

list = [0]*4

for i in s:
    #print(i)

    if i == "00":
        list[0] += 1
    elif i == "01":
        list[1] += 1
    elif i == "10":
        list[2] += 1
    elif i == "11":
        list[3] += 1

if list[1] > list[2]:
    print(list[0]*1+list[2]*2+list[3]*1)
    result = list[0]*1+list[2]*2+list[3]*1
elif list[1] < list[2]:
    print(list[0]*1+list[1]*2+list[3]*1)
    result = list[0]*1+list[1]*2+list[3]*1
else:
    print(list[0]*1+list[1]*2+list[3]*1)
    result = list[0]*1+list[1]*2+list[3]*1
#print(list)
#print("result:" + str(result))


s = ",".join(s)
s = s.replace(",", "")


if len(s) % 2 == 0:
  s1 = "10" * int(len(s) / 2)
  s2 = "01" * int(len(s) / 2)
else:
  s1 = "10" * int(len(s) / 2) + "1"
  s2 = "01" * int(len(s) / 2) + "0"
a1 = int(s) + int(s1)
a2 = int(s) + int(s2)
a1 = str(a1).count("1")
a2 = str(a2).count("1")
#print(min(a1,a2))
result2 = min(a1, a2)
#print("result2:" + str(result2))

"""
if result != result2:
    print(bin(a))
    print("result:" + str(result))
    print("result2:" + str(result2) + "\n")
    print(False)

#print(bin(a))
#print("result:" + str(result))
#print("result2:" + str(result2) + "\n")
"""

Submission status: Wrong Answer

Solution code:
v = input()
s = [v[i: i+2] for i in range(0, len(v), 2)]
list = [0]*4

for i in s:
    #print(i)

    if i == "00":
        list[0] += 1
    elif i == "01":
        list[1] += 1
    elif i == "10":
        list[2] += 1
    elif i == "11":
        list[3] += 1

if list[1] > list[2]:
    print(list[0]*1+list[2]*2+list[3]*1)
elif list[1] < list[2]:
    print(list[0]*1+list[1]*2+list[3]*1)
else:
    print(list[0]*1+list[1]*2+list[3]*1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

str = input()
strList = [str[i: i+3] for i in range(0, len(str), 3)]
#print(strList)
checkList =  ["100", "110", "011","001","000","111"]
fix = 0
firstNum = strList[0]

if firstNum[0] == '1':
    oneFlag = True
else:
    oneFlag = False
if oneFlag == True:
    if strList[0] in checkList:
        if strList[0] == "100":
            strList[0] = "101"
            fix += 1
        elif strList[0] == "110":
            strList[0] = "101"
            fix += 2
        elif strList[0] == "111":
            strList[0] = "101"
            fix += 1
else:
    if strList[0] in checkList:
        if strList[0] == "011":
            strList[0] = "010"
            fix += 1
        elif strList[0] == "001":
            strList[0] = "010"
            fix += 2
        elif strList[0] == "000":
            strList[0] = "010"
            fix += 1



for count in range(1, len(strList), 1):
    cutstr = strList[count]
    #print(fix)
    if cutstr in checkList:
        if cutstr == checkList[0]:
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
            fix += 2
        elif cutstr == checkList[1]:
            fix += 1
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        elif cutstr == checkList[2]:
            fix += 1
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        elif cutstr == checkList[3]:
            fix += 2
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        elif cutstr == checkList[4]:
            fix += 1
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        else:
            fix += 2
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"


if len(strList[len(strList) - 1]) == 1:
    if strList[len(strList) - 2] == "101":
        if strList[len(strList) - 1] == "1":
            strList[len(strList) - 1] = "0"
            fix += 1
    else:
        if strList[len(strList) - 1] == "0":
            strList[len(strList) - 1] = "1"
            fix += 1
elif len(strList[len(strList) - 1]) == 2:
    if strList[len(strList) - 2] == "101":
        if strList[len(strList) - 1] == "11" or strList[len(strList) - 1] == "00":
            strList[len(strList) - 1] = "01"
            fix += 1
        elif strList[len(strList) - 1] == "10":
            strList[len(strList) - 1] = "01"
            fix += 2
    else:
        if strList[len(strList) - 1] == "11" or strList[len(strList) - 1] == "00":
            strList[len(strList) - 1] = "10"
            fix += 1
        elif strList[len(strList) - 1] == "01":
            strList[len(strList) - 1] = "10"
            fix += 2
#print(strList)
print(fix)

Submission status: Wrong Answer

Solution code:

str = input()
strList = [str[i: i+3] for i in range(0, len(str), 3)]
#print(strList)
checkList =  ["100", "110", "011","001","000","111"]
fix = 0
firstNum = strList[0]

if firstNum[0] == '1':
    oneFlag = True
else:
    oneFlag = False
if oneFlag == True:
    if strList[0] in checkList:
        if strList[0] == "100":
            strList[0] = "101"
            fix += 1
        elif strList[0] == "110":
            strList[0] = "101"
            fix += 2
        elif strList[0] == "111":
            strList[0] = "101"
            fix += 1
else:
    if strList[0] in checkList:
        if strList[0] == "011":
            strList[0] = "010"
            fix += 1
        elif strList[0] == "001":
            strList[0] = "010"
            fix += 2
        elif strList[0] == "000":
            strList[0] = "010"
            fix += 1



for count in range(1, len(strList), 1):
    cutstr = strList[count]
    if cutstr in checkList:
        if cutstr == checkList[0]:
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
            fix += 2
        elif cutstr == checkList[1]:
            fix += 1
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        elif cutstr == checkList[2]:
            fix += 1
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        elif cutstr == checkList[3]:
            fix += 2
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        elif cutstr == checkList[4]:
            fix += 1
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        else:
            fix += 2
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"

if len(strList[len(strList) - 1]) == 1:
    if oneFlag == True:
        if strList[len(strList) - 1] == "0":
            strList[len(strList) - 1] = "1"
            fix += 1
    else:
        if strList[len(strList) - 1] == "1":
            strList[len(strList) - 1] = "0"
            fix += 1
elif len(strList[len(strList) - 1]) == 2:
    if oneFlag == True:
        if strList[len(strList) - 1] == "11" or strList[len(strList) - 1] == "00":
            strList[len(strList) - 1] = "10"
            fix += 1

        elif strList[len(strList) - 1] == "01":
            strList[len(strList) - 1] = "10"
            fix += 2
    else:
        if strList[len(strList) - 1] == "11" or strList[len(strList) - 1] == "00":
            strList[len(strList) - 1] = "01"
            fix += 1
        elif strList[len(strList) - 1] == "10":
            strList[len(strList) - 1] = "01"
            fix += 2
#print(strList)
print(fix)

Submission status: Wrong Answer

Solution code:

str = input()
strList = [str[i: i+3] for i in range(0, len(str), 3)]
#print(strList)
checkList =  ["100", "110", "011","001","000","111"]
fix = 0
firstNum = strList[0]

if firstNum[0] == '1':
    oneFlag = True
else:
    oneFlag = False
if oneFlag == True:
    if strList[0] in checkList:
        if strList[0] == "100":
            strList[0] = "101"
            fix += 1
        elif strList[0] == "110":
            strList[0] = "101"
            fix += 2
        elif strList[0] == "111":
            strList[0] = "101"
            fix += 1
else:
    if strList[0] in checkList:
        if strList[0] == "011":
            strList[0] = "010"
            fix += 1
        elif strList[0] == "001":
            strList[0] = "010"
            fix += 2
        elif strList[0] == "000":
            strList[0] = "010"
            fix += 1
if len(strList[len(strList) - 1]) == 1:
    if oneFlag == True:
        if strList[len(strList) - 1] == "0":
            strList[len(strList) - 1] = "1"
            fix += 1
    else:
        if strList[len(strList) - 1] == "1":
            strList[len(strList) - 1] = "0"
            fix += 1
elif len(strList[len(strList) - 1]) == 2:
    if oneFlag == True:
        if strList[len(strList) - 1] != "11" or strList[len(strList) - 1] != "00":
            strList[len(strList) - 1] = "10"
            fix += 1
        elif strList[len(strList) - 1] != "01":
            strList[len(strList) - 1] = "10"
            fix += 2
    else:
        if strList[len(strList) - 1] != "11" or strList[len(strList) - 1] != "00":
            strList[len(strList) - 1] = "01"
            fix += 1
        elif strList[len(strList) - 1] != "10":
            strList[len(strList) - 1] = "01"
            fix += 2
        

for count in range(1, len(strList), 1):
    cutstr = strList[count]
    if cutstr in checkList:
        if cutstr == checkList[0]:
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
            fix += 2
        elif cutstr == checkList[1]:
            fix += 1
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        elif cutstr == checkList[2]:
            fix += 1
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        elif cutstr == checkList[3]:
            fix += 2
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        elif cutstr == checkList[4]:
            fix += 1
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        else:
            fix += 2
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
#print(strList)
print(fix)

Submission status: Wrong Answer

Solution code:

str = input()
strList = [str[i: i+3] for i in range(0, len(str), 3)]
#print(strList)
checkList =  ["100", "110", "011","001","000","111"]
fix = 0
firstNum = strList[0]

if firstNum[0] == '1':
    oneFlag = True
else:
    oneFlag = False
if oneFlag == True:
    if strList[0] in checkList:
        if strList[0] == "100":
            strList[0] = "101"
            fix += 1
        elif strList[0] == "110":
            strList[0] = "101"
            fix += 2
        elif strList[0] == "111":
            strList[0] = "101"
            fix += 1
else:
    if strList[0] in checkList:
        if strList[0] == "011":
            strList[0] = "010"
            fix += 1
        elif strList[0] == "001":
            strList[0] = "010"
            fix += 2
        elif strList[0] == "000":
            strList[0] = "010"
            fix += 1

for count in range(1, len(strList), 1):
    cutstr = strList[count]
    if cutstr in checkList:
        if cutstr == checkList[0]:
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
            fix += 2
        elif cutstr == checkList[1]:
            fix += 1
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        elif cutstr == checkList[2]:
            fix += 1
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        elif cutstr == checkList[3]:
            fix += 2
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        elif cutstr == checkList[4]:
            fix += 1
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        else:
            fix += 2
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
#print(strList)
print(fix)

Submission status: Wrong Answer

Solution code:

str = input()
strList = [str[i: i+3] for i in range(0, len(str), 3)]
#print(strList)
checkList =  ["100", "110", "011","001","000","111"]
fix = 0
firstNum = strList[0]

if firstNum[0] == '1':
    oneFlag = True
else:
    oneFlag = False
if oneFlag == True:
    if strList[0] in checkList:
        if strList[0] == "100":
            strList[0] = "101"
            fix += 1
        elif strList[0] == "110":
            strList[0] = "101"
            fix += 2
        elif strList[0] == "111":
            strList[0] = "101"
            fix += 1
else:
    if strList[0] in checkList:
        if strList[0] == "011":
            strList[0] = "101"
            fix += 2
        elif strList[0] == "001":
            strList[0] = "101"
            fix += 1
        elif strList[0] == "000":
            strList[0] = "101"
            fix += 2
        
for count in range(1, len(strList), 1):
    cutstr = strList[count]
    if cutstr in checkList:
        if cutstr == checkList[0]:
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
            fix += 2
        elif cutstr == checkList[1]:
            fix += 1
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        elif cutstr == checkList[2]:
            fix += 1
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        elif cutstr == checkList[3]:
            fix += 2
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        elif cutstr == checkList[4]:
            fix += 1
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        else:
            fix += 2
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
#print(strList)
print(fix)

Submission status: Wrong Answer

Solution code:

str = input()
strList = [str[i: i+3] for i in range(0, len(str), 3)]
#print(strList)
checkList =  ["100", "110", "011","001","000","111"]
fix = 0
firstNum = strList[0]
if firstNum[0] == '1':
    oneFlag = True
else:
    oneFlag = False
if oneFlag == True:
    if strList[0] in checkList:
        strList[0] = "101"
        fix += 1
else:
    if strList[0] in checkList:
        strList[0] = "010"
        fix += 1

for count in range(1, len(strList), 1):
    cutstr = strList[count]
    if cutstr in checkList:
        if cutstr == checkList[0]:
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
            fix += 2
        elif cutstr == checkList[1]:
            fix += 1
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        elif cutstr == checkList[2]:
            fix += 1
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        elif cutstr == checkList[3]:
            fix += 2
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        elif cutstr == checkList[4]:
            fix += 1
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
        else:
            fix += 2
            if oneFlag == True:
                strList[count] = "010"
            else:
                strList[count] = "101"
#print(strList)
print(fix)

Submission status: Wrong Answer

Solution code:
s=input()
s=list(s)
n=len(s)
acnt=1
bcnt=1
for i in range(n):
    if i!=n-1 and s[i]==s[i+1]:
        a=s[:]
        if s[i]=='0':
            s[i]='1'
        else:
            s[i]='0'
        for j in range(n):
            if j!=n-1 and s[j]==s[j+1]:
                if s[j]=='0': 
                    s[j+1]='1'
                    acnt+=1
                else:
                    s[j+1]='0'
                    acnt+=1
                        
        if a[i]=='0':
            a[i+1]='1'
        else:
            a[i+1]='0'
        for k in range(n):
            if k!=n-1 and a[k]==a[k+1]:
                if a[k]=='0':
                    a[k+1]='1'
                    bcnt+=1
                else:
                    a[k+1]='0'
                    bcnt+=1
                    
        break
if n==1 or bcnt==1 or acnt==1: print(0)
else: print(min(bcnt,acnt))

Submission status: Wrong Answer

Solution code:
s=input()
s=list(s)
n=len(s)
acnt=1
bcnt=1
for i in range(n):
    if i!=n-1 and s[i]==s[i+1]:
        a=s[:]
        if s[i]=='0':
            s[i]='1'
        else:
            s[i]='0'
        for j in range(n):
            if j!=n-1 and s[j]==s[j+1]:
                if s[j]=='0': 
                    s[j+1]='1'
                    acnt+=1
                else:
                    s[j+1]='0'
                    acnt+=1
                        
        if a[i]=='0':
            a[i+1]='1'
        else:
            a[i+1]='0'
        for k in range(n):
            if k!=n-1 and a[k]==a[k+1]:
                if a[k]=='0':
                    a[k+1]='1'
                    bcnt+=1
                else:
                    a[k+1]='0'
                    bcnt+=1
                    
        break
if n==1: print(0)
else: print(min(bcnt,acnt))

Submission status: Wrong Answer

Solution code:
S=[input().split()]
N=len(S)
ans1=0
ans2=0
for i in range(N): #101010...
    if i%2==0 and S[i]!='1':
        ans1+=1
    if i%2==1 and S[i]!='0':
        ans1+=1
for i in range(N): #01010...
    if i%2==0 and S[i]!='0':
        ans2+=1
    if i%2==1 and S[i]!='1':
        ans2+=1
print(min(ans1,ans2))

Submission status: Wrong Answer

Solution code:
S=[input().split()]
N=len(S)
ans1=0
ans2=0
for i in range(N): #101010...
    if i%2==0 and S[i]!=1:
        ans1+=1
    if i%2==1 and S[i]!=0:
        ans1+=1
for i in range(N): #01010...
    if i%2==0 and S[i]!=0:
        ans2+=1
    if i%2==1 and S[i]!=1:
        ans2+=1
print(min(ans1,ans2))

Submission status: Wrong Answer

Solution code:
s=input()

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

for i in range(len(s)):
	if i%2==1:
		if s[i]==0:
			odd_0+=1
		else:
			odd_1+=1
	if i%2==0:
		if s[i]==0:
			even_0+=1
		else:
			even_1+=1
print(min([even_1+odd_0,even_0+odd_1]))

Submission status: Wrong Answer

Solution code:
S = input()
counter = 0
counter2 = 0
def Even_Counter(S):
    global counter, counter2
    for i in range(0, len(S), 2):
        if S[i] != '1':
            counter += 1
        if S[i+1] != '0':
            counter += 1
    for i in range(0, len(S), 2):
        if S[i] != '0':
            counter2 += 1
        if S[i+1] != '1':
            counter2 += 1
#even
if len(S) % 2 == 0:
    Even_Counter(S)

#odd
if len(S) % 2 == 1:
    Even_Counter(S[:len(S)-1])
    if S[len(S)-1] != '0':
        counter += 1
    else:
        counter2 += 1

print(min(counter, counter2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
str = input()
S = []
N = len(str)
for i in range(N):
  S = list(str)

ans = 0
if len(S) >= 3:
  if S[0] == S[1] and S[1] == S[2]:
    num = S[0]
    if num == 1:
      S[1] = 0
    else:
      S[1] = 1
    ans = ans +1

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

print(ans)

Submission status: Wrong Answer

Solution code:
def sub():
    ss = [e for e in input()]
    if len(ss) == 1:
        print("0")
        return

    countZero = 0
    countOne = 0
    for s in ss:
        if s == "0":
            countZero = countZero + 1
        else:
            countOne = countOne + 1
    cFlip = None
    if countZero > countOne:
        cFlip = "1"
    else:
        cFlip = "0"
    
    memC = ss[0]
    count = 0
    if memC == cFlip:
        count = count + 1
        if memC == "0":
            memC = "1"
        else:
            memC="0"
    for i in range(1, len(ss)):
        cI = ss[i]
        if memC == cI:
            count = count + 1
            if cI == "0":
                memC = "1"
            else:
                memC = "0"
    print("{}".format(count))

sub()

Submission status: Wrong Answer

Solution code:
s=[int(x) for x in list(input())]


e = [0, 1] * (int(len(s)/2) + 1)

h = [0, 0]
h[0] = sum([x == ei for x, ei in zip(s,e[0:len(s)])])
h[1] = sum([x == ei for x, ei in zip(s,e[1:len(s)])])

print(min(h))