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

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    S = SS()

    ans = 0
    stk = []
    for i in S:
        if stk and stk[-1] != i:
            stk.pop()
            ans += 2
        else:
            stk.append(i)

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
S = input()
cnt_0 = S.count('0')
cnt_1 = S.count('1')

print(min(cnt_0, cnt_1)*2)

Submission status: Accepted

Solution code:
S=list(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())
x = s.count('0')
y = s.count('1')
print(min(x,y)*2)

Submission status: Accepted

Solution code:
S = input()

num_0 = S.count('0')
num_1 = S.count('1')

print(min(num_0, num_1)*2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

zero = s.count('0')
one = s.count('1')

print(min(zero,one)*2)

Submission status: Accepted

Solution code:

S = input()
num_0 = S.count("0")
num_1 = S.count("1")
print(2 * min(num_0, num_1))

Submission status: Accepted

Solution code:
S = input()
z = 0
o = 0
for c in S:
    if c == '0':
        z += 1
    else:
        o += 1
print(min([z,o])*2)

Submission status: Accepted

Solution code:
S = list(input())
one = S.count('1')
zero = S.count('0')

print(2*min(one,zero))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
A = S.count("0")
B = S.count("1")
print(2*min(A, B))

Submission status: Accepted

Solution code:
S=input()
o=0
i=0
for j in S:
    if j=="0":
        o+=1
    else:
        i+=1
print(min(o,i)*2)

Submission status: Accepted

Solution code:
S=input()
zero=0
one=0
for i in range(len(S)):
    if S[i]=='1':
        one+=1
    else:
        zero+=1
print(min(zero,one)*2)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
a = s.count('1')
b = s.count('0')
if a>=b:
  print(b*2)
else:
  print(a*2)

Submission status: Accepted

Solution code:
S=input()
cnt0 = 0
cnt1 = 0
for i in range(len(S)):
  if S[i]=='0':
    cnt0 += 1
  else:
    cnt1 += 1
print(min(cnt0, cnt1)*2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
b=input()
A=b.count("1")
B=b.count("0")
print(min(2*A,2*B))

Submission status: Accepted

Solution code:
# coding:utf-8
s = input()
a = s.count('0')
b = s.count('1')

print(2 * min(a, b))

Submission status: Accepted

Solution code:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():

    s = list(input().rstrip())
    zero = 0
    one = 0
    for i in s:
        if i == "0":
            zero += 1
        else:
            one += 1
    print(2*min(zero,one))

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
S=list(str(input()))
zero=S.count("0")
one=S.count("1")
if zero==0 or one==0:
  print(0)
else:
  print(min(zero,one)*2)

Submission status: Accepted

Solution code:
S = input().rstrip()
T = []
cnt = 0
for s in S:
    if not T:
        T.append(s)
        continue
    if s!=T[-1]:
        cnt += 2
        T.pop()
    else:
        T.append(s)
print(cnt)

Submission status: Accepted

Solution code:
S = input()

zero = S.count("0")
one = S.count("1")

if zero != 0 and one != 0:
  print(min(zero,one)*2)
else:
  print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

length = len(s)

r = s.count('0')
b = s.count('1')

print(length - abs(r-b))

Submission status: Accepted

Solution code:
import math
from collections import Counter
s = list(input())
s = list(map(int, s))
dict_s = Counter(s)
#print(dict_s)
print((min(dict_s[0], dict_s[1]))*2)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()

    red = S.count('0')
    blue = len(S) - red

    print(min(red, blue) * 2)

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
l0 = S.count("0")
l1 = len(S) - l0

print(2 * min([l0, l1]))

Submission status: Accepted

Solution code:
S = list(input())
N = len(S)
print(N-abs(S.count('0')-S.count('1')))

Submission status: Accepted

Solution code:
S=input()
n0,n1=0,0
for s in S:
  if s=='0':
    n0+=1
  else:
    n1+=1
print(min(n0,n1)*2)

Submission status: Accepted

Solution code:
s = input()
n0 = s.count('0')
n1 = s.count('1')
ans = min(n0,n1) * 2
print(ans)

Submission status: Accepted

Solution code:
def readinput():
    s=list(input())
    return s

def main(s):
    n=len(s)
    count=0
    for i in range(n):
        if s[i]=='1':
            count+=1
    return min(count,n-count)*2

if __name__=='__main__':
    s=readinput()
    ans=main(s)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())

ans = min(S.count("1"), S.count("0"))

print(ans*2)

Submission status: Accepted

Solution code:
ss = input()
zero = 0
one = 0
for s in ss:
    if s == "0":
        zero += 1
    elif s == "1":
        one += 1
print(2 * min(zero, one))

Submission status: Accepted

Solution code:
a = list(input())

n = a.count("0")
m = a.count("1")

print(min(n, m) * 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
n=len(s)
r=0
b=0
for i in s:
    if i=="1":
        r+=1
    else:
        b+=1
print(min(r,b)*2)

Submission status: Accepted

Solution code:
s=input()
a=0
b=0
for i in range(len(s)):
  if s[i]=="1":
    a+=1
  else:
    b+=1
print(min(a,b)*2)

Submission status: Accepted

Solution code:
S = input()
ans = 0
i = 0
while i < len(S)-1:
    if S[i] != S[i+1]:
        ans += 2
        if i==0:
            S = S[2:]
        else:
            S = S[:i] + S[i+2:]
            i -= 1
    else:
        i += 1
print(ans)

Submission status: Accepted

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

Solution code:
"""
int(input())
map(int, input().split())
list(map(int, input().split()))
input()
input().split()
"""

s = input()
s2 = []
s2.append(s[0])
ans = 0
for i in range(1,len(s)):
    if len(s2) != 0:
        if (s[i] != s2[-1]):
            s2.pop()
            ans += 2
        else:
            s2.append(s[i])
    else:
        s2.append(s[i])
print(ans)

Submission status: Accepted

Solution code:
S=input()
a=S.count("1")
b=S.count("0")
print(min(a,b)*2)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7


s = collections.Counter(rr())
print(min(s['0'], s['1']) * 2)

Submission status: Accepted

Solution code:
def resolve():
    s = input()
    num_0 = s.count("0")
    num_1 = s.count("1")
    print(min(num_0, num_1)*2)
resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
x = s.count("0")
print(2 * min(x, len(s) - x))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

print(min(s.count("0"),s.count("1"))*2)

Submission status: Accepted

Solution code:
S=sorted(input())
import bisect

i=bisect.bisect_right(S,'0')
o=len(S)-i
z=i
print(len(S)-abs(o-z))

Submission status: Accepted

Solution code:
s=[int(x) for x in list(input())]
x=s.count(0)
print(min(x,len(s)-x)*2)

Submission status: Accepted

Solution code:
S = input().strip()
z = 0
o = 0
r = 0
for s in S:
    if s == "0":
        if o > 0:
            o -= 1
            r += 2
        else:
            z += 1
    elif s == "1":
        if z > 0:
            z -= 1
            r += 2
        else:
            o += 1
print(r)

Submission status: Accepted

Solution code:
S = list(input())

zero = S.count("0")
one = S.count("1")

print(min(zero, one) * 2)

Submission status: Accepted

Solution code:
S = input()
zero = S.count("0")
one = len(S) - zero

print(min(zero, one)*2)

Submission status: Accepted

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

def solve(S: str):
    from collections import Counter
    c = Counter(S)
    return 2 * min(c["0"], c["1"])

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print(solve(S))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Submission status: Accepted

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

def solve(S: str):
    stack = [-1]
    for c in map(int, S):
        if stack[-1] + c == 1:
            stack.pop()
            continue
        stack.append(c)
    return len(S)-len(stack)+1

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print(solve(S))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Submission status: Accepted

Solution code:
import sys
from collections import deque


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    S = list(map(int, list(input())))
    d_1 = deque(S[1:])
    d_2 = deque([S[0]])
    ans = 0
    for i in range(1, len(S)):
        if d_2:
            r = d_1.popleft()
            l = d_2.pop()
            if r != l:
                ans += 2
            else:
                d_2.append(l)
                d_2.append(r)
        else:
            d_2.append(d_1.popleft())
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()

s_0 = s.count("0")
s_2 = s.count("1")

print(min(s_0,s_2)*2)

Submission status: Accepted

Solution code:
s = input()
zero = 0
one = 0

for i in s:
    if i == "0":
        zero += 1
    else:
        one += 1
        
res = min(zero, one) * 2
print(res)

Submission status: Accepted

Solution code:
S = input()
cnt0 = S.count("0")
cnt1 = S.count("1")
ans = min(cnt0, cnt1) * 2
print(ans)

Submission status: Accepted

Solution code:
def solve():
  S = input()
  ans = min(S.count('0'),S.count('1'))*2
  return ans
print(solve())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

length = len(S)
total = 0
for i in list(S):
    total += int(i)

if (length - total) > total:
    answer = total * 2
else:
    answer = (length - total) * 2

print(answer)

Submission status: Accepted

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

print(min(red,blue)*2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
chara0 = S.count('0')
chara1 = S.count('1')
if chara0 < chara1:
    print(chara0 * 2)
else:
    print(chara1 * 2)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
stack = []
for i in s:
    if stack and stack[-1] != i:
        stack.pop()
    else:
        stack.append(i)
print(n - len(stack))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
n = len(s)
m = 0
for x in s:
  m += int(x)
print(n-abs(n-2*m))

Submission status: Accepted

Solution code:
S = list(map(int,input()))
red = S.count(0)
blue = S.count(1)
print(min(red,blue)*2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
a = 0; b = 0
for i in range(len(s)):
    if s[i] == "0":
        a += 1 
    else:
        b += 1
print(min(a, b)*2)

Submission status: Accepted

Solution code:
S = list(input())

i = 0
count = 0
while i < len(S)-1:
  if S[i] != S[i+1]:
    del S[i:i+2]
    count += 2
    if i != 0:
      i -= 1
  else:
    i += 1
print(count)

Submission status: Accepted

Solution code:
s = input()

c0 = s.count("0")
c1 = s.count("1")

print(min([c0*2,c1*2]))

Submission status: Accepted

Solution code:
from collections import deque
S = input()
stack = deque([])
c = 0
for s in S:
  if len(stack)==0:
    stack.append(s)
  elif stack[-1]==s:
    stack.append(s)
  else:
    stack.pop()
    c += 2
print(c)

Submission status: Accepted

Solution code:
S=list(map(int,list(input())))
print(2*min(sum(S),len(S)-sum(S)))

Submission status: Accepted

Solution code:
s = input()
n = len(s)
a, b = 0, 0
for i in s:
  if i == '1':
    a+=1
b = n-a

print(min(a,b)*2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=list(map(int, list(input())))

num1 = sum(S)
num0 = len(S) - num1

print(min(num1,num0)*2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
s = list(input())
s = Counter(s)
print(min(s['0'], s['1']) * 2)

Submission status: Accepted

Solution code:
def main():
    s = input()
    kazu = len(s)
    onelen = 0
    zerolen = 0
    
    for i in range(kazu):
        if s[i] == "1":
            onelen += 1
        else:
            zerolen += 1
    
    print(min(onelen, zerolen) * 2)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s=list(input())
n=len(s)
a=s.count('1')
b=n-a
c=abs(a-b)
print(n-c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
zero,one=0,0
for i in range(len(s)):
  if s[i]=="0":
    zero+=1
  else:
    one+=1
print(min(zero,one)*2)

Submission status: Accepted

Solution code:
def resolve():
    s = input()
    cnt_zero = s.count('0')
    cnt_one = s.count('1')

    print(min(cnt_one, cnt_zero) * 2)
    
resolve()

Submission status: Accepted

Solution code:
S = input()
from collections import deque
q = deque()
ans = 0
for s in S:
    if not q:
        q.append(s)
        continue
    pres = q.pop()
    if (s == '0' and pres == '1') or (s=='1' and pres=='0'):
        ans += 2
    else:
        q.append(pres)
        q.append(s)
print(ans)

Submission status: Accepted

Solution code:
S = input()
stack = []
for s in S:
    if not stack:
        stack.append(s)
    else:
        if s == stack[-1]:
            stack.append(s)
        else:
            stack.pop()
print(len(S)-len(stack))

Submission status: Accepted

Solution code:
S = input()
a = S.count("1")
b = S.count("0")
print(2 * min(a,b))

Submission status: Accepted

Solution code:
import collections
s = list(input())
c = collections.Counter(s)
print(min(c["0"], c["1"])*2)

Submission status: Accepted

Solution code:
s = input()

cnt_0 = 0
cnt_1 = 0

for i in range(len(s)):
    if s[i] == "0":
        cnt_0 += 1
    else:
        cnt_1 += 1

print(2*min(cnt_0, cnt_1))

Submission status: Accepted

Solution code:
#計算でもとまるのか・・・
# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない
#*S, = input() 
S =input().strip()
c1 =S.count("1")
c0 =S.count("0")
print(min(c0,c1)*2)

Submission status: Accepted

Solution code:
c = list(input())
c0 = c.count("0")
c1 = c.count("1")
print(min(c0, c1) * 2)

Submission status: Accepted

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

s = input()
count0 = s.count("0")
count1 = s.count("1")

print(2 * min(count0, count1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input().strip()
cnt0 = 0
cnt1 = 0
for i in range(len(S)):
    if S[i]=="0":
        cnt0 += 1
    else:
        cnt1 += 1
print(min(cnt0,cnt1)*2)

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
s = input()
one = s.count('1')
zero = s.count('0')
print(one * 2 if one < zero else zero*2)

Submission status: Accepted

Solution code:
s = list(input())
red = s.count("0")
blue = len(s) - red

print(min(red, blue)*2)

Submission status: Accepted

Solution code:
s = input()

zero = 0
one = 0

for c in s:
    if c == '1':
        one +=1
    else :
        zero +=1

print(min(one,zero)*2)

Submission status: Accepted

Solution code:
s = input()

c0 = s.count("0")
c1 = s.count("1")
print(2 * min(c0, c1))

Submission status: Accepted

Solution code:
s=input()
n=len(s)
t=0
for i in range(n):
    if s[i]=="1":
        t+=1
print(min(2*t,2*(n-t)))

Submission status: Accepted

Solution code:
S=input()
one=S.count("1")
zero=S.count("0")
ans=min(one,zero)*2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
c0 = 0
c1 = 0
for s in S:
    if s == "0":
        c0 += 1
    else:
        c1 += 1

print(2*min(c0, c1))

Submission status: Accepted

Solution code:
s = input()
count1 = s.count("1")
count0 = s.count("0")
if count0 == count1 :
    print(len(s))
else :
    print(min(count1, count0)*2)

Submission status: Accepted

Solution code:
s = input()

ans = min(s.count("0"), s.count("1"))*2
print(ans)

Submission status: Accepted

Solution code:
S = input()

ones = S.count('1')
zeros = S.count('0')
print(min(ones, zeros) * 2)

Submission status: Accepted

Solution code:
S = input()
c = S.count("0")
l = len(S)
print(l-abs(c-(l-c)))

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    s = list(input())
    print(min(s.count('0'), s.count('1')) * 2)
        
if __name__ == '__main__':
    main()

Submission status: Accepted

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

if s.count("1") >= s.count("0"):
  print(2*s.count("0"))
elif s.count("1") < s.count("0"):
  print(2*s.count("1"))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
red = s.count("0")
blue = s.count("1")
num = min(red,blue)
print(num*2)

Submission status: Accepted

Solution code:
s=input()
t=s.count('0')
u=s.count('1')
ans=min(t,u)

print(2*ans)

Submission status: Accepted

Solution code:
import sys

def input():
    return sys.stdin.readline().rstrip()


def main():
    S =input()
    N = len(S)
    one = S.count("1")
    zero = N-one
    print(min(zero,one)*2)



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import math
import heapq


def input():
    return sys.stdin.readline().rstrip()


def main():
    S =input()
    N = len(S)
    one = S.count("1")
    zero = N-one
    print(min(zero,one)*2)



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

s = input()

o = 0
z = 0
ans = 0
for i in range(len(s) - 1):
    if s[i] == '0':
        o += 1
    else:
        z += 1
    if s[i] != s[i + 1]:
        mi = min(o, z)
        ans += mi * 2
        o -= mi
        z -= mi

print(ans)

Submission status: Accepted

Solution code:
S = input()
r = S.count("0")
b = S.count("1")
print(min(r, b) *2)

Submission status: Accepted

Solution code:
s=input()
s=[i for i in s]
ans=min(s.count('0'),s.count('1'))
print(2*ans)

Submission status: Accepted

Solution code:
s = input()

ans = 0
ind = 0
while ind < len(s)-1:
    if s[ind:ind+2] in ("01", "10"):
        s = s[:ind]+s[ind+2:]
        ans += 1
        ind = max(0, ind-1)

    else:
        ind += 1
print(ans*2)

Submission status: Accepted

Solution code:
S = input()
cnt = 0
_cnt = 0
for s in S:
    if s == '0':
        cnt += 1
    else:
        _cnt += 1
print(min(cnt, _cnt) * 2)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
print(2*min(s.count('1'),s.count('0')))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
n = len(s)
c = 0
p = ""
count = 0
for i in s:
    if i == p:
        count += 1
    else:
        c = count - c
        count = 1
    p = i
c = count - c
print(n - abs(c))

Submission status: Accepted

Solution code:
S = input()
r = S.count('0')
b = S.count('1')

print(min(r,b) * 2)

Submission status: Accepted

Solution code:
s = input()
r = 0
b = 0

for i in range(len(s)):
  if s[i] == '0':
    r += 1
  else:
    b += 1
if r > b:
  print(b*2)
else:
  print(r*2)

Submission status: Accepted

Solution code:
from collections import Counter
S = input()
C = Counter(S)
print(min(C['0'], C['1'])*2)

Submission status: Accepted

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

print(2 * min(s.count(1), s.count(0)))

Submission status: Accepted

Solution code:
import collections
s = input()
c0 = s.count('0')
c1 = len(s) - c0
print(min(c0,c1)*2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
n=len(s)

num0=s.count("0")
num1=s.count("1")
min=min([num0,num1])

print(min*2)

Submission status: Accepted

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

S = input().rstrip('\n')
N = len(S)

print(2*min(S.count('0'), S.count('1')))

# for i in itertools.count():
#     # print(S)
#     S = S.replace('01', '').replace('10', '')
#     if not S:
#         break
#     if S.count('0') == 0 or S.count('1') == 0:
#         break

# print(N-len(S))

Submission status: Accepted

Solution code:
S=input()

R=0
B=0
for s in S:
    if s=="0":
        R+=1
    else:
        B+=1

print(2*min(R,B))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
zero = 0
one = 0
for i in s:
  if i == '0':
    zero += 1
  else:
    one += 1

print(min(zero, one)*2)

Submission status: Accepted

Solution code:
S = input()
n = 0
i = 0
while i < len(S):
    # print(S)
    if len(set(S[i:i+2])) == 2:
        S = S[:i]+S[i+2:]
        n += 2
        if i != 0:
            i -= 1
    else:
        i += 1
print(n)

Submission status: Accepted

Solution code:
S=input()

# S='11011010001011'

ans=min(S.count('0'),S.count('1'))*2

print(ans)

Submission status: Accepted

Solution code:
s = list(input())

zero = s.count("0")
one = s.count("1")
print(min(zero,one)*2)

Submission status: Accepted

Solution code:
s = input()
n = len(s)

a, b = 0, 0
for i in range(n):
    if s[i] == '0':
        a += 1
    else:
        b += 1
print(min(a, b)*2)

Submission status: Accepted

Solution code:
s = input()
cnt0 = 0
cnt1 = 0
for c in s:
    if c == '0':
        cnt0 += 1
    else:
        cnt1 += 1

print(min(cnt0,cnt1)*2)

Submission status: Accepted

Solution code:
S = input()
bl = 0
re = 0
for i in S:
  if i == "0":
    re += 1
  else:
    bl += 1
print(min(bl,re)*2)

Submission status: Accepted

Solution code:

S = input()
N = len(S)
cnt0 = S.count("0")
cnt1 = S.count("1")
ans = 2*min(cnt0, cnt1)
print(ans)

Submission status: Accepted

Solution code:
S = input()

zero_count = int(S.count('0'))
one_count = int(S.count('1'))

print(min(zero_count, one_count)*2)

Submission status: Accepted

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

Submission status: Accepted

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

    print(ans)
    return
resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
cnt1 = 0
cnt2 = 0
for i in range(len(s)):
    if s[i] == '0':
        cnt1 += 1
    else:
        cnt2 += 1
print(min(cnt1, cnt2)*2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

S = list(input())

count = Counter(S)
n = min(count['0'], count['1'])
print(n * 2)

Submission status: Accepted

Solution code:
s = input()
cnt_1 = 0

for i in s:
    if i == '1':
        cnt_1 += 1
        
print(min(cnt_1, len(s) - cnt_1) * 2)

Submission status: Accepted

Solution code:
S = input()

count_0 = 0
count_1 = 0
for s in S:
    if s == "0":
        count_0 += 1
    else:
        count_1 += 1
        
print(2 * min(count_0, count_1))

Submission status: Accepted

Solution code:
s=input()

a=s.count('0')
b=s.count('1')

if a>=b:
    print(b*2)

else:
    print(a*2)

Submission status: Accepted

Solution code:
s = input()
stack = []

count = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())

a = 0
b = 0

for i in S:
  if i =='0':
    a+=1
  else:
    b+=1

    
print(2*min(a,b))

Submission status: Accepted

Solution code:
import collections
S = input()
col_S = collections.Counter(S) 
print(min(col_S['0'],col_S['1'])*2)

Submission status: Accepted

Solution code:
s = input()

if len(s)>0:
    print(min(s.count("0"),s.count("1"))*2)

Submission status: Accepted

Solution code:
s = list(input())
one  = s.count("1")
zero = s.count("0")
if(one == 0 or zero == 0):
    print("0")
else:
    if (one > zero):
        print(zero * 2)
    else:
        print(one * 2)

Submission status: Accepted

Solution code:
S=input()

ans = min(S.count('0'), S.count('1'))

print(ans*2)

Submission status: Accepted

Solution code:
s = input()

stack = [s[0]]
ans = 0
for i in range(1, len(s)):
    if len(stack) == 0:
        stack.append(s[i])
        continue
    if s[i] == "0":
        if stack[-1] == "1":
            del stack[-1]
            ans += 2
        else:
            stack.append("0")
    else:
        if stack[-1] == "0":
            del stack[-1]
            ans += 2
        else:
            stack.append("1")

print(ans)

Submission status: Accepted

Solution code:
s = input()
cnt_1 = s.count("1")
cnt_0 = s.count("0")

print(2 * min(cnt_1, cnt_0))

Submission status: Accepted

Solution code:
S = input()

C0 = S.count("0")
C1 = S.count("1")

ans = 2 * min(C0, C1)
print(ans)