TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: You are given positive integers A and B.  Find the K-th largest positive integer that divides both A and B.  The input guarantees that there exists such a number.

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

a, b, k = map(int, input().split())
count = 0
for i in range(100, 0, -1):
    if a % i == 0 and b % i == 0:
        count += 1
        if count == k:
            print(i)
            exit()


Verdicts: Wrong Answer

Accepted
Problem: You are given positive integers A and B.  Find the K-th largest positive integer that divides both A and B.  The input guarantees that there exists such a number.

Submission attempts (in order):
A, B, K = map(int, input().split())

def get(num):
    yakusuu_array = []
    for i in range(1,num + 1):
        if num % i == 0:
            yakusuu_array.append(i)
    return yakusuu_array

print(get(A))
a = list(set(get(A)) & set(get(B)))
a.sort(reverse=True)


print(a[(K-1)])



A, B, K = map(int, input().split())

def get(num):
    yakusuu_array = []
    for i in range(1,num + 1):
        if num % i == 0:
            yakusuu_array.append(i)
    return yakusuu_array

a = list(set(get(A)) & set(get(B)))
a.sort(reverse=True)


print(a[(K-1)])



Verdicts: Wrong Answer

Accepted
Problem: You are given positive integers A and B.  Find the K-th largest positive integer that divides both A and B.  The input guarantees that there exists such a number.

Submission attempts (in order):
a, b, c = map(int, input().split())
for i in range(1, 101):
  if a%i + b%i < 1:
	c -= 1
    if c < 1:
      print(i)
	  break 
  

#! /usr/bin/env python3
a, b, c = map(int, input().split())
t = []
for i in range(1, 101):
    if a%i + b%i < 1: t += [i]
print(t[-c])

Verdicts: Runtime Error

Accepted
Problem: You are given positive integers A and B.  Find the K-th largest positive integer that divides both A and B.  The input guarantees that there exists such a number.

Submission attempts (in order):
A,B,K=map(int,input().split())
count=1
i=1
while count<K:
  i+=1
  if A%i=0 and B%i=0:
    count+=1
print(i)
  

A,B,K=map(int,input().split())
count=0
i=min(A,B)+1
while count<K:
  i-=1
  if A%i==0 and B%i==0:
    count+=1
print(i)

Verdicts: Runtime Error

Accepted
Problem: You are given positive integers A and B.  Find the K-th largest positive integer that divides both A and B.  The input guarantees that there exists such a number.

Submission attempts (in order):
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)
A,B,K=map(int,input().split())
print(A*B//gcd(A,B)*K)

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)
def make_divisors(n):
  lower_divisors , upper_divisors = [], []
  i = 1
  while i*i <= n:
    if n % i == 0:
      lower_divisors.append(i)
      if i != n // i:
        upper_divisors.append(n//i)
    i += 1
  return lower_divisors + upper_divisors[::-1]
A,B,K=map(int,input().split())
c=gcd(A,B)
print(make_divisors(c)[-K])

Verdicts: Wrong Answer

Accepted
Problem: You are given positive integers A and B.  Find the K-th largest positive integer that divides both A and B.  The input guarantees that there exists such a number.

Submission attempts (in order):
A,B,K = list(map(int, input().split()))
x=[]

for i in range(max(A,B)):
  if A%i==B%i==0:
    x.append(i)

print(x[K-1])

A,B,K = list(map(int, input().split()))
x=[]
count=0 
for i in range(max(A,B)+1):
  if A%(i+1)==B%(i+1)==0:
    x.append(i+1)
    count+=1
 
print(x[count-K])

Verdicts: Runtime Error

Accepted
Problem: You are given positive integers A and B.  Find the K-th largest positive integer that divides both A and B.  The input guarantees that there exists such a number.

Submission attempts (in order):
A,B,K = map(int,input().split())

list = []
for i in range(1,101):
    if A % i == 0 and B % i == 0:
        list.append(i)

print(list)
print(list[K-1])

A,B,K = map(int,input().split())

list = []
for i in range(1,101):
    if A % i == 0 and B % i == 0:
        list.append(i)

list.sort(reverse=True)
print(list[K-1])

Verdicts: Wrong Answer

Accepted
Problem: You are given positive integers A and B.  Find the K-th largest positive integer that divides both A and B.  The input guarantees that there exists such a number.

Submission attempts (in order):
a,b,k = map(int,input().split())
ans = 1
i = 1
found = False
while ans <= a and ans <= b and not found:
    if a % ans == 0 and b % ans == 0:
        print(ans)
        if i == k:
            found = True
            print(ans)
        i += 1
    ans += 1

a,b,k = map(int,input().split())
ans = 1
i = 1
aa = []
while ans <= a and ans <= b:
    if a % ans == 0 and b % ans == 0:
        aa.append(ans)
        i += 1
    ans += 1
aa.reverse()
print(aa[k-1])

Verdicts: Wrong Answer

Accepted
Problem: You are given positive integers A and B.  Find the K-th largest positive integer that divides both A and B.  The input guarantees that there exists such a number.

Submission attempts (in order):
import math

def main():
    a, b, k = [int(x) for x in input().split()]

    p = []
    for i in range(1, max(a, b) - 1):
        if a % i == 0 and b % i == 0:
            print(i)
            p.append(i)

    print(p[len(p) - k])



if __name__ == "__main__":
    main()

def common_divisor(a, b):
  ans = []
  mn = min(a, b)
  mx = max(a, b)
  for i in range(1, min(a, b) + 1):
    if a % i == 0 and b % i == 0 :
      ans.append(i)
  
  return ans

a, b, c = [int(x) for x in input().split()]
kys = common_divisor(a, b)
print(kys[len(kys) - c])

Verdicts: Runtime Error

Accepted
Problem: You are given positive integers A and B.  Find the K-th largest positive integer that divides both A and B.  The input guarantees that there exists such a number.

Submission attempts (in order):
A , B , K = map(int,input().split())

lst = []
for i in range(1,max(A,B) + 1):
    if (A / i).is_integer() and (B / i).is_integer():
       lst.append(i)
lst.sort(reverse=True)
print(lst[K - 1])
print(lst)

A , B , K = map(int,input().split())

lst = []
for i in range(1,max(A,B) + 1):
    if (A / i).is_integer() and (B / i).is_integer():
       lst.append(i)
lst.sort(reverse=True)
print(lst[K - 1])

Verdicts: Wrong Answer

Accepted
Problem: You are given positive integers A and B.  Find the K-th largest positive integer that divides both A and B.  The input guarantees that there exists such a number.

Submission attempts (in order):
a,b,k=input().split()
a,b,k=int(a),int(b),int(k)
c=0
for i in range(min(a,b)):
    if a%(i+1)==0 and b%(i+1)==0:
        print(i+1)
        c+=1
    if c==k:
        print(i+1)
        break


a,b,k=map(int,input().split())
check=0
m=min(a,b)
for i in range(m,0,-1):
    if a%i==0 and b%i==0:
        check+=1
        if check==k:
            print(i)
            break


Verdicts: Wrong Answer

Accepted
Problem: You are given positive integers A and B.  Find the K-th largest positive integer that divides both A and B.  The input guarantees that there exists such a number.

Submission attempts (in order):
A,B,K = map(int,input().split())

L = []

for i in range(1,max(A,B) + 1):

	if (A % i) == 0 and (B % i) == 0:
		L.append(i)
		
print(L[-K:-K+1])

A,B,K = map(int,input().split())

L = []

for i in range(1,max(A,B) + 1):

	if (A % i) == 0 and (B % i) == 0:
		L.append(i)
		
if K - (K-1) >= 0:
	print(L[0])
else:
	print(L[-K:-K+1])

A,B,K = map(int,input().split())

L = []

for i in range(1,max(A,B) + 1):

	if (A % i) == 0 and (B % i) == 0:
		L.append(i)
		
print(L[-K])

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given positive integers A and B.  Find the K-th largest positive integer that divides both A and B.  The input guarantees that there exists such a number.

Submission attempts (in order):
import fractions as frac

A,B,K = [int(i) for i in input().split()]

cd_list = []
for i in range(1,max(A,B)+1) :
    print(i)
    if (A % i == 0 and B % i == 0) :
        cd_list.append(i)
        
        #     break

print(cd_list[-K])

import fractions as frac

A,B,K = [int(i) for i in input().split()]

cd_list = []
for i in range(1,max(A,B)+1) :
    if (A % i == 0 and B % i == 0) :
        cd_list.append(i)
        
        #     break

print(cd_list[-K])

Verdicts: Wrong Answer

Accepted
Problem: You are given positive integers A and B.  Find the K-th largest positive integer that divides both A and B.  The input guarantees that there exists such a number.

Submission attempts (in order):
import math
import collections

def gcd(x,y)
	if y==0: return x
  return gcd(y,x%y)

gc_value = gcd(A,B)
N = gc_value


prime_factor = []
for i in range(2,int(math.sqrt(N))+1):
  while N%i == 0:
    prime_factor.append(i)
    N/=i
    
if N > 1:
  prime_factor.append(N)
  
for i in range(K-1):
  gc_value/=prime_factor[i]

print(int(gc_value))  
  


import sys

A,B,K = [int(s) for s in input().split()]

cnt = 0

N = min(A,B) 

for i in range(N,0,-1):
  if A % i == 0 and B % i == 0:
    cnt += 1
  if cnt == K:
    print(i)
    sys.exit()

Verdicts: Runtime Error

Accepted
Problem: You are given positive integers A and B.  Find the K-th largest positive integer that divides both A and B.  The input guarantees that there exists such a number.

Submission attempts (in order):
A,B,K=map(int,input().split());print[i for i in range(A,0,-1)if 1>A%i+B%i][K-1]

A,B,K=map(int,input().split());print[i for i in range(A,0,-1)if1>A%i+B%i][K-1]

A,B,K=map(int,input().split());print([i for i in range(A,0,-1)if1>A%i+B%i][K-1])

A,B,K=map(int,input().split());print([i for i in range(A+1)if i>=1>A%i+B%i][::-1][K-1])

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You are given positive integers A and B.  Find the K-th largest positive integer that divides both A and B.  The input guarantees that there exists such a number.

Submission attempts (in order):
data = input().split()

divisor0 = []
divisor1 = []
for i in range(int(data[0])):
    if int(data[0]) % (i+1) == 0:
        divisor0.append(i+1)

for i in range(int(data[1])):
    if int(data[1]) % (i+1) == 0:
        divisor1.append(i+1)

print(divisor0)

print(divisor1)
plus_array= divisor0 + divisor1
l_duplicate = [x for x in set(plus_array) if plus_array.count(x) > 1]
print(l_duplicate[int(data[2])-1])

data = input().split()

divisor0 = []
divisor1 = []
for i in range(int(data[0])):
    if int(data[0]) % (i+1) == 0:
        divisor0.append(i+1)

for i in range(int(data[1])):
    if int(data[1]) % (i+1) == 0:
        divisor1.append(i+1)


plus_array= divisor0 + divisor1
l_duplicate = [x for x in set(plus_array) if plus_array.count(x) > 1]

l_duplicate.sort(reverse=True)

print(l_duplicate[int(data[2])-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()
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):
# -*- coding: utf-8 -*-


string = input()


max = min(len(string), 100000)


del_count = 0


del_flg = True

while del_flg:
    del_flg = False
    for idx in range(max):
        target = string[idx : idx + 2]
        if target == "01" or target == "10":
            string_head = string[:idx]
            string_tail = string[idx + 2:]
            string = string_head + string_tail
            print(string)
            del_count += 2
            del_flg = True

print(del_count)

# -*- coding: utf-8 -*-

string = input()

red_count  = string.count('0')
blue_count = string.count('1')

print(min(red_count, blue_count) * 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):
n=int(input())
a=list(map(int,input().split()))
e=[]
o=[]
s=0

for i in range(n):
    if(int(a[i])==1):
        s+=1
    else:
        e.append(s)
        if(s==n):
            break
        for j in range(i,n):
            f=0
            if(int(a[j])==0):
                s+=1
            else:
                e.append(s)
                if(s==n):
                    break
                for k in range(j,n):
                    if(int(a[k])==1):
                        s+=1
                    else:
                        e.append(s)
                        if(s==n):
                            break
                        f=1
                        break
                if(f==1):
                    break
        
        e.append(s)
        if(s==n):
            break
        s=0
e.append(s)
if(len(e)==0):
    print("0")
else:
    print(max(e))
#print(o)

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

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):
st = input()
countone = st.count('1')
countzero = st.count('0')
if countone > countzero and countzero > 0:
    print(countone)
elif countone <= countzero and countone > 0:
    print(countzero)
else:
    print('0')

st = input()
countone = st.count('1')
countzero = st.count('0')
if countone > countzero and countzero > 0:
    print(countzero*2)
elif countone <= countzero and countone > 0:
    print(countone*2)
else:
    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):
s=list(map(int,input()))
i=0
ans=0
a=s[i]
b=s[i]
while True:
  try:
    a=s[i]

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

s=list(map(int,input()))
i=0
ans=0

s=[s.count(0),s.count(1)]
print(min(s)*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()
if s.count("0")==len(s) or s.count("1"):
    print(0)
else:
    print(min(s.count("0"),s.count("1"))*2)

s=input()
if s.count("0")==len(s) or s.count("1")==len(s):
    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):
n = int(input())
s = input()
cnt1 = 0
cnt2 = 0
for i in range(n):
    if s[i] == '0':
        cnt1 += 1
    else:
        cnt2 += 1
print(min(cnt1, cnt2)*2)

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

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 = list(s)

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

s = input()
s_list = list(s)

print(min(s_list.count('1'), s_list.count('0')) * 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()
S = list(S)
count = 0


for j in range(200) :
    if len(S) < 2:
        break
    
    if S[0] != S[1] :
        S.pop(0)
        S.pop(0)
        count+=2
    
    
    for i in range(1,len(S)-2) :
        print(S, i)
        if S[i] != S[i+1] :
            if S[i-1] != S[i+2] :
                S.pop(i)
                S.pop(i)
                count +=2
                break
            
print(count)
        


S = input()
C1 = S.count("0")
C2 = S.count("1")

print(min(C1,C2)*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):
a=list(str(input()))
b=a.count('0')
c=a.count('1')
print(b if b<=c else c)

a=list(str(input()))
b=a.count('0')
c=a.count('1')
print(b*2 if b<=c else c*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

while len(s) > 0:
    i = 0

    while i < len(s):
        if i == len(s)-1:
            break
        if (s[i+1] == '0' and s[i+2] =='1') or (s[i+1] == '1' and s[i+2] =='1'):
            s = s[:i+1]+s[i+3:]
            count += 1
            break
        i += 1
    if i == len(s)-1:
            break

print(count*2)

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

if count0 >= count1:
    print(count1*2)
else:
    print(count0*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 = list(input())
S_len = len(S)


def dfs(S):
    slen = len(S)
    for i in range(slen -1 ):
        if S[i] != S[i+1]:
            del S[i+1:i+2]
            dfs(S)
            break;
    End_len = len(S)
    ans = S_len - End_len
    return ans

if __name__ == '__main__':
    print(dfs(S))

s = input()
count_0 = s.count('0')
count_1 = s.count('1')
print(2*min(count_0,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()
count = 0

oi10 = "0"*10 + "1"*10
io10 = "1"*10+"0"*10

while oi10 in s or io10 in s:
    while oi10 in s:
        s = s.replace(oi10, "", 1)
        count += 10
    while io10 in s:
        s = s.replace(io10, "", 1)
        count += 10

while "01" in s or "10" in s:
    while "01" in s:
        s = s.replace("01", "", 1)
        count += 1
    while "10" in s:
        s = s.replace("10", "", 1)
        count += 1

print(count * 2)
print(s)


count = 0

oi10 = "0"*10 + "1"*10
io10 = "1"*10 + "0"*10

while oi10 in s or io10 in s:
    while oi10 in s:
        s = s.replace(oi10, "", 1)
        count += 10
    while io10 in s:
        s = s.replace(io10, "", 1)
        count += 10

while "01" in s or "10" in s:
    while "01" in s:
        num = s.count("01")
        s = s.replace("01", "")
        count += num
    while "10" in s:
        num = s.count("10")
        s = s.replace("10", "")
        count += num

print(count * 2)

#!/usr/bin/env python3
import sys
input = sys.stdin.readline

s = input().rstrip()
n = len(s)
zero = s.count("0")
one = s.count("1")
print(n - max(zero, one) + min(zero, one))

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()
a=s.count("1")
b=s.count("2")

print(min(a,b)*2)


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

print(min(a,b))


import collections

s = input()
c = collections.Counter(s)
print(min(c['1'],c['0'])*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()
print(len(s) - 2 * min([sum([v == '1' for v in s]), sum([v == '0' for v in s])]))

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):
# encoding:utf-8
import copy
import numpy as np
import random
import pandas as pd
import torch


s = list(str(input()))

escape = False
begin = len(s)

def rem(s):
    for i in range(1,len(s)):
        # print(s)
        if s[i-1] != s[i]:
            s.pop(i)
            s.pop(i-1)
            break
    return s


for i in range(10**4):
    s = rem(s)

end = len(s)
print(begin-end)


# encoding:utf-8
import copy
import numpy as np
import random

# import torch


s = list(str(input()))


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

ans = 2*min(count[0],count[1])
#
print(ans)

# begin = len(s)
#


#         # print(s)
#         if s[i-1] != s[i]:
#             s.pop(i)
#             s.pop(i-1)
#             break
#     return s
#
#

# proceed = 0
# while proceed != pre:



#
# end = len(s)
# print(begin-end)


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)
c0 = s.count('0')
c1 = s.count('1')
print(2 *min(c0, c1))

s = input()
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=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

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


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

s=S()
l=[s[0]]
ans=0
for i in range(1,len(s)):
    if len(l)==0:
        l.append(s[i])
        continue
    if l[-1]!=s[i]:
        ans+=2
        l.pop()
    else:
        l.append(s[i])
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 -*-
"""
Created on Sun Mar  3 19:52:53 2019

@author: Yamazaki Kenichi
"""
S = input()
print(min(S.count('0'),S.count('1')))

# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 19:52:53 2019

@author: Yamazaki Kenichi
"""
S = input()
print(max(S.count('0'),S.count('1')))

# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 19:52:53 2019

@author: Yamazaki Kenichi
"""
S = input()
print(2*min(S.count('0'),S.count('1')))

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

count = 0

def str_del(str,index):
    str = str[:index]+str[index+1:]
    return str

def remove_cube(string):
  for i in range(0, len(string)):
    print(len(string))
    if i+1 >= len(string):
      return string
    elif string[i] != string[i+1]:
      string = str_del(string, i)
      string = str_del(string, i)
      return string

string = s
can_remove = True
while can_remove:
  removed = remove_cube(string)
  if removed != string:
    string = removed
    count += 2
    can_remove = True
  else:
    can_remove = False

print(count)


s = '11011010001011'

count = 0

def str_del(str,index):
    str = str[:index]+str[index+1:]
    return str

def remove_cube(string):
  new_text = string.replace('10', '', 1)
  if new_text == string:
    new_text = string.replace('01', '', 1)
  return new_text

string = s
can_remove = True
while can_remove:
  removed = remove_cube(string)
  if removed != string:
    string = removed
    count += 2
    can_remove = True
  else:
    can_remove = False

print(count)


s = input()
s = '11011010001011'
 
count = 0
 
def str_del(str,index):
    str = str[:index]+str[index+1:]
    return str
 
def remove_cube(string, count):
  count = string.count('10')
  if count > 0:
    new_text = string.replace('10', '', count)
  count = string.count('01')
  if count > 0:
    new_text = string.replace('01', '', count)
  return new_text
 
string = s
can_remove = True
while can_remove:
  search_count = string.count('10')
  if search_count > 0:
    new_text = string.replace('10', '', search_count)
  else:
    search_count = string.count('01')
    if search_count > 0:
      new_text = string.replace('01', '', search_count)

  if new_text != string:
    string = new_text
    count += search_count * 2
    can_remove = True
  else:
    can_remove = False
 
print(count)


s = input()

count0 = s.count('0')
count1 = s.count('1')
print(min(count0, count1) * 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()
t=1
ans=0
while t!=0:
    t=0
    t+=s.count('01')
    s=s.replace('01','')
    print(s)
    t+=s.count('10')
    s=s.replace('10','')
    ans+=t
print(ans*2)

s=input()
a=s.count('1')
b=s.count('0')
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):
S = list(input())

last = S.pop(0)
stack = [last]
can_pop = True
cnt = 0
for s in S:
    if last != s and can_pop:
        stack.pop()
        can_pop = False
        
        cnt += 2
    else:
        stack.append(s)
        last = s
        can_pop = True

print(cnt)


S = list(input())

one = 0
zero = 0
for s in S:
    if s == "1":
        one += 1
    else:
        zero += 1
print(min(one, zero) * 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 deque
S=input()

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

from collections import deque
S=input()

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

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 fractions

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

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

print(min(count0,count1))


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

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

print(min(count0,count1) * 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 inpl():
    return list(map(int, input().split()))


S = inpu()
print(min(S.count('0'), S.count('1')))

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


S = input()
print(min(S.count('0'), S.count('1')))

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


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):
st = input()
list_s = list(st)

delcount = 0
while True:
    if list_s.count('0') == 0 or list_s.count('1') == 0:
        break
    pre = list_s[0]
    count = 0
    for s in list_s:        
        if (pre == '0' and s == '1') or (pre == '1' and s == '0'):
            del list_s[count-1:count]
            delcount += 1
            break
        count += 1
print(delcount)


st = input()
list_s = []
for s in st:
    list_s.append(s)

delcount = 0
while True:
    if list_s.count('0') == 0 or list_s.count('1') == 0:
        break
    pre = list_s[0]
    count = 0
    for s in list_s:        
        if (pre == '0' and s == '1') or (pre == '1' and s == '0'):
            del list_s[count-1:count]
            delcount += 1
            break
        count += 1
print(delcount)


st = input()
list_s = list(st)

delcount = 0
count_0 = list_s.count('0')
count_1 = list_s.count('1')
if count_0 < count_1:
    print(count_0 * 2)
else:
    print(count_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()
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):
nums=str(input())
arr=list(map(int,nums))
l=len(arr)
a=0
i=0
while i<len(arr)-1:
    if arr[i]!=arr[i+1]:
        del arr[i:i+2]
        #print(arr)
        a+=2
        i=0
    i+=1
print(a)

nums=str(input())
arr=list(map(int,nums))
l=len(arr)
a=0
i=0
while i<len(arr)-1:
    if i<0:
        i=0
    if arr[i]!=arr[i+1]:
        del arr[i:i+2]
        #print(arr)
        a+=2
        i-=2
    i+=1
print(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=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):
#ABC120C-Unification.py

from sys import stdin

input = stdin.readline

S = input()

Nblock = 0

while '0' in S and '1' in S:
    for i in range(len(S)-1):
        if S[i:i+1] != S[i+1:i+2]:
            Nblock += 2
            S = S[:i] + S[i+2:]
            print(S)
            break

print(Nblock)


#ABC120C-Unification.py

from sys import stdin

input = stdin.readline

S = input().rstrip()

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

print(Nblock*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()
o = len(s)
while True:
  len(s) = b
  s.replace('00','')
  s.replace('11','')
  if(len(s) == b):
    break
print(o - len(s))

s = input()
z = s.count('0')
if 2*z > len(s):
  print((len(s)-z)*2)
else:
  print(2*z)

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 resolve():
    S = int(input())
    zeros = S.count("0")
    print(min(zeros, len(zeros)*2)

if '__main__' == __name__:
    resolve()

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

if '__main__' == __name__:
    resolve()

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 for s in S]

ans = 0
while len(S) > 0:
    counter = 0
    for ix in range(len(S)):
        if ix+1 < len(S):
            if S[ix] != S[ix+1]:
                print(S)
                del S[ix]
                del S[ix]
                ans += 1
                counter += 1
                break
    if counter == 0:
        break

print(ans*2)


S = input()

S = [s for s in S]

ans = 0
while len(S) > 0:
    counter = 0
    for ix in range(len(S)):
        if ix+1 < len(S):
            if S[ix] != S[ix+1]:
                print(S)
                del S[ix]
                del S[ix]
                ans += 1
                counter += 1
    if counter == 0:
        break

print(ans*2)


S = input()

S = [s for s in S]
S = [int(s, 0) for s in S]
S.sort()
if 1 in S and  0 in S:
    print(min(S.count(0)*2,S.count(1)*2))
else:
    print(0)

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 = list(input())
N = len(S)
while(1):
    Q = []
    for i in range(len(S)-1):
        if S[i]!=S[i+1]:
            i += 1
        else:
            Q.append(S[i])
    Q.append(S[-1])
    if S == Q:
        break
    S = Q 
    #print(S)
print(N-len(S))
    


S = list(input())
N = len(S)
print(N-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()
List = list(S)
zeroNum = List.count("0")
oneNum = List.count("1")
res = min(reroNum,oneNum)
print(res*2)

S=input()
List = list(S)
zeroNum = List.count("0")
oneNum = List.count("1")
res = min(zeroNum,oneNum)
print(res*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):
N = int(input())
S = input()
zero = S.count('0')
one = S.count('1')
print(min(zero,one)*2)

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

import sys

#S =input().strip()
*S, = input() 
count =0
flag =1
while len(S) >=2 and flag==1:
    flag =0
    l =len(S)
    for i in range(l -1):
        if S[i:i+2] ==["1","0"] or S[i:i+2] ==["0","1"]:
            #print(S[i:i+2])
            del S[i:i+2]
            print(S,end=" ")
            count +=2
            flag =1
            #break
    #print()
print(count)



import sys

#*S, = input() 
S =input().strip()
c1 =S.count("1")
c0 =S.count("0")
print(min(c0,c1)*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):
istr=input()
for ch in istr:
  if ch == '0':
    c0+=1
  else:
    c1+=1
print(min(c0,c1)*2)
      

istr=input()
c0=0
c1=0
for ch in istr:
    if ch == '0':
        c0+=1
    else:
        c1+=1
print(min(c0,c1)*2)

Verdicts: Runtime Error

Accepted