Problem:


Score : 300 points

Problem Statement

There are N cubes stacked vertically on a desk.

You are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.

You can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.

At most how many cubes can be removed?

Constraints

1 \leq N \leq 10^5

|S| = N

Each character in S is 0 or 1.

Input

Input is given from Standard Input in the following format:

S

Output

Print the maximum number of cubes that can be removed.

Sample Input 1

0011

Sample Output 1

4

All four cubes can be removed, by performing the operation as follows:

Remove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.

Remove the first and second cubes from the bottom.

Sample Input 2

11011010001011

Sample Output 2

12

Sample Input 3

0

Sample Output 3

0



Sample input:
0011


Sample output:
4

Submission status: Wrong Answer

Solution code:
s = input()
count = 0

while s.find("01") != -1 or s.find("10") != -1:
    count += 2 * s.count("10") +  2 * s.count("01")
    s = s.replace("01", "").replace("10", "")
print(count)

Submission status: Wrong Answer

Solution code:
def unification(h,n,s,count):
    if n < 1:
        return count

    for i in range(h,n-1):
        if s[i] !=  s[i+1]:
            s.pop(i)
            s.pop(i)

            count = unification(i-1,n-2,s,count+2)
            break

    return count


if __name__ == '__main__':
    s = raw_input()
    n = len(s)
    _s = [i for i in s]

    print unification(0,n,_s,0)

Submission status: Wrong Answer

Solution code:
s = input()
result = 0
while True:
  t = len(s)
  i = 0
  a = []
  while i < len(s) - 1:
    if s[i] != s[i + 1]:
      result += 2
      i += 1
    else:
      a.append(s[i])
    i += 1
  s = ''.join(a)
  if len(s) == t:
    break
print(result)

Submission status: Wrong Answer

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

count0=0
count1=0
lastElm=-1
S=[]
s=input()
for c in s:
        S.append(c)
S.pop(-1)

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

for i in range(len(S)):
        if i==0:
                count0=S.count("0")
                count1=S.count("1")
        else:
                if lastElm == "0":
                        count0 -= 1
                elif lastElm == "1":
                        count1 -= 1
        if count0 == count1:
                print(count0*2)
                exit()
        else:
                lastElm = S[-1]
                S.pop(-1)

Submission status: Wrong Answer

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

count0=0
count1=0
S=[]
s=input()
for c in s:
        S.append(c)
S.pop(-1)

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

for _ in range(len(S)):
        count0=S.count("0")
        count1=S.count("1")
        if count0 == count1:
                print(count0*2)
                exit()
        else:
                S.pop(-1)

Submission status: Wrong Answer

Solution code:
s=input();print(min(s.count('0'),s.count('1')))

Submission status: Wrong Answer

Solution code:
from collections import Counter
C = Counter(list(input()))
print(C["0"] if C["0"]<=C["1"] else C["1"])

Submission status: Wrong Answer

Solution code:

S = input()
s = S.replace('0011', '').replace('1100', '').replace('0101', '').replace('1010', '').replace('01', '').replace('10', '')

print(len(S) - len(s))

Submission status: Wrong Answer

Solution code:
S = [i for i in input()]
one = S.count("1")
zero = S.count("0")
print(min(one,zero))

Submission status: Wrong Answer

Solution code:
import fractions

S = str(input())
cube = list(S)
count0 = 0
count1 = 0

for string in cube:
    if string == '0':
        count0 = count0 + 1
    else:
        count1 = count1 + 1

print(min(count0,count1))

Submission status: Wrong Answer

Solution code:
s=str(input())

a=s.count('0')
b=s.count('0')
print(min(a,b)*2)

Submission status: Wrong Answer

Solution code:
s=str(input())
c=len(s)

for _ in range(1000):
        s=s.replace('01','')
        s=s.replace('10','')
print(c-len(s))

Submission status: Wrong Answer

Solution code:
s=str(input())
c=len(s)

for _ in range(100):
        s=s.replace('01','')
        s=s.replace('10','')
print(c-len(s))

Submission status: Wrong Answer

Solution code:
s=list(str(input()))
c=len(s)

for _ in range(100):
        for i in range(len(s)-1):
                if s[i]==str(0) and s[i+1]==str(1):
                        s[i]=''
                        s[i+1]=''
                elif s[i]==str(1)  and s[i+1]==str(0):
                        s[i]=''
                        s[i+1]=''
        l=s
        s=[]
        for i in range(len(l)):
                if l[i]==str(0) or l[i]==str(1):
                        s.append(l[i])
print(c-len(s))

Submission status: Wrong Answer

Solution code:
s=list(str(input()))
c=len(s)

for _ in range(10):
        for i in range(len(s)-1):
                if s[i]==str(0) and s[i+1]==str(1):
                        s[i]=''
                        s[i+1]=''
                elif s[i]==str(1)  and s[i+1]==str(0):
                        s[i]=''
                        s[i+1]=''
        l=s
        s=[]
        for i in range(len(l)):
                if l[i]==str(0) or l[i]==str(1):
                        s.append(l[i])
print(c-len(s))

Submission status: Wrong Answer

Solution code:
Sl = list(input())

cnt = 0
i = 0
while True:
    if len(Sl)==0 or len(Sl)==1:
        break
    
    if i==0:
        if Sl[0]=="0":
            isZero = True
        else:
            isZero = False
    i += 1
    
    if i >= len(Sl):
        break
    
    if isZero:
        if Sl[i]=="1":
            Sl.pop(i)
            Sl.pop(i-1)
            cnt += 2
            i = -1
    else:
        if Sl[i]=="0":
            Sl.pop(i)
            Sl.pop(i-1)
            cnt += 2
            i = -1
                
print(cnt)

Submission status: Wrong Answer

Solution code:
s = input()

count_0 = 0
count_1 = 1
for i in range(len(s)):
    if s[i] == '0':
        count_0 += 1
    else:
        count_1 += 1

print(min(count_0,count_1) * 2)

Submission status: Wrong Answer

Solution code:
S = list(input())

ans = 0

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

if (len(S) - 1) % 2 != 0:
    if S[-2] != S[-1]:
        ans += 2
print(ans)

Submission status: Wrong Answer

Solution code:
s = list(map(int, list(input())))
i = [x for x in s if x == 1]
n = len(s)
m = sum(i)
if n <= m:
    print(n*2)
else:
    print(m*2)

Submission status: Wrong Answer

Solution code:
a,b=input(),0
for i in range(len(a)):
    if a[i]=='0':
        b+=1
print(max(min(b,int(a)-b),0)*2)

Submission status: Wrong Answer

Solution code:
N = input()
zeronum = N.count("0")
onenum = N.count("1")

ans = 2 + min(zeronum,onenum)
print(ans)

Submission status: Wrong Answer

Solution code:
S=input()
s0=S.count("0")
s1=S.count("1")

print(min(s0,s1))

Submission status: Wrong Answer

Solution code:
s = str(input())
count_0 = 0
count_1 = 0

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

Submission status: Wrong Answer

Solution code:
import sys
s = input()
if len(s) == 0:
    print(0)
    sys.exit()
nokori = 0
streak = 1
temp = s[0]
for i in range(1,len(s)):
    if temp == s[i]:
        streak += 1
    else:
        if streak % 2 == 0:
            nokori += 0
        else:
            nokori += 1
        streak = 0

print(len(s) - nokori)

Submission status: Wrong Answer

Solution code:
s = input()
nokori = 0
streak = 1
temp = s[0]
for i in range(1,len(s)):
    if temp == s[i]:
        streak += 1
    else:
        if streak % 2 == 0:
            nokori += 0
        else:
            nokori += 1
        streak = 0

print(len(s) - nokori)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
old_length=-1
for i in range(n):
  if old_length==len(s):
    break
  old_length=len(s)
  s=s.replace('0101','').replace('1010','').replace('01','').replace('01','')
print(n-len(s))

Submission status: Wrong Answer

Solution code:
s = input()
s = list(s)
print(2*min(s.count(0),s.count(1)))

Submission status: Wrong Answer

Solution code:
S = input()

ret = 0
while '01' in S:
    ret += 1
    S.replace('01', '')

print(ret)

Submission status: Wrong Answer

Solution code:
s = input()
zero = len([x for x in s if x == "0"])
one = len(s) - zero

print(min(zero, one))

Submission status: Wrong Answer

Solution code:
import re

pattern = re.compile('01|10')

#def remove(tower, count):
#  target = len(pattern.findall(tower))
#  if target:
#    remove(pattern.sub('', tower), count + target)
#  else:
#    print(pattern.split(tower))
#    print(count * 2)
    
def remove(tower, count):
  m = pattern.split(tower)
  operation = len(m) - 1
  if operation == 0:
    print(m)
    print(count * 2)
  else:
    remove(''.join(m), count + operation)
    
    

count = 0
remove(input(), count)

Submission status: Wrong Answer

Solution code:
S = input()

s_list=[]
for i in range(len(S)):
    s_list.append(int(S[i]))

num=0
judge=1
N=len(s_list)
while judge==1:
    judge=0
    for i in range(2,N):
        if i+1 < len(s_list):
            while s_list[i] != s_list[i+1]:
                #print(i,len(s_list),s_list,s_list[i],s_list[i+1])
                del s_list[i:i+2]
                num+=2
                judge=1
                if i>0 and i<len(s_list):
                    if s_list[i-1] == s_list[i]:
                        del s_list[i:i + 2]
                        judge=1
                        num+=2
                if i+i>=len(s_list):
                    break
        else:
            break
    N = len(s_list)
print(num)

Submission status: Wrong Answer

Solution code:
S = input()

s_list=[]
for i in range(len(S)):
    s_list.append(int(S[i]))

num=0
judge=1
N=len(s_list)
while judge==1:
    judge=0
    for i in range(N):
        if i+1 < len(s_list):
            while s_list[i] != s_list[i+1]:
                print(i,len(s_list),s_list,s_list[i],s_list[i+1])
                del s_list[i:i+2]
                num+=2
                judge=1
                if i+i>=len(s_list):
                    break
        else:
            break
    N = len(s_list)
print(num)

Submission status: Wrong Answer

Solution code:
S = input()
print(S)
s_list=[]
for i in range(len(S)):
    s_list.append(S[i])

num=0
judge=1
N=len(s_list)
while judge==1:
    judge=0
    for i in range(N):
        if i+1 < len(s_list):
            if s_list[i] != s_list[i+1]:
                #print(i,len(s_list),s_list,s_list[i],s_list[i+1])
                del s_list[i:i+2]
                num+=2
                judge=1
                N = len(s_list)
print(num)

Submission status: Wrong Answer

Solution code:
from collections import deque
r=deque(map(int,list(input())))
l=deque()
cnt=0
while len(r)>0:
	if len(l)==0:
		l.append(r.popleft())
	if len(r)==0:
		break
	if l[-1] + r[0]==1:
		l.pop()
		r.popleft()
		cnt += 2
	else:
		l.append(r.popleft())
	print(l,r)
		
print(cnt)

Submission status: Wrong Answer

Solution code:
s = input()
cnt_one = s.count('1')
cnt_zero = len(s) - cnt_one
print(len(s) - min(cnt_zero, cnt_one)*2)

Submission status: Wrong Answer

Solution code:
S = input()
ans = 0
stack = []
for i in range(len(S)):
    if len(stack)==0:
        stack.append(S[i])
    if S[i] != stack[-1]:
        ans += 2
        stack.pop()
    else:
        stack.append(S[i])
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
S = str(input())

#(S[i - 1] == '1' and S[i] == '0') or (S[i - 1] == '0' and S[i] == '1')

S_dict = {}
if len(S) == 1:
    print(1)
    sys.exit()

for letter in S:
    if letter == '1':
        if letter in S_dict:
            S_dict[letter] += 1
        else:
            S_dict[letter] = 1
    elif letter == '0':
        if letter in S_dict:
            S_dict[letter] += 1
        else:
            S_dict[letter] = 1

if len(S_dict.values()) == 1:
    print(0)
    sys.exit()
print(min(S_dict.values()) * 2)

Submission status: Wrong Answer

Solution code:
S = str(input())

#(S[i - 1] == '1' and S[i] == '0') or (S[i - 1] == '0' and S[i] == '1')

S_dict = {}
for letter in S:
    if letter == '1':
        if letter in S_dict:
            S_dict[letter] += 1
        else:
            S_dict[letter] = 1
    elif letter == '0':
        if letter in S_dict:
            S_dict[letter] += 1
        else:
            S_dict[letter] = 1
        
print(min(S_dict.values()) * 2)

Submission status: Wrong Answer

Solution code:
s = input()

count = 0
while True:
    s0 = s
    s = s.replace("11","",1)
    if s0 != s:
        count += 2
        #print(s)
    else:
        s1 = s
        s = s.replace("00","",1)
        if s1 != s:
            count += 2
            #print(s)
        else:
            break

#print(s)
print(count)

Submission status: Wrong Answer

Solution code:
c0=0
c1=0
for i in input():
  if i=="1":
    c1+=1
  else:
    c0+=1
print(min(c0,c1))

Submission status: Wrong Answer

Solution code:
s=input()
c=0
n=1
while n>0:
  n=s.count('01')
  s=s.replace('01','')
  c=c+n
  n=s.count('10')
  s=s.replace('10','')
  c=c+n
print(c*2)

Submission status: Wrong Answer

Solution code:
s = [int(x) for x in input()]
ans = 0
cnt = 1

while cnt>0:
	cnt = 0
	for i in range(len(s)-1):
		if s[i] + s[i+1] == 1:
			s[i]=2
			s[i+1]=2
			cnt = 1
			ans+=1
		# print(s)
	while 2 in s:
		s.remove(2)
	# print(s)

print(ans)

Submission status: Wrong Answer

Solution code:
s=list(map(int,input()))
i=0
ans=0
a=s[i]
b=s[i]

while True:
    try:
        #print(s)
        i=i+1
        #print(i)
        a=s[i]
        if a!=b:
            del s[i-1]
            del s[i-1]
            ans=ans+2
            #print(ans)
            i=i-2
            a=s[i]
        b=a
    except:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
s=list(map(int,input()))
i=0
ans=0
a=s[i]
b=s[i]
while True:
  try:
    a=s[i]

    if a != b:
        del s[i]
        del s[i-1]
        ans=ans+2
        i=i-2
        a = s[i]
        b = s[i]
    b=a
    i=i+1
  except:
      break
print(ans)

Submission status: Wrong Answer

Solution code:
s=list(map(int,input()))
i=0
ans=0
a=s[i]
b=s[i]
while True:
  try:
    a=s[i]

    if a != b:
        del s[i]
        del s[i-1]
        ans=ans+2
        i=i-3
        a = s[i]
        b = s[i]
    b=a
    i=i+1
  except:
      break
print(ans)

Submission status: Wrong Answer

Solution code:
s=list(map(int,input()))
i=0
ans=0
a=s[i]
b=s[i]
while True:
  try:
    a=s[i]

    if a != b:
        del s[i]
        del s[i-1]
        ans=ans+2
        i=0
    b=a
    i=i+1
  except:
      break
print(ans)

Submission status: Wrong Answer

Solution code:
s=list(map(int,input()))
i=0
ans=0
a=s[i]
b=s[i]
while True:
  try:
    a=s[i]
    i=i+1
    if a != b:
        del s[i]
        del s[i-1]
        ans=ans+2
        if i>2:
            i=i-3
        else:
            i=0
    b=a
  except:
      break
print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    S = input()
    zeros = S.count("0")
    print(min(zeros, len(S))* 2)

if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
S = str(input())

ans = len(S)
for i in range(len(S)):
  new_S = S.replace("01","")
  if new_S == S:
    break
  else:
    S = new_S

print(ans-len(new_S))

Submission status: Wrong Answer

Solution code:
S = str(input())

ans = 0
for i in range(100000):
  if S in "01" and len(S) >= 2:
    ans +=1
  new_S = S.replace("01","",1)
  if new_S == S:
    break
  else:
    S = new_S

print(ans*2)

Submission status: Wrong Answer

Solution code:
s = input()
	
print(min(s.count("1"),s.count("0")))

Submission status: Wrong Answer

Solution code:
s = input()
	
print(abs(s.count("1")-s.count("0")))

Submission status: Wrong Answer

Solution code:
import numpy as np

s=np.array(list(map(int,list(input()))))
k = s*2-1
print(len(k)-sum(k))

Submission status: Wrong Answer

Solution code:
s=input()
a=s.count("1")
b=s.count("2")

print(min(a,b)*2)

Submission status: Wrong Answer

Solution code:
s=input()
a=s.count("1")
b=s.count("2")

print(min(a,b))

Submission status: Wrong Answer

Solution code:
s = input()
n0, n1 = 0, 0

for c in s:
  if c == '0':
    n0 += 1
  else:
    n1 += 1
      
print(min(n0, n1))

Submission status: Wrong Answer

Solution code:
s = input()
n0, n01 = 0, 0

for c in s:
  if c == '0':
    n0 += 1
  else:
    if n0 == 0:
      continue
    else:
      n0 -= 1
      n01 += 2
      
print(n01)

Submission status: Wrong Answer

Solution code:
s = input()
red = s.count("1")
blue = s.count("0")

ans = red if red>blue else blue
ans = ans*2
print(ans)

Submission status: Wrong Answer

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

S = input()
stack = []
count = 0
for s in S:
  if not stack:
    stack.append(s)
  elif s != stack[-1]:
    stack.pop()
    count += 2
  else:
    stack.append(s)
print(count)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
ans = 0
if n < 1:
  print(0)
else:
  a,b = s.count('0'), s.count('1')
  for _ in range(min(a,b)+1):
    c, d = s.count('01'), s.count('10')
    print(s)
    if len(s) <= 0 or c+d <= 0:
      break
    c = s.count('01')
    if c > 0:
      ans += c*2
      s = s.replace('01', '')
    d = s.count('10')
    if d > 0:
      ans += d*2
      s = s.replace('10', '')

print(ans)

Submission status: Wrong Answer

Solution code:
s = list(input())
ans = 0

zero = s.count('0')
one = len(s) - zero

if zero == one:
    ans = 0
else:
    ans = min(zero, one) * 2

print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

ans1 = 0
onecount = 0
for i in range(len(S)):
    if S[i] == "0":
        if onecount > 0:
            ans1 += 2
            onecount -= 1
    else:
        onecount += 1

ans2 = 0
zerocount = 0
for i in range(len(S)):
    if S[i] == "1":
        if zerocount > 0:
            ans2 += 2
            zerocount -= 1
    else:
        zerocount += 1
print(max(ans1, ans2))

Submission status: Wrong Answer

Solution code:
S = input()
prev_len = len(S)
while S.find("01") != -1 or S.find("10") != -1:
    S = S.strip("01")
    S = S.strip("10")
curr_len = len(S)
print(prev_len - curr_len)

Submission status: Wrong Answer

Solution code:
S = input()
red = S.count("0")
blue = S.count("1")
print(2 * abs(red - blue))

Submission status: Wrong Answer

Solution code:
from collections import Counter
S = list(input())
c = Counter(S)
ans = min(c["0"], c["1"])
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)

count = 0
for i in range(N):
    if S[i] == 0:
        count += 1

ans = min(count, N - count) * 2
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)

count = 0
for i in range(N):
    if S[i] == 0:
        count += 1

ans = min(count, N - count)
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
total = 0

while '01' in s:
  total += s.count('01') * 2
  s = s.replace('01', '')
  total += s.count('10') * 2
  s = s.replace('10', '')
  
print(total)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    S = str(input())
    N = len(S)

    count_0 = S.count('0')
    count_1 = S.count('1')

    answer = min(count_0, count_1)

    print(answer)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    S = str(input())
    N = len(S)

    count_0 = S.count('0')
    count_1 = S.count('1')

    answer = min(count_1, count_1)

    print(answer)

Submission status: Wrong Answer

Solution code:
s = list(input())
print(min(s.count('0'),s.count('1')))

Submission status: Wrong Answer

Solution code:
S=str(input())
int_S=[]
for i in range(0,len(S)):
    int_S.append(int(S[i]))
global_count=0
count=1
while(count!=0):
    new_list=[]
    count=0
    i=0
    while(i<len(S)-1):
        if(S[i]!=S[i+1]):
            global_count+=2
            i+=2
            count+=1
        else:
            new_list.append(S[i])
            i+=1
    S=new_list
 
print(global_count)

Submission status: Wrong Answer

Solution code:
S = input()
S = S.replace("0","r")
S = S.replace("1","b")
r = 0
b = 0
for s in S:
    if s == "r":
        r+=1
    else:
        b+=1
print(min([r,b]))

Submission status: Wrong Answer

Solution code:
import re
import copy
s=input()
sr,ss=copy.deepcopy(s),""
while ss!=sr:
    sr,ss=ss,re.sub("0+1+|1+0+","",ss if sr!=s else s)
print(len(s)-len(ss))

Submission status: Wrong Answer

Solution code:
S = input()
2*min(S.count('0'), S.count('1'))

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)
A = 0

for i in range(N):
    if S[i] == '1':
        A = A + 1

print(abs(N - A)*2)

Submission status: Wrong Answer

Solution code:
S=input()
S='9'+S+'9'
ans = 0
while 1:
    flg=True
    for i in range(len(S)-1):
        if S[i]!=S[i+1] and S[i]!=9 and S[i+1]!=9:
            S=S[:i]+S[i+2:]
            ans += 2
            flg=False
            break
    if flg:
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:
s = list(input())
n = len(s)
c1 = 0
for i in range(len(s)-1):
    if(s[i] == '0'):
        c1 += 1
c2 = len(s) - c1
print(len(s) - abs(c1 - c2))

Submission status: Wrong Answer

Solution code:
S = str(input())
Smae = S
while True:
    S = S.replace('01', '')
    S = S.replace('10', '')
    if '01' not in S or '10' not in S:
        break
print(len(Smae) - len(S))

Submission status: Wrong Answer

Solution code:
s = input()

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

a = max(count, len(s) - count)

if a % 2 == 0:
    print(len(s))
else:
    print(len(s) - 2)

Submission status: Wrong Answer

Solution code:
n=10^5
s=input()
t=list(s)
t=len(t)
for i in range (1,n):
  s=s.replace("01","")
  s=s.replace("10","")
k=len(s)
x=t-k
import math
x=math.floor(x)
print(t-k)

Submission status: Wrong Answer

Solution code:
n=5*10^4
s=input()
t=list(s)
t=len(t)
for i in range (0,n):
  s=s.replace("01","")
  s=s.replace("10","")
k=len(s)
x=t-k
import math
x=math.floor(x)
print(t-k)

Submission status: Wrong Answer

Solution code:
n=5*10^4
s=input()
t=list(s)
t=len(t)
for i in range (1,n):
  s=s.replace("01","")
  s=s.replace("10","")
k=len(s)
x=t-k
import math
x=math.floor(x)
print(t-k)

Submission status: Wrong Answer

Solution code:
S = input()
num_length = len(S)
counter_0 = 0
counter_1 = 0
for i in range(num_length):
    if S[i] == 0:
        counter_0 += 1
    if S[i] == 1:
        counter_1 += 1

if counter_0 <= counter_1:
    print(2*counter_0)
else:
    print(2*counter_1)

Submission status: Wrong Answer

Solution code:
S = input()
num_length = len(S)
counter_0 = 0
counter_1 = 0
for i in range(num_length):
    if S[i] == 0:
        counter_0 += 1
    if S[i] == 1:
        counter_1 += 1

if counter_0 <= counter_1 and counter_0 > 0:
    print(2*counter_0)
elif counter_0 > counter_1 and counter_1 > 0:
    print(2*counter_1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
S = input()
num_length = len(S)
counter_0 = 0
counter_1 = 0
for i in range(num_length):
    if S[i] == 0:
        counter_0 += 1
    if S[i] == 0:
        counter_1 += 1

if counter_0 <= counter_1:
    print(2*counter_0)
else:
    print(2*counter_1)

Submission status: Wrong Answer

Solution code:
S = str(input())

zero_num = 0
one_num = 0

for i in range(len(S)):
    if S[i] == 0:
        zero_num += 1
    else:
        one_num += 1

print(2*min(zero_num, one_num))

Submission status: Wrong Answer

Solution code:
S = input()

red = S.count('0')
blue = S.count('1')
N = red + blue

if red > blue:
    print(N-(red-blue))
elif blue < red:
    print(N-(blue-red))

Submission status: Wrong Answer

Solution code:
k = input()
ol = pl = len(k)
l = 0
while l != pl:
  k.replace("01", "").replace("10", "")
  l = len(k)
print(ol - l)

Submission status: Wrong Answer

Solution code:
def smaller(x, y):
	if x < y: return x
	else: return y

S = raw_input()
count = [0, 0]
for i in range(0, len(S)):
	count[int(S[i])] += 1

print smaller(count[0], count[1])

Submission status: Wrong Answer

Solution code:
ss = list(input())

cnt = 0
i = 1
while True:
	#print(i, ss)
	if i >= len(ss):
		break
	if ss[i-1] != ss[i]:
		ss.pop(i-1)
		ss.pop(i-1)
		cnt += 2
		if i > 0:
			i -= 1
	else:
		i += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
x=0
y=0
for i in list(input()):
  if i=='0':
    x+=1
  else:
    y+=1
print(min(x,y))

Submission status: Wrong Answer

Solution code:
import re
S = input()

match_101 = re.compile('10(?=1)')
match_010 = re.compile('01(?=0)')
match_1100 = re.compile('1(1+0+)0')
match_0011 = re.compile('0(0+1+)1')

def pre_remove(s, i):
    '''
    101 -> 1
    010 -> 0
    0011 -> 01
    1100 -> 10
    この並びの時は順番にかかわらず短縮しても良い
    '''
    cs = s
    prev_s = cs
    ci = i
    prev_ci = ci
    while True:
        cs = match_101.sub('', cs)
        cs = match_010.sub('', cs)
        cs = match_1100.sub('10', cs)
        cs = match_0011.sub('01', cs)
        cs = cs[2:] if cs.startswith('10') else cs
        cs = cs[2:] if cs.startswith('01') else cs
        cs = cs[:-2] if cs.endswith('10') else cs
        cs = cs[:-2] if cs.endswith('01') else cs
        ci += len(prev_s) - len(cs)
        if prev_ci == ci:
            return (cs, ci)
        prev_s = cs
        prev_ci = ci
S_2, i_2 = pre_remove(S, 0)
print(i_2)

Submission status: Wrong Answer

Solution code:
from collections import deque

def unification(string):

    n = len(string)

    if n == 1:
        return 0

    q = deque()
    idx = 2
    q.appendleft(string[0])
    q.appendleft(string[1])
    count = 0

    while idx < n:
        while len(q) > 1 and q[0] != q[1]:
            q.popleft()
            q.popleft()
            count += 2

        q.appendleft(string[idx])
        idx += 1

    return count


if __name__ == "__main__":
    string = input()
    print(unification(string))

Submission status: Wrong Answer

Solution code:
from collections import deque                                        
                                                                     
def unification(string):                                             
                                                                     
    n = len(string)                                                  
                                                                     
    if n == 1:                                                       
        return 0                                                     
                                                                     
    q = deque()                                                      
    idx = 2                                                          
    q.appendleft(string[0])                                          
    q.appendleft(string[1])                                          
    count = 0                                                        
                                                                     
    while idx < n:                                                   
        while len(q) > 1 and q[0] != q[1]:                           
            q.pop()                                                  
            q.pop()                                                  
            count += 2                                               
                                                                     
        q.appendleft(string[idx])                                    
        idx += 1                                                     
                                                                     
    return count                                                     
                                                                     
                                                                     
if __name__ == "__main__":                                           
    string = input()                                                 
    print(unification(string))

Submission status: Wrong Answer

Solution code:
from sys import stdin

# 標準入力の受取
sdi = stdin.readline().rstrip()
# a, b, c = stdin.readline().rstrip().split()
# a, b, c = [x for x in stdin.readline().rstrip().split()]
# a, b, c = [int(x) for x in stdin.readline().rstrip().split()]

l = list(sdi)
l.reverse()
start = len(l)
r = 0
i = 0
while len(l) >= i + 2:
    if l[i] != l[i + 1]:
        l.pop(i + 1)
        l.pop(i)
        i = max(i-2, 0)
    i += 1

print(start - len(l))

Submission status: Wrong Answer

Solution code:
from sys import stdin

# 標準入力の受取
sdi = stdin.readline().rstrip()
# a, b, c = stdin.readline().rstrip().split()
# a, b, c = [x for x in stdin.readline().rstrip().split()]
# a, b, c = [int(x) for x in stdin.readline().rstrip().split()]

l = list(sdi)
l.reverse()
start = len(l)
r = 0
i = 0
while len(l) >= i + 2:
    if l[i] != l[i + 1]:
        l.pop(i + 1)
        l.pop(i)
        print("cut", i, i+1)
        i = max(i-2, 0)
    i += 1

print(start - len(l))

Submission status: Wrong Answer

Solution code:
S=input()


S=[s for s in S]

count=0
i=0
while(i<len(S)-1):
	#print(i,S)
	if(int(S[i])+int(S[i+1])==1):
		count+=2
		if(i>0):
			i-=1
		if(i<=len(S)-3):
			S=S[:i]+S[i+2:]
	else:
		i+=1

print(count)

Submission status: Wrong Answer

Solution code:




S=input()


S=[s for s in S]

#ハジはまた考える
#真ん中を覗く時にできるパターン
#0100 | 00 !
#0010 | 00 !
#1100 | 10
#1010 | 10 !
#0101 | 01 !
#0011 | 01 !
#1101 | 11 !
#1011 | 11 !
#つまり, どのように撮っても結果は変わらない


N=len(S)
#O(N)で可能

index=0
count=0
while(index!=N-1):
	if(int(S[index])+int(S[index+1])==1):
		count+=2
		if(index>=1):
			S[index+1]=S[index-1]
			index+=1
		else:
			index+=2
		
		

	else:
		index+=1
print(count)

Submission status: Wrong Answer

Solution code:
s = list(input())
zero = s.count("0")
ans = max(len(s)-zero,zero)
print(ans*2)

Submission status: Wrong Answer

Solution code:
A = list(map(int,input()))
c = 0
i = 0
while True:
    d = 0
    while i < len(A)-1-c:
    #for i in range(len(A)-1-c):
        #print(i)
        if A[i] != A[i+1]:
            c += 2
            d = 1
            #print(A,c,i)
            for j in range(i,len(A)-c):
                A[j] = A[j+2]
            i -= 2
        i += 1
    if d == 0:
        break
print(c)

Submission status: Wrong Answer

Solution code:
S = list(input())
remove = [False] * len(S)

count = 0
is_continue = False

while True:
  is_continue = False
  remove = [False] * len(S)
  for i in range(len(S) - 2):
    if S[i] != S[i+1]:
      remove[i] = True
      remove[i+1] = True
      count += 2
      i += 1
      is_continue = True

  if is_continue == False:
    if len(S) >= 2:
      if S[0] != S[1]:
        S.pop(0)
        S.pop(0)
        count += 2
    print(count)
    exit()
      
  tmp = []
  for i in range(len(S)):
    if remove[i] == False:
      tmp.append(S[i])

  S = tmp
  print(S)

Submission status: Wrong Answer

Solution code:
S = list(input())
remove = [False] * len(S)

count = 0
is_continue = False

while True:
  is_continue = False
  for i in range(len(S) - 2):
    if S[i] != S[i+1]:
      remove[i] = True
      remove[i+1] = True
      count += 2
      i += 1
      is_continue = True

  if is_continue == False:
    if len(S) >= 2:
      if S[0] != S[1]:
        S.pop(0)
        S.pop(0)
        count += 2
    print(count)
    exit()
      
  tmp = []
  for i in range(len(S)):
    if remove[i] == False:
      tmp.append(S[i])

  S = tmp