Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
result = [0] * N

for i in range(N):
    s = list(map(int, input().split()))
    K = s[0]
    A = s[1:]
    for j in range(K):
        result[A[j]-1] = result[A[j]-1] + 1

print(result.count(N))


Fixed submission:
N, M = map(int, input().split())
result = [0] * M

for i in range(N):
    s = list(map(int, input().split()))
    K = s[0]
    A = s[1:]
    for j in range(K):
        result[A[j]-1] = result[A[j]-1] + 1

print(result.count(N))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
result = [0] * N

for i in range(N):
    K, A = list(map(int, input().split()))
    K = s[0]
    A = s[1:]
    for j in range(K):
        result[A[j]-1] = result[A[j]-1] + 1

print(result.count(N))


Fixed submission:
N, M = map(int, input().split())
result = [0] * M

for i in range(N):
    s = list(map(int, input().split()))
    K = s[0]
    A = s[1:]
    for j in range(K):
        result[A[j]-1] = result[A[j]-1] + 1

print(result.count(N))
Buggy python submission (verdict: Runtime Error):
D = int(input())

if D == 22:
    print("Christmas Eve Eve Eve")
else if D == 23:
    print("Christmas Eve Eve")
else if D == 24:
    print("Christmas Eve")
else if D == 25:
    print("Christmas")

Fixed submission:
D = int(input())

if D == 22:
    print("Christmas Eve Eve Eve")
elif D == 23:
    print("Christmas Eve Eve")
elif D == 24:
    print("Christmas Eve")
elif D == 25:
    print("Christmas")
Buggy python submission (verdict: Runtime Error):
s=list(int(input()))
t=list(int(input()))
count = 0
for i in range(len(s)):
  if s[i] == t[i]:
    count += 1
print(int(count))

Fixed submission:
s=list(input())
t=list(input())
count = 0
for i in range(len(s)):
  if s[i] == t[i]:
    count += 1
print(int(count))
Buggy python submission (verdict: Runtime Error):
k = int(input())
x = int(input())
li = [str(x-k+1+i) for i in range(2*k-1)]
l = ' '.join(li)
print(l)

Fixed submission:
k,x = map(int,input().split())	
li = [str(x-k+1+i) for i in range(2*k-1)]
l = ' '.join(li)
print(l)

Buggy python submission (verdict: Runtime Error):
k = int(input())
x = int(input())
li = [str(x-k+1+i) for i in range(2*k-1)]
l = ' '.join(li)
print(int(l))

Fixed submission:
k,x = map(int,input().split())	
li = [str(x-k+1+i) for i in range(2*k-1)]
l = ' '.join(li)
print(l)

Buggy python submission (verdict: Runtime Error):
k = int(input())
x = int(input())
li = [str(x-k+1+i) for i in range(2*k-1)]
l = ' '.join(li)
print(l)

Fixed submission:
k,x = map(int,input().split())	
li = [str(x-k+1+i) for i in range(2*k-1)]
l = ' '.join(li)
print(l)

Buggy python submission (verdict: Runtime Error):
k = int(input())
x = int(input())
li = [str(2*k-1+i) for i in range(2*k-1)]
l = ' '.join(li)
print(l)

Fixed submission:
k,x = map(int,input().split())	
li = [str(x-k+1+i) for i in range(2*k-1)]
l = ' '.join(li)
print(l)
Buggy python submission (verdict: Runtime Error):
N,D = map(int,input().split())
a = N%(2*D+1)
b = N//(2*D+1)
if a=0:
  print(int(b))
else:
  print(int(b+1))


Fixed submission:
N,D = map(int,input().split())
a = N%(2*D+1)
b = N//(2*D+1)
if a==0:
  print(int(b))
else:
  print(int(b+1))

Buggy python submission (verdict: Runtime Error):
N,D = map(int,input().split())
a = N%(2*D+1)
b = N//(2*D+1)
if a=0:
  print(b)
else:
  print(int(b+1))


Fixed submission:
N,D = map(int,input().split())
a = N%(2*D+1)
b = N//(2*D+1)
if a==0:
  print(int(b))
else:
  print(int(b+1))
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())	
if n*a=<b:
  print(int(n*a))
else:
  print(b)

Fixed submission:
n,a,b = map(int,input().split())	
if n*a<=b:
  print(int(n*a))
else:
  print(b)
Buggy python submission (verdict: Runtime Error):
a=int(input())
li = list(map(int,input().split()))	
count = 0
for i in range(1:a):
  if li[i-1]<li[i] and li[i]<li[i+1]:
    count += 1
  else:
    pass
print(count)

Fixed submission:
a=int(input())
li = list(map(int,input().split()))	
count = 0
for i in range(1,a-1):
  if li[i-1]<li[i] and li[i]<li[i+1]:
    count += 1
  elif li[i-1]>li[i] and li[i]>li[i+1]:
    count += 1
  else:
    pass
print(count)
Buggy python submission (verdict: Runtime Error):
x = list[map(int,input().split())]
b = sum(x)-max(x)
print(b)

Fixed submission:
x = list(map(int,input().split()))
b = sum(x)-max(x)
print(b)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = list(map(int, input().split()))

result = []
for i in range(2, n-1):
    a1, a2 = list[0], list[i-1]
    i1, i2 = 1, i-1
    while i1 < i2:
        if a1 < a2:
            a1 += list[i1]
            i1 += 1
        else:
            a2 += list[i2 - 1]
            i2 -= 1
    b1, b2 = list[i], list[n-1]
    i1, i2 = i + 1, n - 1
    while i1 < i2:
        if b1 < b2:
            b1 += list[i1]
            i1 += 1
        else:
            b2 += list[i2 - 1]
            i2 -= 1
    result.append(max(a1,a2,b1,b2)-min(a1,a2,b1,b2))
print(min(result))

Fixed submission:
import bisect

n = int(input())
list = list(map(int, input().split()))
sum = [0] * (n + 1)
for i in range(1, n+1):
    sum[i] = sum[i-1] + list[i-1]
result = []
for i in range(3, n):
    half1 = sum[i-1] // 2
    i1 = bisect.bisect_right(sum, half1)
    if (half1 - sum[i1 - 1]) < sum[i1] - half1:
        a1 = sum[i1 - 1]
        a2 = sum[i-1] - sum[i1 - 1]
    else:
        a1 = sum[i1]
        a2 = sum[i-1] - sum[i1]
    
    
    half2 = (sum[n] + sum[i-1]) // 2
    i2 = bisect.bisect_right(sum, half2)
    if (half2 - sum[i2 - 1]) < sum[i2] - half2:
        a3 = sum[i2 - 1] - sum[i-1]
        a4 = sum[n] - sum[i2 - 1]
    else:
        a3 = sum[i2] - sum[i-1]
        a4 = sum[n] - sum[i2]
    result.append(max(a1,a2,a3,a4) - min(a1,a2,a3,a4))
print(min(result))
Buggy python submission (verdict: Runtime Error):
n, a, b, k = map(int, input().split())
MOD = 998244353

inv = [0] * ( n + 1)
inv[1] = 1
for i in range(2, n + 1):
    inv[i] = (-(MOD // i) * inv[MOD % i]) % MOD

nCr = [0] * ( n + 1)
nCr[0] = 1
for i in range(1, n+1):
    nCr[i] = nCr[i-1] * (n - i + 1) * inv[i] % MOD

result = 0
maxA = min(n, k//a)
for i in range(maxA):
    if ( k - a * i) % b == 0:
        j = ( k - a * i) // b
        result += nCr[i] * nCr[j] % MOD
if result == 0:
    print(1)
else:
    print(result % MOD)

Fixed submission:
n, a, b, k = map(int, input().split())
MOD = 998244353

a_max =  min(k // a, n) + 1
pair = []
for i in range(a_max):
    if (k - a * i) % b == 0:
        j = (k - a * i) // b
        if j <= n:
            pair.append([i % MOD,j % MOD])

inv = [0] * (n + 1)
inv[1] = 1
for i in range(2, n + 1):
    inv[i] = (-(MOD // i) * inv[MOD % i]) % MOD

nCr = [0] * (n + 1)
nCr[0] = 1
for r in range(1, n + 1):
    nCr[r] = (nCr[r - 1] * (n - r + 1) * inv[r]) % MOD

result = 0
for p in pair:
    result += (nCr[p[0]] % MOD) * (nCr[p[1]] % MOD)

if result == 0:
    print(1)
else:
    print(result % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [-1]
for _ in range(n):
    A.append(int(input()))

X = [0]*(n+1)
count = 0
if A[1] != 0:
    print(-1)
else:
    for i in range(n,0,-1):
        if A[i] > X[i]:
            for j in range(A[i]):
                X[i-j] = A[i] - j
            count += A[i]
        elif A[i] < X[i]:
            print(-1)
            break
    else:
        print(count)
    

Fixed submission:
n = int(input())
A = [-1]
for _ in range(n):
    A.append(int(input()))

num = 0
count = 0
if A[1] != 0:
    print(-1)
else:
    for i in range(n,0,-1):
        if A[i] > num:
            num = A[i]
            count += num
        elif A[i] < num:
            print(-1)
            break
        num -= 1
    else:
        print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [[c for c in input()] for _ in range(n)]

def chechTable(A, Shift):
    for i in range(n):
        for j in range(i):
            i_shift = i + Shift if i + Shift < n else i + Shift - n
            j_shift = j + Shift if j + Shift < n else j + Shift - n
            
            if A[i_shift][j] != A[j_shift][i]:
                return False
    return True

count = 0
for i in range(n):
    if chechTable(A, i):
        count += 1
print(count * n)

Fixed submission:
n = int(input())
A = [input() for _ in range(n)]
A_t = [''] * n
for c in A:
    for i in range(n):
        A_t[i] += c[i]

def checkTable(shift):
    for i in range(n):
        if A_t[(i + shift) % n] != A[i][shift:] + A[i][:shift]:
            return False
    return True

count = 0
for i in range(n):
    if checkTable(i):
        count += 1
print(count * n)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = input().split()#List of Str
A.append("0")

def goWithoutNum( num):
    pos = 0
    result = 0
    for i in range(N + 1):
        if i != num:
            result += abs( int( A[i]) - pos)
            pos = int(A[i])
    print( result)

for i in range(N):
    goWithoutNum(i)

Fixed submission:
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
B = [abs(A[i] - A[i-1]) for i in range(N+2)]
allPath = sum(B)

def diffWithoutNum( num):
    return B[num + 1] + B[num] - abs(A[i + 1] -A[i - 1])

for i in range( 1, N + 1):
    print( allPath - diffWithoutNum(i))
Buggy python submission (verdict: Runtime Error):
x, y = input().split()
a = {'A':10, 'B':11, 'C':12, 'D':13, 'E':14, 'D':15}
if a[x] < a[y]:
    print('<')
elif a[x] > a[y]:
    print('>')
else:
    print('=')

Fixed submission:
x, y = input().split()
a = {'A':10, 'B':11, 'C':12, 'D':13, 'E':14, 'F':15}
if a[x] < a[y]:
    print('<')
elif a[x] > a[y]:
    print('>')
else:
    print('=')
Buggy python submission (verdict: Runtime Error):
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

Hn = [abs(A - (T - i * 0.006)) for i in H]
print(Hn.index(min(Hn)) + 1)
N = int(input())

Fixed submission:
N = int(input())
T,A = map(int, input().split())
H = list(map(int, input().split()))

Hn = [abs(A - (T - i * 0.006)) for i in H]
print(Hn.index(min(Hn)) + 1)
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N=10*i for i in range(1,5+1):
    print("10")
else
    print(sum(int(str(N)))

Fixed submission:
N = int(input())
a = 0

for i in str(N):
    a += int(i)
if a == 1:
    print(10)
else:
    print(a)
Buggy python submission (verdict: Runtime Error):
A,B,C,X,Y = map(int,input().split())
a = 0

if A+B < C*2:
    a += (A+B) * min(X,Y)
else
    a += C*2 * min(X,Y)
if X > Y:
    a += min(A,C*2)*(X-Y)
else:
    a += min(B,C*2)*(Y-X)
print(a)

Fixed submission:
A,B,C,X,Y = map(int,input().split())
a = 0

if A + B < C * 2:
    a += (A + B) * min(X, Y)
else:
    a += 2 * C * min(X, Y)

if X > Y:
    a += min(A, C * 2) * (X - Y)
else:
    a += min(B, C * 2) * (Y - X)
        
print(a)
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
a = 0

for i in range(A,B+1):
    if i[1:2] = i[4:5]:
        a += 1
print("a")

Fixed submission:
A,B = map(int,input().split())
C = 0

for i in range(A,B+1):
    if str(i) == str(i)[::-1]:
        C += 1
print(C)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if a * b % 2 == 0:
	print('even')
else:
	print('odd')


Fixed submission:
a, b = map(int, input().split())

if a * b % 2 == 0:
    print('Even')
else:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if a * b % 2 = 0:
	print('even')
else:
	print('odd')


Fixed submission:
a, b = map(int, input().split())

if a * b % 2 == 0:
    print('Even')
else:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()

c = a * b

if c % 2 = 0:
	print('even')
else:
	print('odd')


Fixed submission:
a, b = map(int, input().split())

if a * b % 2 == 0:
    print('Even')
else:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()

if (a * b) % 2 == 0:
	print('even')
else:
	print('odd')


Fixed submission:
a, b = map(int, input().split())

if a * b % 2 == 0:
    print('Even')
else:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()

if a * b % 2 == 0:
	print('even')
else:
	print('odd')


Fixed submission:
a, b = map(int, input().split())

if a * b % 2 == 0:
    print('Even')
else:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()

if a * b % 2 == 0:
	print("even")
else:
	print("odd")


Fixed submission:
a, b = map(int, input().split())

if a * b % 2 == 0:
    print('Even')
else:
    print('Odd')
Buggy python submission (verdict: Runtime Error):
a,b = map(open(0).read().split())

print(int(-(-(a + b) // 2)))

Fixed submission:
a,b = map(int, input().split())

if (a + b) % 2 == 0:
    print((a + b) // 2)
else:
    print((a + b) // 2 + 1)
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N % sum(str(N)) == 0:
    print("Yes")
else:
    print("No")

Fixed submission:
N = int(input())

if N % sum(map(int,str(N))) == 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
print(input[::2])

Fixed submission:
s = input()

print(s[::2])
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N == 1:
  print('Hello World')
else:
  A = int(imput())
  B = int(imput())
  print(A + B)

Fixed submission:
N = int(input())

if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A + B)

Buggy python submission (verdict: Runtime Error):
N = int(input())

if N == 1:
  print('Hello World')

else:
  A = int(imput())
  B = int(imput())
  print(A + B)

Fixed submission:
N = int(input())

if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A + B)

Buggy python submission (verdict: Runtime Error):
N = int(input())

if N == 1:
  print('Hello World')

else:
  A = int(imput())
  B = int(imput())
  
  print(A + B)

Fixed submission:
N = int(input())

if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A + B)
Buggy python submission (verdict: Runtime Error):
from collections import deque

N=int(input())
AB=[list(map(int,input().split())) for _ in range(N-1)]
C=deque(sorted(map(int,input().split())))
edges=[[] for _ in range(N)]
for a,b in AB:
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

ps=[0]*N

def dfs(prev, curr):
    ps[curr]=C.pop()
    for dst in edges[curr]:
        if prev==dst:
            continue
        dfs(curr,dst)
dfs(-1,0)

ans=0
for a,b in AB:
    ans += min(ps[a-1],ps[b-1])

print(ans)
print(" ".join([str(p) for p in ps]))


Fixed submission:
from collections import deque
import sys
sys.setrecursionlimit(100000)

N=int(input())
AB=[list(map(int,input().split())) for _ in range(N-1)]
C=deque(sorted(map(int,input().split())))
edges=[[] for _ in range(N)]
for a,b in AB:
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

ps=[0]*N

def dfs(prev, curr):
    ps[curr]=C.pop()
    for dst in edges[curr]:
        if prev==dst:
            continue
        dfs(curr,dst)
dfs(-1,0)

ans=0
for a,b in AB:
    ans += min(ps[a-1],ps[b-1])

print(ans)
print(" ".join([str(p) for p in ps]))
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heapify, heapreplace
N,M=[int(a) for a in input().split()]
A=[int(a) for a in input().split()]
BC=[[int(a) for a in input().split()] for _ in range(M)]
heapify(A)
for B,C in BC:
    for _ in range(B):
        if C<=A[0]:
            break
        heapreplace(A, C)
print(sum(A))

Fixed submission:
from heapq import heapify, heapreplace
N,M=[int(a) for a in input().split()]
A=sorted([int(a) for a in input().split()])
BC=[[int(a) for a in input().split()] for _ in range(M)]
B,C=zip(*sorted(BC, key=lambda row: row[1], reverse=True))
i,j=0,0
for k in range(N):
    if j>=B[i]:
        i+=1
        j=0
    if i>=M or A[k]>= C[i]:
        break
    A[k] = C[i];
    j+=1
print(sum(A))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

N=int(input())
edges = [[] for i in range(N)]
colors = [-1]*N
for i in range(N-1):
    u,v,w=[int(a) for a in input().split()]
    edges[u-1].append((v-1,w))
    edges[v-1].append((u-1,w))
 
diff = lambda n: 1 if n==0 else 0
 
def dfs(prev,curr):
    for node,d in edges[curr]:
        if node==prev:
            continue
        colors[node] = colors[curr] if d%2==0 else diff(colors[curr])
        dfs(curr,node)
 
colors[0]=0
dfs(1000000,0)
for i in range(N):
    print(colors[i])


Fixed submission:
N,K=[int(a) for a in input().split()]
S=input()
print(S[:K-1]+{"A":"a","B":"b","C":"c"}[S[K-1]]+S[K:])
Buggy python submission (verdict: Runtime Error):
N=int(input())
edges = [[] for i in range(N)]
colors = [-1]*N
for i in range(N-1):
    u,v,w=[int(a) for a in input().split()]
    edges[u-1].append((v-1,w))
    edges[v-1].append((u-1,w))

diff = lambda n: 1 if n==0 else 0

def dfs(prev,curr):
    for node,d in edges[curr]:
        if node==prev:
            continue
        colors[node] = colors[curr] if d%2==0 else diff(colors[curr])
        dfs(curr,node)

colors[0]=0
dfs(1000000,0)
for i in range(N):
    print(colors[i])


Fixed submission:
import sys
sys.setrecursionlimit(100000)

N=int(input())
edges = [[] for i in range(N)]
colors = [-1]*N
for i in range(N-1):
    u,v,w=[int(a) for a in input().split()]
    edges[u-1].append((v-1,w))
    edges[v-1].append((u-1,w))
 
diff = lambda n: 1 if n==0 else 0
 
def dfs(prev,curr):
    for node,d in edges[curr]:
        if node==prev:
            continue
        colors[node] = colors[curr] if d%2==0 else diff(colors[curr])
        dfs(curr,node)
 
colors[0]=0
dfs(1000000,0)
for i in range(N):
    print(colors[i])
Buggy python submission (verdict: Runtime Error):
from functools import reduce
from fractions import gcd

N = int(input())
A = [int(a) for a in input().split(" ")]
if N==2:
    print(gcd(*A))
else:
    left = reduce(lambda acc, x: acc+[gcd(x, acc[-1])], A, A[:1])
    right = reduce(lambda acc, x: acc+[gcd(x, acc[-1])], A[::-1], A[-1:])[::-1]

    ans = max([gcd(left[i-1], right[i+1]) for i in range(1,N-1)])
    ans = max([right[1], ans, left[-2]])
    print(ans)


Fixed submission:
A, B,  T = [int(s) for s in input().split()]
print(B*(T//A))

Buggy python submission (verdict: Runtime Error):
from functools import reduce
from math import gcd

N = int(input())
A = [int(a) for a in input().split(" ")]
if N==2:
    print(gcd(*A))
else:
    left = reduce(lambda acc, x: acc+[gcd(x, acc[-1])], A, A[:1])
    right = reduce(lambda acc, x: acc+[gcd(x, acc[-1])], A[::-1], A[-1:])[::-1]

    ans = max([gcd(left[i-1], right[i+1]) for i in range(1,N-1)])
    ans = max([right[1], ans, left[-2]])
    print(ans)


Fixed submission:
A, B,  T = [int(s) for s in input().split()]
print(B*(T//A))
Buggy python submission (verdict: Runtime Error):
from math import *
num_digit = lambda n: int(log2(n)+1)    
A, B = [int(s) for s in input().split()]

ret = 0
N = (B-A)+1
nd = num_digit(B)
for i in range(nd):
    nb = int(pow(2, i+1) if i>0 else pow(2, i+2))
    nr = N%nb
    s = sum([(A+j) >> i for j in range(nr)])
    ret += ((s%2) << i)
    
print(ret)

Fixed submission:
H, W = [int(s) for s in input().split()]
h, w = [int(s) for s in input().split()]
print((H-h)*(W-w))
Buggy python submission (verdict: Runtime Error):
def find(tab, a):
    try:
        if tab[0][a]==-1:
            return a
        tab[0][a] = find(tab, tab[0][a])
        return tab[0][a]
    except:
        pass

def union(tab, a, b):
    p1, p2 = find(tab, a), find(tab, b)
    if p1 != p2:
        tab[0][p1] = p2
        tab[1][p2] += tab[1][p1]

def size(tab, a):
    return tab[1][a]

N, M = [int(a) for a in input().split(" ")]
ABs = [[int(a) for a in input().split(" ")] for i in range(M)]
tab = [[-1]*N, [1]*N]
arr = []



for a, b in reversed(ABs):
    a, b = a-1, b-1
    pa, pb = find(tab, a), find(tab, b)
    na, nb = size(tab, pa), size(tab, pb)
    if pa!=pb:
        dn = ((na+nb)*(na+nb-1)//2)-(na*(na-1)//2)-(nb*(nb-1)//2)
        arr.append(dn)
        union(tab, a, b)
    else:
        arr.append(0)

acc = 0
for cp in reversed(arr):
    acc += cp
    print(acc)


Fixed submission:
A, B, C = [int(a) for a in input().split()]
print(min(C, B//A))
Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
i, ans = (0, 0)
while i>=0 and i<len(S)-1:
    if S[i]!=S[i+1]:
        S = S[:i]+S[i+2:] if i+2<len(S) else S[:i]
        ans += 2
        i = max(0, i-1)
    else:
        i+=1
print(ans)


Fixed submission:
from collections import deque
sin = input()
queue = deque(maxlen=len(sin))
for s in sin:
    if len(queue)>0 and queue[-1] != s:
        queue.pop()
    else:
        queue.append(s)
#print("".join(arr))
print(len(sin)-len(queue))

Buggy python submission (verdict: Runtime Error):
S = str(input())
i, ans = (0, 0)
while i>=0 and i<len(S)-1:
    print(S)
    if S[i]!=S[i+1]:
        S = S[:i]+S[i+2:] if i+2<len(S) else S[:i]
        ans += 2
        i = max(0, i-1)
    else:
        i+=1
print(ans)


Fixed submission:
from collections import deque
sin = input()
queue = deque(maxlen=len(sin))
for s in sin:
    if len(queue)>0 and queue[-1] != s:
        queue.pop()
    else:
        queue.append(s)
#print("".join(arr))
print(len(sin)-len(queue))

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
i, ans = (0, 0)
while i<len(S)-1:
    if S[i]!=S[i+1]:
        S = S[:i]+S[i+2:] if i+2<len(S) else S[:i]
        ans += 2
        i-=1
    else:
        i+=1
print(ans)

Fixed submission:
from collections import deque
sin = input()
queue = deque(maxlen=len(sin))
for s in sin:
    if len(queue)>0 and queue[-1] != s:
        queue.pop()
    else:
        queue.append(s)
#print("".join(arr))
print(len(sin)-len(queue))

Buggy python submission (verdict: Runtime Error):
sin = input()
queue = deque(maxlen=len(sin))
for s in sin:
    if len(queue)>0 and queue[-1] != s:
        queue.pop()
    else:
        queue.append(s)
#print("".join(arr))
print(len(sin)-len(queue))

Fixed submission:
from collections import deque
sin = input()
queue = deque(maxlen=len(sin))
for s in sin:
    if len(queue)>0 and queue[-1] != s:
        queue.pop()
    else:
        queue.append(s)
#print("".join(arr))
print(len(sin)-len(queue))

Buggy python submission (verdict: Time Limit Exceeded):
sin = input()
arr = []
for s in sin:
    if len(arr)>0 and arr[-1] != s:
        arr = arr[:-1]
    else:
        arr.append(s)
print(len(sin)-len(arr))

Fixed submission:
from collections import deque
sin = input()
queue = deque(maxlen=len(sin))
for s in sin:
    if len(queue)>0 and queue[-1] != s:
        queue.pop()
    else:
        queue.append(s)
#print("".join(arr))
print(len(sin)-len(queue))