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();min(S.count('0'),S.count('1'))*2

S=input();
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):
S=list(int(input()))

red=0
blue=0
for i in range(N):
    if S[i]==0:
        red+=1
    else:
        blue+=1
print(min(red,blue)*2)

S=input()
red=0
blue=0
for i in range(N):
    if S[i]==0:
        red+=1
    else:
        blue+=1
print(min(red,blue)*2)

S=list(input())

red=0
blue=0
for i in range(len(S)):
    if S[i]=="0":
        red+=1
    else:
        blue+=1
        
print(min(red,blue)*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):
s = input()
zero = len([x for x in s if x == "0"])
one = len(s) - zero

print(min(zero, one))

import re

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

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

count = 0
remove(input(), count)

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

print(min(zero, one) * 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):
from collections import Counter
s=input()
if len(set(s)) == 1:
  print(0)
else:
  cs=Counter()
  print(min(cs['0'],cs['1'])*2)


from collections import Counter
s=input()
if len(set(s)) == 1:
  print(0)
else:
  cs=Counter(s)
  print(min(cs['0'],cs['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()

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

s = input()

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

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)

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):
string = input()
ones = 0
zeros = 0
for s in string:
  if s == '1':
    ones += 1
  else:
    zeroes += 1
print(2*min(ones, zeros))

string = input()
ones = 0
zeros = 0
for s in string:
  if s == '1':
    ones += 1
  else:
    zeros += 1
print(2*min(ones, zeros))

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):
if __name__ == "__main__":
    n = input()
    a = 0
    b = 0
    for c in n:
        if(c == '1'):
            a += 1
        else:
            b += 1
    if(a>b):
        print(b)
    else:
        print(a)

if __name__ == "__main__":
    n = input()
    a = 0
    b = 0
    for c in n:
        if(c == '1'):
            a += 1
        else:
            b += 1
    if(a>b):
        print(b*2)
    else:
        print(a*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):
def solve(S,crs=0):
    if crs >= len(S):
        return 0
    while crs + 1 < len(S):
        if S[crs] != S[crs+1]:
            return max(solve(S,crs+1),solve(S[:crs]+S[crs+2:],crs-1)+2)
        crs += 1
        
    return 0
  
S = input()
print(S,0)

def solve(S):
    return min(S.count("0"),S.count("1"))*2
  
S = input()
print(solve(S))

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/env python3
S = input()
print(2*min(S.count("0"), S.count("1c")))

#!/usr/bin/env python3
S = input()
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):
def next_check(cubes):
	index_list = []
	for cube_index in reversed(range(1, len(cubes))):
		if ((cube_index not in index_list) and (cubes[cube_index] == cubes[cube_index - 1])):
			index_list.append(cube_index - 1)
			index_list.append(cube_index)
	l = len(index_list)
	for i in reversed(index_list):
		cubes.pop(i)
	return (cubes, l)

def main():
	cubes = input()
	for c in cubes:
		if c not in ['0', '1']:
			exit(0)
	cube_list = []
	for cube in cubes:
		cube_list.append(cube)
	l = len(cube_list)
	k = 0
	while (l != 0):
		cubes, l = next_check(cube_list)
		k += l
	print(k)

if __name__ == "__main__":
	main()

	index_list = []
	for cube_index in range(1, len(cubes)):
		if cube_index not in index_list and cubes[cube_index] == cubes[cube_index - 1]:
			index_list.append(cube_index - 1)
			index_list.append(cube_index)
	l = len(index_list)
	for i in reversed(index_list):
		cubes.pop(i)
	return (cubes, l)


cubes = input()
for c in cubes:
	if c not in ['0', '1']:
		exit(0)
cube_list = []
for cube in cubes:
	cube_list.append(cube)
l = len(cube_list)
k = 0
while (l != 0):
	cubes, l = next_check(cube_list)
	k += l
print(k)

S = input()

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

print(min(num_0, num_1)*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):
n = int(input())
input_list = list(map(int, input().split()))
ans_list = input_list[::-2] + input_list[n%2::2]
print(*ans_list)

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

print(min(zero, one) * 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()
res = 0
while S:
    p = S[0]
    T = []
    i = 1
    while i < len(S):
        if S[i] != S[i-1]:
            i += 1
            res += 2
        else:
            T.append(S[i])
        i += 1
    if len(S) == len(T):
        break
    S = T
print(res)

S = input()
print(min(sum([1 for s in S if s == "0"]),sum([1 for s in S if 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()

zero_cnt = S.count("0")
one_cnt = S.count("1")

print( min(zero_cnt, one_cnt) )



S = input()

zero_cnt = S.count("0")
one_cnt = S.count("1")

print( min(zero_cnt, one_cnt) * 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):
t = input()
s = [c for c in t]
count = 0
while True and len(s)>1:
    u = []
    tmp = len(s)
    for i in range(len(s)-1):
        if int(s[i])+int(s[i+1]) == 1:
            s[i+1] = '2'
            count += 2
        elif not s[i] == '2':
            u.append(s[i])
    s = u
    if tmp == len(s):
        break
print(count)
            

t = input()
s = [int(c) for c in t]
print(2 * min(len(s)-sum(s), sum(s)))

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):
#%%
def c(s):
    n = len(s)

    if n < 2:
        print(0)

    else:
        ans, i = 0, 0
        rem = []

        while i < n:
            print(rem,s[0:i],s[i:])

            if not rem:

                if i+1 < n:
                    if s[i] == s[i+1]:
                        rem.append(s[i])
                        i += 1

                    else:
                        i += 2
                        ans += 2

                else:
                    i += 1

            else:
                if rem[-1] != s[i]:
                    rem.pop()
                    i += 1
                    ans += 2
                
                else:
                    if i + 1 < n:
                        if s[i] == s[i+1]:
                            rem.append(s[i])
                            i += 1

                        else:
                            i += 2
                            ans += 2

                    else:
                        i += 1
    print(ans)

#%%
s = input()

c(s)

#%%
s = input()
n = len(s)

if n < 2:
    print(0)

else:
    ans, i = 0, 0
    rem = []

    while i < n:

        if not rem:

            if i+1 < n:
                if s[i] == s[i+1]:
                    rem.append(s[i])
                    i += 1

                else:
                    i += 2
                    ans += 2

            else:
                i += 1

        else:
            if rem[-1] != s[i]:
                rem.pop()
                i += 1
                ans += 2
            
            else:
                if i + 1 < n:
                    if s[i] == s[i+1]:
                        rem.append(s[i])
                        i += 1

                    else:
                        i += 2
                        ans += 2

                else:
                    i += 1
    print(ans)


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()

ans = 0
stack = []

for c in s[1:-1]:
  if stack == []:
    continue
  if c == stack[-1]:
    ans += 2
    stack.pop(-1)
  else:
    stack.append(c)
    
print(ans)


s = input()
 
ans = 0
stack = []
 
for c in s:
  if stack == []:
    continue
  if c != stack[-1]:
    ans += 2
    stack.pop(-1)
  else:
    stack.append(c)
    
print(ans)

s = input()
 
ans = 0
stack = []
 
for c in s:
  if stack == []:
    continue
  if c == stack[-1]:
    ans += 2
    stack.pop(-1)
  else:
    stack.append(c)
    
print(ans)

s = input()

ans = 0
stack = [s[0]]

for c in s[1:-1]:
  if c == stack[-1]:
    ans += 2
    stack.pop(-1)
  else:
    stack.append(c)
    
print(ans)


s = input()
 
ans = 0
stack = []
 
for c in s:
  if stack == []:
    stack.append(c)
    continue
  if c != stack[-1]:
    ans += 2
    stack.pop(-1)
  else:
    stack.append(c)
    
print(ans)


Verdicts: Wrong Answer

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


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















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


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















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


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















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)















Verdicts: Wrong Answer

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):
from collection import Counter
cnt = Counter()
s = input()
for c in s:
  cnt[c] += 1
  
print(min(cnt.keys()) * 2)

def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b


from collections import Counter

cnt = Counter()
s = input()
for c in s:
    cnt[c] += 1

if len(cnt.keys()) == 1:
    print(0)
else:
    print(min(cnt.values()) * 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):
from collections import deque

s=input()
sd=deque(s)
d=deque()
while(len(sd)>0):
  crr = sd.popleft()
  if(len(d)<1):
    d.append(crr)
    continue
    if(len(d)>=1 and d[-1]!=crr):
      d.pop()
      else:
        d.append(crr)
print(len(s)-len(d))

from collections import deque
 
s=input()
sd=deque(s)
d=deque()
while(len(sd)>0):
  crr = sd.popleft()
  if(len(d)<1):
    d.append(crr)
    continue
  if(len(d)>=1 and d[-1]!=crr):
    d.pop()
  else:
    d.append(crr)
print(len(s)-len(d))

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):
a, b, c = map(int, input().split())
print(min(b//a, c))

S = list(input())
n0 = S.count('0')
n1 = S.count('1')
print(2*min(n0, n1))

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()
print(min(S.count("1"), S.count("0")))


S = input()
print(2 * min(S.count("1"), S.count("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):
s=str(input())
n=len(s)
b=s.count('0')
A=[b,n-b]
print(n-min(A)-min(A))

s=str(input())
n=len(s)
b=s.count('0')
A=[b,n-b]
print(2*min(A))

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())
print(min(s.count("1"),s.count("0")*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):
ans=0
s_=""
s=input()
while s!=s_:
	s_=s
	s=s.replace("01","")
	ans+=len(s_)-len(s)
	s_=s
	s=s.replace("10","")
	ans+=len(s_)-len(s)
print(ans)

s=input()
sum1=len([i for i in s if i=="1"])
sum0=len([i for i in s if i=="0"])
if sum1>sum0:
	print(sum0*2)
else:
	print(sum1*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 numpy as np

S = np.array(list(map(int, list(input()))))

n0 = (S == 0).sum()
n1 = (S == 1).sum()

print(min(n0, n1))


import numpy as np

S = np.array(list(map(int, input())))

n0 = (S == 0).sum()
n1 = (S == 1).sum()

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):
S = input()
c0, c1 = 0,0
ans = 0
for ch in S:
  if c0 == 0 and ch = '1':
    c1 += 1
  elif c1 == 0 and ch = '0':
    c0 += 1
  elif ch == '1':
    ans += 2
    c0 -= 1
  else:
    ans += 2
    c1 -= 1
    
print(ans)


S = input()
c0, c1 = 0,0
ans = 0
for ch in S:
  if c0 == 0 and ch == '1':
    c1 += 1
  elif c1 == 0 and ch == '0':
    c0 += 1
  elif ch == '1':
    ans += 2
    c0 -= 1
  else:
    ans += 2
    c1 -= 1
    
print(ans)


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()

num0=0
num1=1

for i in range(len(S)):
    if S[i]=='0':
        num0+=1
    else:
        num1+=1
print(min(num0,num1))



S=input()

num0=0
num1=0

for i in range(len(S)):
    if S[i]=='0':
        num0+=1
    else:
        num1+=1
print(2*min(num0,num1))



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())
count = 0
find = False
while True:
    if len(s) <=2:
        break
    for i in range(0,len(s)-1):
        if s[i] != s[i+1]:
            count += 2
            del s[i]
            del s[i+1]
            break
    else:
        break
    
print(count)

s = list(input())
zero = s.count("0")
ans = min(len(s)-zero,zero)
print(ans*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):
x=0
y=0
for i in list(input()):
  if i=='0':
    x+=1
  else:
    y+=1
print(min(x,y))

x=0
y=0
for i in list(input()):
  if i=='0':
    x+=1
  else:
    y+=1
print(min(x,y)*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()
print(2*min(s.count(0),s.count(1)))

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):
def trim(s):
    for i in range(len(s)-1):
        if (s[i]=="0" and s[i+1]=="1") or (s[i]=="1" and s[i+1]=="0"):
            s=s[:i]+s[i+2:]
            break
    else: return False
    return s
s=input()
c=-1
while s:
    c+=1
    s=trim(s)
print(c*2)

s=input()
a=s.count("0")
b=s.count("1")
print(min(a,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):
l=list(map(str,input()))
print(2*(min(l.count(0),l.count(1))))


l=list(map(str,input()))
print(2*(min(l.count('0'),l.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=str(input())

p1 = '01'
p2 = '10'
s = s[::-1]
c = 0
flag = True
while flag:
  flag = False
  for i in range(len(s)):
    if s[i:i+4] == in('0011','1100','1010','0101','1001','0110'):
      s = s[:i] + s[i+4:]
      c += 4
      flag = True
      break
    
    
    if s[i:i+2] in [p1,p2]:
      s = s[:i] + s[i+2:]
      c += 2
      flag = True
      break
print(c)

s=str(input())
c1 = 0
c0 = 0
for i in range(len(s)):
  if s[i] == '1':
    c1 += 1
  if s[i] == '0':
    c0 += 1
print(2*min(c1,c0))

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()

red = 0  # 0
blue = 0 # 1
m = 0
for s in S:
	if s = '0':
		if blue != 0:
			blue -= 1
			m += 2
		else:
			red += 1
	elif s = '1':
		if red != 0:
			red -= 1
			m += 2
		else:
			blue += 1

print(m)

S = input()

red = 0  # 0
blue = 0 # 1
m = 0
for s in S:
	if s == '0':
		if blue != 0:
			blue -= 1
			m += 2
		else:
			red += 1
	elif s == '1':
		if red != 0:
			red -= 1
			m += 2
		else:
			blue += 1

print(m)

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):
for a in Str:
    Codigo.append(a)

lenMax=len(Codigo)-1
k=0

while i < len(Codigo)-1:
    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

        k+=1

        if k >= lenMax:
            break
    except:
        break
    
print(contador)

a = input()
c_zero = 0
c_one = 0
for digit in a:
    if digit == '0':
        c_zero += 1
    else:
        c_one += 1
print(min(c_one, c_zero) * 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):
def main():
    S = list(input())
    count = 0
    while True:
        start_count = count
        for i, val in enumerate(S):
            while_loop = 0
            while True:
                while_loop += 1
                try:
                    if S[i] != S[i+1]:
                        S.pop(i)
                        S.pop(i)
                        i -= 1
                        count += 2
                    else:
                        break
                except IndexError:
                    if i < 0:
                        i == 0
                    else:
                        break
        if start_count == count:
            break

    print(count)


if __name__ == "__main__":
    main()


from collections import Counter


def main():
    S = list(input())
    c = Counter(S)
    print(len(S) - abs(c['0'] - c['1']))


if __name__ == "__main__":
    main()


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

while S.find("01") != -1 or S.find("10") != -1:
    count += 2 * s.count("01")
    s = s.replace("01", "")
    count += 2 * s.count("10")
    s = s.replace("10", "")
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):
S = input()
N = len(S)
for _ in range(N//2):
    S = S.replace('01','').replace('10','')S.replace('01','').replace('10','')S.replace('01','').replace('10','')S.replace('01','').replace('10','')S.replace('01','').replace('10','')
    if S.count('01') == 0 and S.count('10') == 0:
        break
print(N - len(S))


S = input()
r = S.count('0')
b = S.count('1')
print(min(r,b)*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):
from sys import stdin


sdi = stdin.readline().rstrip()
# a, b, c = stdin.readline().rstrip().split()
# a, b, c = [x for x in stdin.readline().rstrip().split()]
# a, b, c = [int(x) for x in stdin.readline().rstrip().split()]

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

print(start - len(l))


from sys import stdin


sdi = stdin.readline().rstrip()
# a, b, c = stdin.readline().rstrip().split()
# a, b, c = [x for x in stdin.readline().rstrip().split()]
# a, b, c = [int(x) for x in stdin.readline().rstrip().split()]

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

print(start - len(l))


from sys import stdin


sdi = stdin.readline().rstrip()
# a, b, c = stdin.readline().rstrip().split()
# a, b, c = [x for x in stdin.readline().rstrip().split()]
# a, b, c = [int(x) for x in stdin.readline().rstrip().split()]

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

print(start - len(l))


from sys import stdin


sdi = stdin.readline().rstrip()
# a, b, c = stdin.readline().rstrip().split()
# a, b, c = [x for x in stdin.readline().rstrip().split()]
# a, b, c = [int(x) for x in stdin.readline().rstrip().split()]
l = list(sdi)
l.reverse()
start = len(l)
i = 0
while len(l) - 1 >= i + 1:
    print(l)
    if l[i] != l[i + 1]:
        l.pop(i + 1)
        l.pop(i)
        i = max(i - 2, 0)
        continue
    i += 1
print(start - len(l))


from sys import stdin


sdi = stdin.readline().rstrip()
# a, b, c = stdin.readline().rstrip().split()
# a, b, c = [x for x in stdin.readline().rstrip().split()]
# a, b, c = [int(x) for x in stdin.readline().rstrip().split()]
l = list(sdi)
l.reverse()
start = len(l)
i = 0
while len(l) - 1 >= i + 1:
    if l[i] != l[i + 1]:
        l.pop(i + 1)
        l.pop(i)
        i = max(i - 2, 0)
        continue
    i += 1
print(start - len(l))


Verdicts: Wrong Answer

Wrong Answer

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()

i = 0
while(True):
    if ("01" in s ) :
        s = s.replace("01","",1) 
        i += 1
    elif "10" in s:
        s = s.replace("10","",1)
        i += 1
    else:
        break
    print(s)
print(i*2)

s = input()

num_0 = s.count("0")
num_1 = s.count("1")
if num_0 < num_1:
    print(num_0*2)
else:
    print(num_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):
from collections import Counter


def main():
    S = input()

    ans = f(S)
    print(ans)


def f(S):
    c = Counter(S)
    return min(c['0'], c['1'])


if __name__ == '__main__':
    main()


def main():
    S = input()

    ans = f(S)
    print(ans)


def f(S):
    
    bef = S[0]
    b = []
    a = 0
    for c in S:
        if c == '0':
            a += 1
        else:
            a -= 1
        b.append(a)

    from collections import Counter
    c = Counter(b)
    ans = 0
    for v in c.values():
        ans += v // 2 * 2

    # print(c)

    return ans


if __name__ == '__main__':
    main()


def main():
    S = input()

    ans = f(S)
    print(ans)


def f(S):
    stack = []
    ans = 0
    for c in S:
        if stack and stack[-1] != c:
            ans += 2
            stack.pop()
        else:
            stack.append(c)
    return ans


if __name__ == '__main__':
    main()


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):
def extract(string, i):
    split = string.split("01")
    split = split.split("10")
    i += len(split) - 1
    split_concat = "".join(split)
    if "01" in split_concat or "10" in split_concat:
        return extract(split_concat, i)
    else:
        return i * 2

S = input()
print(extract(S,0))


def extract(string, i):
    split = "".join(string.split("01")).split("10")
    i += len(split) - 1
    split_concat = "".join(split)
    if "01" in split_concat or "10" in split_concat:
        return extract(split_concat, i)
    else:
        return i * 2

S = input()
print(extract(S,0))


S = input()

print(min(S.count('0'), S.count('1')) * 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):
s = input()
stack = []
r = 0
for c in s:
  n = int(c)
  if len(stack) > 0 and stack[-1] ^ n == 1:
    stack.pop()
    r += 1
  else:
    stack.append(n)
print(r)

s = input()
stack = []
r = 0
for c in s:
  n = int(c)
  if len(stack) > 0 and stack[-1] ^ n == 1:
    stack.pop()
    r += 2
  else:
    stack.append(n)
print(r)

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(map(int,input()))

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

s = list(map(int,input()))

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


s = input()

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

print(2 * min(one, zero))


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()
init_len = len(s)
tmp_s_len = 0
while tmp_s_len != len(s):
    tmp_s_len = len(s)
    s = s.replace("01","").replace("10","")
    if s == "":
        break
    else:
        continue
res = init_len - tmp_s_len
print(res)


s = input()
cnt_zero = 0
cnt_one = 0
for letter in s:
    if letter == "0":
        cnt_zero += 1
    else:
        cnt_one += 1
res = min(cnt_zero, cnt_one) * 2
print(res)


Verdicts: Wrong Answer

Accepted