TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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?

Submission attempts (in order):
s = input()
q = []
l = 0
o = 0
for c in s:
    q.append(c)
    l += 1
    while 2 < l and q[l-1] == q[l-2]:
        q.pop()
        q.pop()
        o += 2
        l -= 2
print(o)


s = input()
q = []
l = 0
o = 0
for c in s:
    q.append(c)
    l += 1
    while 1 < l and q[l-1] != q[l-2]:
        q.pop()
        q.pop()
        o += 2
        l -= 2
print(o)


Verdicts: Wrong Answer

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

Submission attempts (in order):
S = input()
subS = S
cnt = 0
while True:
    flg = True
    if "01" in subS:
        flg = False
        tmp = subS.replace("01", "")
        cnt += len(subS) - len(tmp)
        subS = tmp
    if "10" in subS:
        flg = False
        tmp = subS.replace("10", "")
        cnt += len(subS) - len(tmp)
        subS = tmp
    if flg:
        break

S = input()

zeroSum = 0
oneSum = 0
for _ in S:
  if _ == "0":
    zeroSum += 1
  if _ == "1":
    oneSum += 1

t = max(zeroSum, oneSum) - min(zeroSum, oneSum)
print(len(S) - t)

Verdicts: Wrong Answer

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

Submission attempts (in order):
t = input()

z = 0
o = 0
count = 0
for c in t:
    if c == '0':
        if o > 0:
            o -= 1
            count += 2
        else:
            z += 1
    else:
        if z > 0:
            z -= 1
            count += 1
        else:
            o += 2
print(count)

t = input()

count = 0
t2 = ""
for c in t:
    t2 += c
    while t2.endswith("01") or t2.endswith("10"):
        t2 = t2[:-2]
        count += 2
print(count)

Verdicts: Wrong Answer

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

Submission attempts (in order):
try:
  print(Counter(input()).most_common()[1][1] * 2)
except:
  print(0)

from collections import Counter
try:
  print(Counter(input()).most_common()[1][1] * 2)
except:
  print(0)

Verdicts: Wrong Answer

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

Submission attempts (in order):
import sys
input = sys.stdin.readline

s = list(input().replace("¥n", ""))
l = {
    "0": 0,
    "1": 0
}

for v in s:
    l[v] += 1
        
print(min(l["0"], l["1"]) * 2)

import sys
input = sys.stdin.readline

s = list(input())
l = {
    "0": 0,
    "1": 0,
}

for v in s:
    if l.get(v):
        l[v] += 1
    else:
        l[v] = 1
        
print(min(l["0"], l["1"]) * 2)

Verdicts: Runtime Error

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

Submission attempts (in order):
s = input()
ls = list(int(s))

ans = 0
lf = [1]*n
while '01' in s or '10' in s:
  for i in range(len(ls)):
    if sum(ls[i:i+2]) == 1:
      lf[i] = 0
      lf[i+1] = 0
      ans += 1
  ls,lf = *[s,f for s,f in zip(ls,lf) if lf[i]>0]
print(ans)

s = input()
ls = list(map(int,list(s)))
lt = [0]
for i in range(1,len(s)):
  lt.append(ls[i-1]+ls[i])

ans = 0
while 1 in lt:
  flg = 1
  n = len(ls)
  for i in range(1,n):
    if flg == 1 and lt[n-i] == 1:
      ls = ls[:n-i-2] + ls[n-i:]
      ans += 2
      flg = 0
    elif flg == 0:
      flg = 1
  lt = [0]
  for i in range(1,len(ls)):
    lt.append(ls[i-1]+ls[i])
print(ans)

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

Verdicts: Runtime Error

Wrong Answer

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

Submission attempts (in order):
S=list(input())
s=0
i=0
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)

S=list(input())
N=len(S)
ans=0
i=0
while len(S)>0:
  if S[i]==0 and S[i+1]==1 or S[i]==1 and S[i+1]==0:
    S.remove(S[i:i+2])
    ans+=1
  else:
    ans=ans
    i+=1
print(ans)

S=list(int(input()))
s=0
i=0
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)

S=list(input())
N=len(S)
def main():
  ans=0
  i=0
  while len(S)>0 :
    if (S[i]==0 and S[i+1]==1) or (S[i]==1 and S[i+1]==0):
      S.remove(S[i:i+2])
      ans+=1
    else:
      ans=ans
      i+=1
  print(ans)
main()

S=list(int(input()))
s=0
i=0
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)

S=list(input())
N=len(S)
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
    i=0
print(s)
    


S=list(input())
N=len(S)
def main():
  ans=0
  i=0
  while len(S)>0 and i<N-1:
    if (S[i]==0 and S[i+1]==1) or (S[i]==1 and S[i+1]==0):
      S.remove(S[i:i+2])
      ans+=1
    else:
      ans=ans
      i+=1
  print(ans)
main()

S=list(input())
N=len(S)
def main():
  ans=0
  i=0
  while len(S)>0 and i<N-1:
    if (S[i]==0 and S[i+1]==1) or (S[i]==1 and S[i+1]==0):
      S.remove(S[i:i+2])
      ans+=1
      i=0
    else:
      ans=ans
      i+=1
  print(ans)
main()

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)

S=list(input())
N=len(S)
def main():
  ans=0
  i=0
  while len(S)>0 and i<N-1:
    if (S[i]==0 and S[i+1]==1) or (S[i]==1 and S[i+1]==0):
      S=S.remove(S[i:i+2])
      ans+=1
      i=0
    else:
      ans=ans
      i+=1
  print(ans)
main()

i

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):
class Solver:

    def __init__(self):
        pass


    def solve(self, s):
        one = 0
        zero = 0
        for ch in s:
            if ch == '1':
                one += 1
            else:
                zero += 1
        return abs(one-zero)


if __name__ == '__main__':

    solver = Solver()
    s = input()
    n = solver.solve(s)
    print(n)


class Solver:

    def __init__(self):
        pass


    def solve(self, s):
        one = 0
        zero = 0
        for ch in s:
            if ch == '1':
                one += 1
            else:
                zero += 1
        return len(s) - abs(one-zero)


if __name__ == '__main__':

    solver = Solver()
    s = input()
    n = solver.solve(s)
    print(n)


Verdicts: Wrong Answer

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

Submission attempts (in order):
s = input()
ans = 0
flg = 0
while '10' in s and '01' in s:
    ans += s.count('01') * 2
    s = s.replace('01', '')
    ans += s.count('10') * 2
    s = s.replace('10', '')
print(ans)

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
S = input()
ans = min(S.count("0"), S.count("1"))
print(ans)

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
# # coding: utf-8
# data = list(input())
# removed_block = 0


# while i < (len(data) + 1):
#     try:

#             data.pop(i)
#             data.pop(i - 1)
#             removed_block += 2


#         else:

#     except:
#         break
# print(removed_block)

# coding: utf-8
n = input()
print(min(n.count('0'), n.count('1')))


# # coding: utf-8
# data = list(input())
# removed_block = 0


# while i < (len(data) + 1):
#     try:

#             data.pop(i)
#             data.pop(i - 1)
#             removed_block += 2


#         else:

#     except:
#         break
# print(removed_block)

# coding: utf-8
n = input()
print(min(n.count('0'), n.count('1')) * 2)


Verdicts: Wrong Answer

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

Submission attempts (in order):
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)

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
s=input()
cnt0=0
cnt1=0
for i in range(len(s)):
  if s[i]=='0':
    cnt0+=1
  else:
    cnt1+=1
if cnt1<cnt0:
  print(len(s)-2*cnt1)
else:
  print(len(s)-2*cnt0)

s=input()
cnt0=0
cnt1=0
for i in range(len(s)):
  if s[i]=='0':
    cnt0+=1
  else:
    cnt1+=1
if cnt1<cnt0:
  print(2*cnt1)
else:
  print(2*cnt0)


Verdicts: Wrong Answer

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

Submission attempts (in order):
S = input()
ans = 0
while i < len(S):
    if any(['01' in S[i:i+2],'10' in S[i:i+2]]):
        S = S[:i]+S[i+2:]
        ans += 2
        i -= 1
    else:
        i += 1
print(ans)

i = 0
total = 0
while i < len(S):
    if S[i:i+2] == '01'or S[i:i+2] == '10':
        Sa = S[:i]
        Sb = S[i+2:]
        S = Sa+Sb
        total += 1
        i -= 1
    else:
        i += 1
print(total*2)

S = input()
ans = 0
i = 0
while i < len(S):
    if any(['01' in S[i:i+2],'10' in S[i:i+2]]):
        S = S[:i]+S[i+2:]
        ans += 2
        i -= 1
    else:
        i += 1
print(ans)

Verdicts: Runtime Error

Runtime Error

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

Submission attempts (in order):
s = input()
print(min(s.count("1"),s.count("2"))*2)

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
s = input()
cnt_one = s.count('1')
cnt_zero = len(s) - cnt_one
print(len(s) - min(cnt_zero, cnt_one)*2)

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
one = len([i for i in s if i == '1'])
zero = len(s)- one

print(2*min(one,zero))

s  = input()

one = len([i for i in s if i == '1'])
zero = len(s)- one

print(2*min(one,zero))

Verdicts: Runtime Error

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

Submission attempts (in order):
from __future__ import print_function
import numpy as np
import sys

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

cnt=0
S=list(input())


L=list()
L.append(S.pop())
while len(S)!=0:
    if S[-1]==L[-1]: 
        L.append(S.pop())
        
        
    else: 
        S.pop()
        L.pop()
        if L==[]:
            L.append(S.pop())
        cnt=cnt+2
        
        

print(cnt)

#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#


from __future__ import print_function
import numpy as np
import sys

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

cnt=0
S=list(input())


L=list()
L.append(S.pop())
while len(S):
    if S[-1]==L[-1]: 
        L.append(S.pop())
        
        
    else: 
        S.pop()
        L.pop()
        if L==[]:
            L.append(S.pop())
        cnt=cnt+2
        
        

print(cnt)

#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#


from __future__ import print_function
import numpy as np
import sys

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

cnt=0
S=list(input())
eprint(S)

L=list()
L.append(S.pop())
while len(S):
    if S[-1]==L[-1]: 
        L.append(S.pop())
        eprint("S: " + str(S))
        eprint("L: " + str(L))
    else: 
        S.pop()
        L.pop()
        if L==[]:
            L.append(S.pop())
        cnt=cnt+2
        eprint("S: " + str(S))
        eprint("L: " + str(L))

print(cnt)

#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#


from __future__ import print_function
import numpy as np
import sys

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

cnt=0
S=list(input())


L=list()
L.append(S.pop())
while len(S)!=0:
    if S[-1]==L[-1]: 
        L.append(S.pop())
        
        
    else: 
        S.pop()
        L.pop()
        if L==[] and S!=[]:
            L.append(S.pop())
        cnt=cnt+2
        
        

print(cnt)

#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#


Verdicts: Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):
s = input()
print(min(s.count('0'),s.count('1')))

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


Verdicts: Wrong Answer

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

Submission attempts (in order):
s = input()
count = 0
flag = True
while flag == True:
    flag = False
    for i in range(len(s)-1):
        if s[i] != s[i+1]:
            s = s[0:i]+s[i+2:]
            count += 2
            flag = True

print(count)

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

Verdicts: Runtime Error

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

Submission attempts (in order):
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']

# 1 2	| x,y = map(int,input().split())   |	x=1,y=2




# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())


# import math
# import numpy as np
# import copy
# from collections import defaultdict, Counter
# from itertools import product

def inpl(): return list(map(int, input().split()))

S = list(input())
N = len(S)
while True:
    flag = False
    for i in range(1, len(S)-2):
        l = S[i-1]
        mid = S[i:i+2]
        r = S[i+2]
        if mid == ["0", "1"] or mid == ["1", "0"]:
            if (l == "0" and r == "1") or (l == "1" and r == "0"):
                del S[i:i+2]
                i += 2
                flag = True
                if i >= len(N)-3:
                    break


    if flag:
        continue

    nN = len(S)
    for i in range(0, len(S)-1):
        mid = S[i:i+2]
        if mid == ["0", "1"] or mid == ["1", "0"]:
            del S[i:i+2]
            i += 2
            if i >= len(nN)-2:
                break

    break
print(N-len(S))

# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']

# 1 2	| x,y = map(int,input().split())   |	x=1,y=2




# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())


# import math
# import numpy as np
# import copy
# from collections import defaultdict, Counter
# from itertools import product

def inpl(): return list(map(int, input().split()))

S = input()
N = len(S)
c0 = S.count("0")
c1 = S.count("1")

print(2*min(c0, c1))


Verdicts: Runtime Error

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

Submission attempts (in order):
s=list(input())
from collections import Counter
d=Counter(s)
print(min(d[0], d[1])*2)


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

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

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
S = input()
red = S.count("0")
blue = S.count("1")
print(2 * abs(red - blue))


S = input()
red = S.count("0")
blue = S.count("1")
if red == 0 or blue == 0:
    print(0)
else:
    print(min(red, blue) * 2)


Verdicts: Wrong Answer

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

Submission attempts (in order):
import re
S = input()
print(re.sub("01|10|0(0)*(1)*1|1(0)*(1)*0|0(1)*(0)*1|1(1)*(0)*0","",S))

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
s=input();c=count;print(min(s.c("1"),s.c("0")*2))

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

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

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

Verdicts: Runtime Error

Wrong Answer

Runtime Error

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

Submission attempts (in order):
S=input()
A=S.replace(01"")
B=A.replace(10"")
print(len(S)-len(B))


S=input()
i=0
while i<=int(S)//2:
    A=S.replace("01","")
    B=A.replace("10","")
    i+=1
print(len(S)-len(B))


S=input()
A=S.replace("01","")
B=A.replace("10","")
print(len(S)-len(B))

S=list(input())
a=S.count("1")
b=S.count("0")
if a>=b:
    print(b*2)
else :
    print(a*2) 

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

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

Submission attempts (in order):
S = input()
init_count = len(S)

tmp_i = 0
while len(S) > 1:
    no_01 = True
    before_s = None
    for i, s in enumerate(S[tmp_i:]):
        if i == 0:
            before_s = s
            continue
        if before_s != s:
            no_01 = False
            print(S[:tmp_i + i-1], '(', S[tmp_i + i - 1], ' | ', S[tmp_i + i],  ')', S[tmp_i + i+1:])
            newS = S[:tmp_i + i-1] + S[tmp_i + i+1:]
            S = newS
            print('newS: ', newS)
            tmp_i = tmp_i + i - 2
            if tmp_i < 0:
                tmp_i = 0
            print(tmp_i)
            break
    if no_01:
        break
print(init_count - len(S))

S = input()
init_count = len(S)

tmp_i = 0
while len(S) > 1:
    no_01 = True
    before_s = None
    for i, s in enumerate(S[tmp_i:]):
        if i == 0:
            before_s = s
            continue
        if before_s != s:
            no_01 = False
            
            newS = S[:tmp_i + i-1] + S[tmp_i + i+1:]
            S = newS
            # print('newS: ', newS)
            tmp_i = tmp_i + i - 2
            if tmp_i < 0:
                tmp_i = 0
            # print(tmp_i)
            break
    if no_01:
        break
print(init_count - len(S))

Verdicts: Runtime Error

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

Submission attempts (in order):
import sys
input = sys.stdin.readline
s = input()
n = len(s)
a = []
i = 0
ct = 0
for i in range(n):
    a.append(int(s[i]))
i = -1

while ct < 100000000000:
    n = len(a)
    i += 1
    if i >= n - 1: break
    if a[i] == 0 and a[i + 1] == 1:
        a.pop(i)
        a.pop(i)
        ct += 1
        i -= 2
        if i <= 1: i = -1
        continue
    elif a[i] == 1 and a[i + 1] == 0:
        a.pop(i)
        a.pop(i)
        ct += 1
        i -= 2
        if i <= 1: i = -1

print(ct * 2)


import sys
input = sys.stdin.readline
s = input()
S = [int(s[i]) for i in range(len(s))]
# print(S)
count = 0
before = 0
while 1:
    #print("S:", S)
    is_continue = False
    # print(len(S))
    #deleted = False
    for i in range(max([before, 0]), len(S) - 1):
        #print(before, i)
        #print(S[i], S[i + 1])
        # print(S)
        if S[i] != S[i + 1]:
            # print(count)
            del S[i]
            del S[i]
            count += 2
            is_continue = True
            before = i - 2
            #deleted = True
            break
    if not is_continue:
        break
print(count)



s = input()
n = len(s)
a = []
i = 0
ct = 0
for i in range(n):
    a.append(int(s[i]))
i = -1

while ct < 100000000000:
    n = len(a)
    i += 1
    if i >= n - 1: break
    if a[i] == 0 and a[i + 1] == 1:
        a.pop(i)
        a.pop(i)
        ct += 1
        i -= 2
        if i <= 1: i = -1
        continue
    elif a[i] == 1 and a[i + 1] == 0:
        a.pop(i)
        a.pop(i)
        ct += 1
        i -= 2
        if i <= 1: i = -1

print(ct * 2)


Verdicts: Runtime Error

Runtime Error

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

Submission attempts (in order):
import math
s = list(input())
s = list(map(int, s))
s_ori = s.copy()
s_len = len(s)

s_new=[]
for k in range(200000):
    if k >=10000:
        print(k)
        break
    count=0
    s_len = len(s)
    if s_len ==1:
        #print('a')
        break
    for i in range(1,s_len):
        if count %2==1:
            count +=1
            if i +1==s_len:
                s_new.append(s[-1])
            continue
        if s[i] is not s[i-1]:
            count +=1
        else:
            s_new.append(s[i-1])
            if i +1==s_len:
                s_new.append(s[-1])
    #print(s_new)
    if s==s_new:
        s = s_new
        break
    s = s_new
    s_new=[]
    
#print(s_ori)    
print(s)
print(math.floor((len(s_ori)-len(s))/2)*2)

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)

Verdicts: Wrong Answer

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

Submission attempts (in order):
s = input()
a = 0
for i in s:
  a += i
print(2 * min(a, len(s)-a))

s = input()
a = 0
for i in s:
    a += int(i)
print(2 * min(a, len(s)-a))

Verdicts: Runtime Error

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

Submission attempts (in order):
s = input()
s=list(s)
zeroc=0
onec=0
for i in s:
  if i == "0":
    zeroc++
  if i == "1":
    onec++
print(min(zeroc,onec)*2)


s = input()
s=list(s)
zeroc=0
onec=0
for i in s:
  if i == 0:
    zeroc++
  if i == 1:
    onec++
print(min(zeroc,onec)*2)


s = input()
s=list()
zeroc=0
onec=0
for i in s:
  if i == 0:
    zeroc++
  if i == 1:
    onec++
print(min(zeroc,onec)*2)

s = input()
s=list(s)
zeroc=0
onec=0
for i in s:
  if i == 0:
    zeroc+=1
  if i == 1:
    onec+=1
print(min(zeroc,onec)*2)


s = input()
s=list(s)
zeroc=0
onec=0
for i in s:
  if i == "0":
    zeroc+=1
  if i == "1":
    onec+=1
print(min(zeroc,onec)*2)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

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

Submission attempts (in order):
import sys
*s, = sys.stdin.readline()
n = len(s)
cntd = {'0':0, '1':0}
for i in range(n):
    cntd[s[i]] += 1
ans = 2 * min(cntd.values())
print(ans)

import sys
*s, = sys.stdin.readline()
n = len(s)
cntd = {'0':0, '1':0}
for i in range(n):
    cntd[s[i]] += 1
ans = 2 * min(cntd.values())
print(ans)

import sys
*s, = sys.stdin.readline()
n = len(s)
cntd = {'0':0, '1':0}

for i in range(n):
    cntd[s[i]] += 1

ans = 2 * min(cntd.values())
print(ans)

import sys
s = list(sys.stdin.readline())
n = len(s)
cntd = {'0':0, '1':0}
for i in range(n):
    cntd[s[i]] += 1
ans = 2 * min(cntd.values())
print(ans)

s = list(input())
n = len(s)
cntd = {'0':0, '1':0}

for i in range(n):
    cntd[s[i]] += 1
ans = 0
ans = 2 * min(cntd.values())
print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):
s = str(input())

num_moto = int(len(s))
flag = True

while True:
    if s.find('10') == -1 or s.find('01') == -1 or int(len(s)) == 0:
        break
    s = s.replace('10','')
    s = s.replace('01','')
        
num_kekka = int(len(s))
print(num_moto - num_kekka)

s = str(input())

num_moto = int(len(s))

while True:
    if ( s.find('10') == -1 and s.find('01') == -1 ) or int(len(s)) == 0:
        break
    s = s.replace('10','')
    s = s.replace('01','')
print(s)
num_kekka = int(len(s))
print(num_moto - num_kekka)

s = str(input())

num_moto = int(len(s))

for ctr in range(500)
    if int(len(s)) == 0:
        break
    s = s.replace('10','')
    s = s.replace('01','')
    
num_kekka = int(len(s))
print(num_moto - num_kekka)

s = input()
count_0 = s.count('0')
count_1 = s.count('1')
print(2*min(count_0,count_1))

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

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

Submission attempts (in order):
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)

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

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

Verdicts: Wrong Answer

Runtime Error

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

Submission attempts (in order):
S = input()
len_s = len(S)
while(True):
    S = S.replace("01", "")
    S = S.replace("10", "")
    if not (("01" in S) and ("10" in S)):
        break
print(len_s - len(S))

S = input()
if len(S) == 1:
    print(0)
else:
    print(min(S.count('0'), S.count('1')) * 2)

Verdicts: Wrong Answer

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

Submission attempts (in order):
#!/usr/bin/python
# coding: UTF-8


S = list(input())
S = list(map(int,S))
S.append(-1)
S.insert(0,-2)
Count = 0
Before = len(S)
while True:
    L = len(S) - 2
    for i in range(L,1,-1):
        if S[i] !=  S[i+1] and S[i] != -2 and S[i+1] != -1:
            #print(S)
            S.pop(i)
            S.pop(i)
            break
    else:
        break

#print(S)
print(Before - len(S))

#!/usr/bin/python
# coding: UTF-8

S = list(input())
S = list(map(int,S))
S.append(-1)
S.insert(0,-2)
Count = 0
Before = len(S)
while True:
    L = len(S) - 2
    for i in range(L,1,-1):
        if S[i] !=  S[i+1] and S[i] != -2 and S[i+1] != -1:
            #print(S)
            S.pop(i)
            S.pop(i)
            i += 1
            if i > L:
                break
    else:
        break

#print(S)
print(Before - len(S))

#!/usr/bin/python
# coding: UTF-8

S = list(input())
S = list(map(int,S))
#S.append(-1)
#S.insert(0,-2)
#Count = 0
#Before = len(S)
#L = len(S)
#S1 = S[0:L//2]
#S2 = S[L//2:L]
zero = 0
for i in S:
    if i == 0:
        zero += 1
one = len(S) - zero
ans = one - zero if one > zero else zero - one
print(len(S) - ans)


Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
S = input()
print(S)
stack = []
ans = 0
for c in S:
    if stack and stack[0] != c:
        print("stack={}, c={} pop!".format(stack, c))
        stack.pop()
        ans += 2
    else:
        print("stack={}, c={} append!".format(stack, c))
        stack.append(c)
#     print("c={0}, st={1}".format(c, stack))
print(ans)

# ABC120 C - Unification
# 2019/10/28

def main():
    S = list(map(int, list(open(0).read())))
#     print(S)
    
    cnt = 0
    i=0

    while (i<len(S)-1):
        if (S[i] == 0 and S[i+1] == 1) or (S[i] == 1 and S[i+1] == 0):
            S.pop(i)
            S.pop(i)
            cnt+=2
#             print("i={0}, S={1}, cnt={2}".format(i, S, cnt))
            i=0
        i+=1
    
    print(cnt)
    
    
if __name__ == "__main__":
    main()

# ABC120 C - Unification
# 2019/10/28

def main():
#     S = list(map(int, list(open(0).read())))
    S = list(map(int, list(input())))
#     print(S)
    
    cnt = 0
    i=0

    while (i<len(S)-1):
        if (S[i] == 0 and S[i+1] == 1) or (S[i] == 1 and S[i+1] == 0):
            S.pop(i)
            S.pop(i)
            cnt+=2
#             print("i={0}, S={1}, cnt={2}".format(i, S, cnt))
            i=0
        i+=1
    
    print(cnt)
    
    
if __name__ == "__main__":
    main()

S = input()
print(S)
stack = []
ans = 0
for c in S:
    if stack and stack[0] != c:
#         print("stack={}, c={} pop!".format(stack, c))
        stack.pop()
        ans += 2
    else:
#         print("stack={}, c={} append!".format(stack, c))
        stack.append(c)
#     print("c={0}, st={1}".format(c, stack))
print(ans)

S = input()
# print(S)
stack = []
ans = 0
for c in S:
    if stack and stack[0] != c:
#         print("stack={}, c={} pop!".format(stack, c))
        stack.pop()
        ans += 2
    else:
#         print("stack={}, c={} append!".format(stack, c))
        stack.append(c)
#     print("c={0}, st={1}".format(c, stack))
print(ans)

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

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

Submission attempts (in order):
s = input()
s = list(s)
print(2*min(s.count(0),s.count(1)))

s = input()
rc = s.count("0")
bc = s.count("1")
min1 = min(rc,bc)
print(min1 *2)

Verdicts: Wrong Answer

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

Submission attempts (in order):
s = input()
n0, n1 = 0, 0

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

s = input()
n0, n1 = 0, 0

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
import sys

s = sys.stdin.readline().rstrip()
n = len(s)

def main():
    c = s.cout('0')
    print(min(n-c, c) * 2)

if __name__ ==  '__main__':
    main()

import sys

s = sys.stdin.readline().rstrip()
n = len(s)

def main():
    c = s.count('0')
    print(min(n-c, c) * 2)

if __name__ ==  '__main__':
    main()

Verdicts: Runtime Error

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

Submission attempts (in order):
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]))

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])*2)

Verdicts: Wrong Answer

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

Submission attempts (in order):
r = 0
b = 0
for a in input():
    if a == '0':
        r += 1
    else:
        b += 1

print(min(r, b))

r = 0
b = 0
for a in input():
    if a == '0':
        r += 1
    else:
        b += 1

print(min(r, b)*2)

Verdicts: Wrong Answer

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

Submission attempts (in order):
S = list(input())
obj = min(S.count("0"),S.count("1"))
print((obj-1)*2)

S = list(input())
obj = min(S.count("0"),S.count("1"))
print(obj*2)

Verdicts: Wrong Answer

Accepted