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()
X=len(S)
A=S.replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","")
B=A.replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","")
C=B.replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","")
if X==1:
  print(0)
else:
  print(X-len(C))

Submission status: Wrong Answer

Solution code:
S=input()
X=len(S)
A=S.replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","")
if X==1:
  print(0)
else:
  print(X-len(A))

Submission status: Wrong Answer

Solution code:
S = input()
n = 0
stack = 0
for s in S:
    if s == S[0]:
        stack += 1
    else:
        if stack > 0:
            n += 2
            stack -= 1
print(n)

Submission status: Wrong Answer

Solution code:
import re
S = input()
ans = 0

while True:
    num0 = S.count('11')
    S = re.sub('11', '', S)
    num1 = S.count('00')
    S = re.sub('00', '', S)
    ans += 2*(num0+num1)
    if num0+num1 == 0:
        print(ans)
        break

Submission status: Wrong Answer

Solution code:
def resolve():
    S = str(input())
    ans = 0

    while True:
        tmp1 = S.count('01')
        ans += tmp1 * 2
        S = S.replace('01', '')

        tmp2 = S.count('10')
        ans += tmp2*2
        S = S.replace('10', '')

        if tmp1 == 0 and tmp2 == 0:
            break

    print(ans)
    return

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
from collections import deque

d=deque(list(input().rstrip()))
d.append("2")
ans=0
r=0

while r<len(d):
    if len(d)<2:
        break
    if d[0]!=d[1] and d[0]!=2 and d[1]!=2:
        d.popleft()
        d.popleft()
        ans+=2
        r=0
    else:
        d.rotate(-1)
        r+=1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
s=input()
ans=0
num=0
while num<len(s)-1:
    if s[num]!=s[num+1]:
        s=s[:num]+s[num+2:]
        num-=1
        ans+=2
    else:
        num+=1
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

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

Submission status: Wrong Answer

Solution code:
from  collections import Counter

s = list(input())
count = Counter(s)

print(min(count.values())*2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]

s = S()
ans = [0]
ss = 1
n = len(s)
for i in range(1,n):
    if s[i] != s[i-1]:
        if ss % 2 != 0:
            ans.append(ss)
            ss = 1
        else:
            ss = ans[-1] + 1

    else:
        ss += 1
if ss % 2 == 0:
    print(n-len(ans)+1)
else:
    print(n-len(ans))

Submission status: Wrong Answer

Solution code:
import collections
i,j = 0,0 
s = raw_input()
q = collections.deque([])
while(j < len(s)):
	while(j < len(s) and s[j] == s[i]): j+=1
	q.append(j - i )
	i = j

ns = len(s)
while(len(q) > 1):
	u,v = q.popleft(), q.popleft()
	if q:  q[0] += abs(u-v)
print ns - (q[0] if q else 0)

Submission status: Wrong Answer

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


s = input()
n = len(s)
prev = s[0]
ans = 0
l = s
while l:
    update = False
    l = []
    for i in range(1,len(s)):
        if s[i]!=prev:
            prev = None
            ans += 2
            update = True
        elif prev is not None:
            l.append(prev)
        else:
            prev = s[i]
    s = "".join(l)
    if not update:
        break
        
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


s = input()
n = len(s)
prev = s[0]
ans = 0
l = s
while l:
    update = False
    l = []
    for i in range(1,len(s)):
        if s[i]==prev:
            prev = None
            ans += 2
            update = True
        elif prev is not None:
            l.append(prev)
        else:
            prev = s[i]
    s = "".join(l)
    if not update:
        break
        
print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
ss="" #新文字列
ss2="a" #一巡前文字列
c=0 #カウント
while ss!=ss2: #一巡前と同じなら抜ける
  for i in range(len(s)):
    if i==0:
      ss=s[0] #一文字目は確定
      a=s[0]
    elif s[i]!=a:
      ss=ss[:len(ss)-1] #一文字減らす
      c+=2
      #a=s[i-1] #逆になるはず
      a=str(abs(1-int(s[i])))
    else:
      ss+=s[i]
      a=s[i]
    
  ss2=s
  s=ss
print(c)

Submission status: Wrong Answer

Solution code:
s=input()
c=0
k=1
while(k!=0):
    b=s.replace('10','')
    c+=len(s)-len(b)
    s=b
    b=s.replace('01','')
    c+=len(s)-len(b)
    k=len(s)-len(b)
    s=b
print(c)

Submission status: Wrong Answer

Solution code:
from collections import Counter


def main():
    s = list(input())
    Count = Counter(s)
    if "0" not in s or "1" not in s:
        ans = 0
        exit()
    min_key = min(Count, key=Count.get)
    ans = Count[min_key] * 2
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
S = list(input())

left = [S.pop(0)]
ans = 0
if not S:
    print(ans)

i = 0
while i < len(S):
    if not left:
        left.append(S[i])
        i += 1
    else:
        if left[-1] + S[i] in ['01', '10']:
            left.pop()
            ans += 1
            i += 1
        else:
            left.append(S[i])
            i += 1
print(2*ans)

Submission status: Wrong Answer

Solution code:
ans=0

def br(s):
  global ans
  ns=[]
  fl=True
  i=0
  while i <len(s)-1:
    if s[i:i+2]==["0","1"] or s[i:i+2]==["1","0"]:
      ans+=2
      i+=1
      fl=False
    else:
      ns.append(s[i])
    i+=1
  if fl or len(ns)==0:
    return 0
  else:
    br(ns)

br(list(input()))
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
#11011010001011
c = max(s.count("1") - s.count("0"),s.count("1") - s.count("0"))

if len(s) == 1:
	print(0)
else:
	print(len(s)-c)

Submission status: Wrong Answer

Solution code:
s=list(map(int,list(input())))
from collections import Counter
cs=Counter(s)
print(min(cs.values())*2)

Submission status: Wrong Answer

Solution code:
s = input()
one = s.count("1")
zero = s.count("0")

print(min(zero,one))

Submission status: Wrong Answer

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

class Cube:
    def __init__(self, color):
        self.color = color
        self.left = None
        self.right = None

class CubeList:
    def __init__(self):
        self.head = Cube(None)
        self.tail = Cube(None)
        self.head.right = self.tail
        self.tail.left = self.head

    def append(self, cube):
        cube.left = self.tail.left
        self.tail.left.right = cube
        cube.right = self.tail
        self.tail.left = cube

    def size(self):
        s = 0
        it = self.iter()
        while it.has_next():
            it.next()
            s += 1
        return s

    def __str__(self):
        colors = []
        it = self.iter()
        while it.has_next():
            colors.append(it.next().color)
        return '->'.join(colors)

    def iter(self):
        return self.Iter(self)

    class Iter:
        def __init__(self, cube_list):
            self.cube_list = cube_list
            self.cur = cube_list.head

        def has_next(self):
            return self.cur.right != self.cube_list.tail

        def next(self):
            self.cur = self.cur.right
            return self.cur

        def back(self):
            assert not self.is_head()
            self.cur = self.cur.left

        def is_head(self):
            return self.cur == self.cube_list.head

        def remove(self):
            assert self.cur != self.cube_list.head
            assert self.cur != self.cube_list.tail
            self.cur = self.cur.left
            self.cur.right = self.cur.right.right
            self.cur.right.left = self.cur

def solve(S: str):
    cubes = CubeList()
    for c in S:
        cubes.append(Cube(c))
    for _ in range(100):
        ci = cubes.iter()        
        while ci.has_next():
            l = ci.next()
            if not ci.has_next():
                break
            r = ci.next()
            if l.color == r.color:
                ci.back()
                continue
            ci.remove()
            ci.remove()
    return len(S) - cubes.size()
    

# 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: Wrong Answer

Solution code:
#C
s = list(input())
zero = 0
one = 0
for i in s:
    if i == "1":
        one += 1
    else:
        zero += 1
print(min(one,zero))

Submission status: Wrong Answer

Solution code:
from collections import Counter
s = input().rstrip()
ctr = Counter(s)
if len(ctr) > 2:
    x = min(ctr.values())
else:
    x = 0
print(x * 2)

Submission status: Wrong Answer

Solution code:
S=input()
z=0
o=0
for i in range(len(S)):
    if S[i]==0:
        z+=1
    elif S[i]==1:
        o+=1
print(2*min(z,o))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# check
cnt = 0
del_ind = []
append = del_ind.append

for i in range(0, N):
    if "".join(S[i:i + 2]) in ["01", "10"]:
        cnt += 2
        N -= 2
        del S[i:i + 2]
print(cnt)

Submission status: Wrong Answer

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

# check
cnt = 0
del_ind = []
append = del_ind.append

for i in range(1, N):
    if "".join(S[i - 1:i + 1]) in ["01", "10"]:
        cnt += 2
        N -= 2
        del S[i - 1:i + 1]
print(cnt)

Submission status: Wrong Answer

Solution code:
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

s=S()
ans=0
ss=""
ind=0
remove=False
loop=True
#print(s)
while loop:
    ind_max=len(s)-1
    if(ind>=ind_max):
        s=ss
        #print()
        #print(s)
        ss=""
        ind=0
        ind_max=len(s)-1
        if not remove:
            loop=False
        remove=False
        continue
    if s[ind]!=s[ind+1]:
        #print("↑↑",end="")
        ans+=2
        ind+=1
        remove=True
    else:
        #print(" ",end="")
        ss+=s[ind]
        if ind==ind_max:
            ss+=s[ind+1]
    ind+=1
print(ans)

Submission status: Wrong Answer

Solution code:
S = list(input())
S = [int(s) for s in S]
N = len(S)
print('S:', S)

count=0
i=1
while True:
    print(S,i)
    if len(S)==0 or len(S)==1 or sum(S)==len(S) or sum(S)==0 :
        break

    elif S[i-1] != S[i]:
        del S[i-1]
        del S[i-1]
        count+=1
        i=1
    else:
        i+=1

print(count*2)

Submission status: Wrong Answer

Solution code:
s=input()
l=[]
for ss in s:
  l.append(ss)
n=len(s)
cnt=0
i=0
while cnt<=n and i<=len(l)-2:
  if l[i]=='0' and l[i+1]=='1':
    if i<0:
      i=0
    cnt+=2
    del l[i:i+2]
    i=i-1
  elif l[i]=='1' and l[i+1]=='0':
    if i<0:
      i=0
    cnt+=2
    del l[i:i+2]
    i=i-1
  else:
    i+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
import collections

l=list(input())
c=collections.Counter(l)
print(c['0'],c['1'])
if c['0']==c['1']:
    print(c['0']*2)
else:
    print(min(c['0'],c['1'])*2)

Submission status: Wrong Answer

Solution code:
def main():
  s = input()
  
  answer = 0
  
  while ("0" in s) and ("1" in s):
    answer += s.count("10")
    s = s.replace("10", "")
    answer += s.count("01")
    s = s.replace("01", "")
  
  print(answer)


if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
def main():
  s = input()
  
  answer = 0
  
  while (not "0" in s) or (not "1" in s):
    answer += s.count("10")
    s.replace("10", "")
    answer += s.count("01")
    s.replace("01", "")
  
  print(answer)


if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
from collections import Counter
s = list(input())
cnt = Counter(s)
cnt = list(cnt.values())
print(min(cnt) * 2)

Submission status: Wrong Answer

Solution code:
S=input()
ans=0
r=b=0
for s in S:
    if s=='0':
        if b>0:
            b-=0
            ans+=2
        else:
            r+=1
    else:
        if r>0:
            r-=1
            ans+=2
        else:
            b+=1
print(ans)

Submission status: Wrong Answer

Solution code:
s=list(map(int,input()))
count=0
k=len(s)-2
i=0
while i<=k:
    if s[i]!=s[i+1]:
        s.remove(s[i])
        s.remove(s[i])
        k-=2
        count+=2
    else:
        i+=1
    
print(count)

Submission status: Wrong Answer

Solution code:
s=list(map(int,input()))
count=0
k=len(s)-2
i=0
while i<=k:
    if s[i]!=s[i+1]:
        s.remove(s[i])
        s.remove(s[i])
        k-=2
        count+=2
    else:
        i+=2
    
print(count)

Submission status: Wrong Answer

Solution code:
s=list(map(int,input()))
k=len(s)
count=0
flag=True
while flag==True:
    flag=False
    for i in range(k-1):
        if s[i]==0 and s[i+1] or s[i]==1 and s[i+1]==0:
            s[i]=-1
            s[i+1]=-1
            k-=2
            count+=2
            flag=True
        else:
            continue
    try:
        for j in s:
            s.remove(-1)
    except:
        pass
        
print(count)

Submission status: Wrong Answer

Solution code:
s = input()
cnt_0, cnt_1 = s.count('0'), s.count('1')
print(max(cnt_0, cnt_1) - min(cnt_0, cnt_1))

Submission status: Wrong Answer

Solution code:
s = input()

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

Submission status: Wrong Answer

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
S = input()

cnt = Counter(S)
low = min(cnt.values())
ans = low*2

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Wrong Answer

Solution code:
a=str(input())
ct=0
for i in range(10):
    ct+=a.count('10')
    a=a.replace("10", "").strip()
    ct+=a.count('01')
    a=a.replace("01", "").strip()
print(ct*2)

Submission status: Wrong Answer

Solution code:
from collections import Counter
print(2*min(Counter(list(input())).values()))

Submission status: Wrong Answer

Solution code:
import collections

S = input()
c = collections.Counter(S)
c.values()
print(2 * min(c.values()))

Submission status: Wrong Answer

Solution code:
import re
a = input()
operations = 0
length_a = len(a)
if not re.search("01", a) and not re.search("01", a):
    print(0)
else:
    while re.search("01", a) or re.search("10", a):
        a = a.replace("01", "", 1)
        operations += 2 if length_a - len(a) == 2 else 0
        length_a = len(a)
        a = a.replace("10", "", 1)
        operations += 2 if length_a - len(a) == 2 else 0
        length_a = len(a)
    print(operations)

Submission status: Wrong Answer

Solution code:
import re
a = input()
operations = 0
length_a = len(a)
if not re.search("01", a) and not re.search("01", a):
    print(0)
else:
    while re.search("01", a) or re.search("10", a):
        if re.search("01", a):
            a = a.replace("01", "", 1)
            operations += 2
        if re.search("10", a):
            a = a.replace("10", "", 1)
            operations += 2
    print(operations)

Submission status: Wrong Answer

Solution code:
Str = input()
Codigo = []
i=0
LenAnterior = 0
contador=0
for a in Str:
    Codigo.append(a)
lenAtual=len(Codigo)-1

while i < lenAtual:
    try:
        lenAnterior = len(Codigo)-1
    
        if Codigo[i] == "0" and Codigo[i+1]=="1":
            contador+=2
            Codigo.pop(i)
            Codigo.pop(i)
        elif Codigo[i] == "1" and Codigo[i+1]=="0":
            contador+=2
            Codigo.pop(i)
            Codigo.pop(i)
        
        if lenAnterior != len(Codigo)-1:
            i=i-1
        else:
            i=i+1
    except:
        break
print(contador)

Submission status: Wrong Answer

Solution code:
num = input()
predicted_value = 0
finished = False
i = 1
while i < len(num):
    if num[i] != num[i-1]:
        num = num[:i-1] + num[i+1:]
        predicted_value += 2
        if i > 1:
            i -= 2
    i += 1
print(predicted_value)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = list(input())

skip = 0
count = 0
no_count = 1
k = 0
s = []
N = len(S)
while k < 1:
  no_count = 1
  for i in range(len(S)-1):
    #print([S[i], S[i+1]])
    if skip == 0:
      if S[i] != S[i+1]:
        count += 1
        skip = 1
        no_count = 0
      else:
        s.append(S[i])
        if i == len(S) - 2:
          s.append(S[-1])
    else:
      skip = 0
      if i == len(S) - 2:
        s.append(S[-1])
  else:
    #print(s)
    if no_count == 1:
      print(count * 2)
      break
    else:
      S = s[:]
      s = []

Submission status: Wrong Answer

Solution code:
S=list(input())
s=0 #取り除いたキューブの数
i=0 
while len(set(S))!=len(S):
  if S[i]==S[i+1]==0 or S[i]==S[i+1]==1:
    s=s
    i+=1
  else:
    s+=2
    del S[i:i+2]
    i=0
print(s)

Submission status: Wrong Answer

Solution code:
s=input()
from itertools import groupby as gb
l=[len(list(b)) for a,b in gb(list(s))]
pre=0
ans=0
c=[0,0]
px,py=0,0
for x,y in zip(l[::2],l[1::2]):
    x+=px
    if py:
        k=min(x,py);x-=k;py-=k;ans+=k
        if x==0:py+=y;continue
    k=min(x,y);ans+=k;px+=(x-k);py+=(y-k)
print(2*ans+2*min(px,py))