Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
numbers = range(1,N+1)
import re
ans = 0
for number in numbers: 
    digits = list(str(number))
    if re.match("^(3|5|7)+$",str(number)) and all(x in digits for x in ['3','5','7']):
        ans += 1
print(ans)

Fixed submission:
nums = ['7','5','3']
N = input()
Max_digit = len(N)

def generator(n, nums):
    """
    return n-digit number in strings that are made out of numbers in nums and each one use precisely once
    """
    ans = [x for x in nums]
    
    for idx in range(1,n):
        new_ans = []
        for n1 in ans:
            for n2 in nums:
                new_ans.append(n1 + n2)
        ans = new_ans.copy()
    
    return [x for x in ans if all(num in x for num in nums)]

if Max_digit < 3:
    print(0)
if Max_digit == 3:
    ans = generator(3,nums)
    print(len([x for x in ans if int(x) <= int(N)]))
if Max_digit > 3:
    # count the number of eligible numbers which has less digits than N
    counter = 0
    for d in range(3, Max_digit):
        counter += len(generator(d,nums))
    # count the number of eligible numbers of the same digits as N and equal or less than N
    ans = generator(Max_digit, nums)
    counter += len([x for x in ans if int(x) <= int(N)])
    print(counter)
Buggy python submission (verdict: Runtime Error):
N = int(input())
T, A = map(int, input().split())
s = [abs(A - (T - 0.006 * x)) for x in map(int, input().split())]
print(s.index(min(s) + 1))

Fixed submission:
N = int(input())
T, A = map(int, input().split())
s = [abs(A - (T - 0.006 * x)) for x in map(int, input().split())]
print(s.index(min(s))+1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
points = [tuple(map(int, input().split())) for i in range(N)]
points = [(0,0,0)] + points
for idx in range(1,N):
  time_diff = points[idx][0] - points[idx-1][0]
  x_diff = abs(points[idx][1] - points[idx-1][1])
  y_diff = abs(points[idx][2] - points[idx-1][2])
  
  if time_diff < x_diff + y_diff or (time_diff - x_diff - y_diff) % 2 == 1:
    print('No')
    exit()
    
print('Yes')

Fixed submission:
A,B = map(int, input().split())
if A * B % 2 == 0:
  print('Even')
else:
  print('Odd')
Buggy python submission (verdict: Runtime Error):
N = int(input())
numbers = [x for x in map(int, input().split())]
count = 0
on = True
while on:
  val = [x % 2 == 0 for x in numbers]
  if False in val:
    print(count)
    break
  else:
    numbers = [x//2 for x in numbers]
    count += 1

Fixed submission:
print(input().count('1'))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

result = []
for _ in range(n):
  result.append(-1)

for _ in range(m):
  s, c = map(int, input().split())
  if result[s-1] not in [-1, c]:
    print(-1)
    exit()
  elif s == 1 and c == 0:
    print(-1)
    exit()
  else:
    result[s-1] = c

for _ in range(len(result)):
  if result[_] == -1:
    result[_] = 1
  
result = map(str, result)
result = "".join(result)
  
print(result)
  

Fixed submission:
a = int(input())

b = int(a/2)

if b < a / 2:
  b = b + 1
 
print(b)

Buggy python submission (verdict: Runtime Error):
a11, a12, a13 = map(int, input().split())
a21, a22, a23 = map(int, input().split())
a31, a32, a33 = map(int, input().split())
N = int(input())
num = []
for _ in range(N):
  num.append(int(input()))
  
bingo = [
  [a11, a12, a13], 
  [a21, a22, a23], 
  [a31, a32, a33]
]
 
for n in range(3):
  for m in range(3): 
    if bingo[n][m] in num:
      bingo[n][m] = 0

row1 = bingo[0][0] + bingo[0][1] + bingo[0][2]
row2 = bingo[1][0] + bingo[1][1] + bingo[1][2]
row3 = bingo[2][0] + bingo[2][1] + bingo[2][2]
 
col1 = bingo[0][0] + bingo[1][0] + bingo[2][0]
col2 = bingo[0][1] + bingo[1][1] + bingo[2][1]
col3 = bingo[0][2] + bingo[1][2] + bingo[2][2]
 
cross1 = bingo[0][0] + bingo[1][1] + bingo[2][2]
cross2 = bingo[2][0] + bingo[1][1] + bingo[2][0]
 
if 0 in [row1, row2, row3, col1, col2, col3, cross1, cross2]:
  print("Yes")
else:
  print("No")

Fixed submission:
a = int(input())

b = int(a/2)

if b < a / 2:
  b = b + 1
 
print(b)

Buggy python submission (verdict: Runtime Error):
a11, a12, a13 = map(int, input().split())
a21, a22, a23 = map(int, input().split())
a31, a32, a33 = map(int, input().split())
N = int(input())
num = []
for _ in range(N):
  num.append(int(input()))
  
bingo = [
  [a11, a12, a13], 
  [a21, a22, a23], 
  [a31, a32, a33]
]

for n in range(3):
  for m in range(3): 
    if bingo[n][m] in num:
      bingo[n][m] = 0

row1 = bingo[0][0] + bingo[0][1] + bingo[0][2]
row2 = bingo[1][0] + bingo[1][1] + bingo[1][2]
row3 = bingo[2][0] + bingo[2][1] + bingo[2][2]

col1 = bingo[0][0] + bingo[1][0] + bingo[2][0]
col2 = bingo[0][1] + bingo[1][1] + bingo[2][1]
col3 = bingo[0][2] + bingo[1][2] + bingo[2][2]

cross1 = bingo[0][0] + bingo[1][1] + bingo[2][2]
cross2 = bingo[2][0] + bingo[1][1] + bingo[2][0]

if 0 in [row1, row2, row3, col1, col2, col3, cross1, cross2]:
  print("Yes")
else:
  print("No")



Fixed submission:
a = int(input())

b = int(a/2)

if b < a / 2:
  b = b + 1
 
print(b)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import sys
A = []
A.append(map(int, raw_input().split()))
A.append(map(int, raw_input().split()))
A.append(map(int, raw_input().split()))

a = [[0,0,0],[0,0,0],[0,0,0]]

N = int(raw_input())
for i in range(N):
    b = int(raw_input())
    for j in range(3):
        if b in A[j]:
            a[j][A[j].index(b)] = 1

if 0 not in a[0]:
    print 'Yes'    
    sys.exit()
if 0 not in a[1]:
    print 'Yes'
    sys.exit()
if 0 not in a[2]:
	print 'Yes'
    sys.exit()
if a[0][0]*a[1][0]*a[2][0] == 1:
    print 'Yes'
    sys.exit()
if a[0][1]*a[1][1]*a[2][1] == 1:
    print 'Yes'
    sys.exit()
if a[0][2]*a[1][2]*a[2][2] == 1:
    print 'Yes'
    sys.exit()

if a[0][0]*a[1][1]*a[2][2] == 1:
    print 'Yes'
    sys.exit()
if a[0][2]*a[1][1]*a[2][0] == 1:
    print 'Yes'
    sys.exit()

Fixed submission:
# coding: utf-8
import sys

A = []
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))

a = [[0,0,0],[0,0,0],[0,0,0]]

N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        if b in A[j]:
            a[j][A[j].index(b)] = 1

flag = False

for i in range(3):
    if 0 not in a[i]: flag = True
    if a[0][i]*a[1][i]*a[2][i] == 1: flag = True
    
if a[0][0]*a[1][1]*a[2][2] == 1: flag = True
if a[0][2]*a[1][1]*a[2][0] == 1: flag = True

print('Yes') if flag == True else print('No')
Buggy python submission (verdict: Runtime Error):
 coding: utf-8

N, M = list(map(int, input().split()))
begin = 0 if N == 1 else 10**(N-1)

sc = [[i for i in map(int, input().split())] for j in range(M)]

for i in range(begin, 10**N):
    flag = True
    for j in range(M):
        if str(i)[sc[j][0]-1] != str(sc[j][1]):
            flag = False
            break

    if flag == True:
        print(i)
        break

if flag == False: print(-1)

Fixed submission:
# coding: utf-8

N, M = list(map(int, input().split()))
begin = 0 if N == 1 else 10**(N-1)

sc = [[i for i in map(int, input().split())] for j in range(M)]

for i in range(begin, 10**N):
    flag = True
    for j in range(M):
        if str(i)[sc[j][0]-1] != str(sc[j][1]):
            flag = False
            break

    if flag == True:
        print(i)
        break

if flag == False: print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
put = []
stor = {}
i=0
while i<num :
    name = input()
    if name in stor.keys():
        stor[name] += 1
    else:
        stor[name] = 1
    i += 1
keyAll = list(stor.keys())
valueAll = list(stor.values())


for i in range(0,len(keyAll)):
    flag = 0
    flag2 = 0
    if i==len(keyAll)-1:
        put.append(keyAll[i])
        break

    for j in range(i+1,len(keyAll)):
        if valueAll[i]<valueAll[j]:
            flag = 1
            break
        if valueAll[i]==valueAll[j]:
            flag2 = 1#存在相等的
    if flag == 0:
        put.append(keyAll[i])
        if flag2==0:
            break
put.sort()
for i in put:
    print(i)


Fixed submission:
num = int(input())

put = []
stor = {}
i=0
while i<num :
    name = input()
    if name in stor.keys():
        stor[name] += 1
    else:
        stor[name] = 1
    i += 1

stor=sorted(stor.items(), key=lambda item:item[1], reverse=True)

m = stor[0][1]

for i in range(0,len(stor)):
    if stor[i][1]==m:
        put.append(stor[i][0])
    else:
        break
put.sort()

for i in put:
    print(i)
Buggy python submission (verdict: Runtime Error):
-*- coding: utf-8 -*-
  
n = input()

if n%2 == 0:
  print(n/2)
else:
  print((n+1)/2)

Fixed submission:
n = int(input())

if n%2:
  print((n+1)//2)
else:
  print(n//2)

Buggy python submission (verdict: Runtime Error):
n = input()

if n%2 == 0:
  print(n/2)
else:
  print((n+1)/2)

Fixed submission:
n = int(input())

if n%2:
  print((n+1)//2)
else:
  print(n//2)

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

if N%2 == 0:
  print(N/2)
else:
  print((N+1)/2)

Fixed submission:
n = int(input())

if n%2:
  print((n+1)//2)
else:
  print(n//2)
Buggy python submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline

N = int(input())
x = []
y = []

for i in range(N):
    p, q = map(int, input().split())
    x.append(p)
    y.append(q)

ans = 0

for i in range(N):
    for j in range(N):
        if i == j:
            continue
#        print ("i="+str(i)+", j="+str(j))
#        print ("xi="+str(x[i])+", xj="+str(x[j]))
#        print ("yi="+str(y[i])+", yj="+str(y[j]))
        ans += math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)

ans = ans / N
print (ans)


Fixed submission:

r = int(input())
print (r*r)

Buggy python submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline

N = int(input())
x = []
y = []

for i in range(N):
    p, q = map(int, input().split())
    x.append(p)
    y.append(q)

ans = 0

for i in range(N):
    for j in range(N):
        print ("i="+str(i)+", j="+str(j))
        print ("xi="+str(x[i])+", xj="+str(x[j]))
        print ("yi="+str(y[i])+", yj="+str(y[j]))
        ans += math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)

ans = ans / N
print (ans)


Fixed submission:

r = int(input())
print (r*r)

Buggy python submission (verdict: Runtime Error):

print (r*r)


Fixed submission:

r = int(input())
print (r*r)
Buggy python submission (verdict: Runtime Error):
import sys

a, b, x = map(int(), input().split())

if(x > a*a*b):
    sys.exit()

suito = a * a * b

wariai = 0

wariai = x / suito

kakudo = 0
kakudo =90 * wariai
print(90-kakudo)


Fixed submission:
import sys
import math

a, b, x = map(int, input().split())


if(x > a*a*b):
    sys.exit()

if (a*a*b/2 >= x):
    s = math.degrees(math.atan(a*b*b/2/x))
else:
    s = math.degrees(math.atan(2*(a*a*b-x)/a/a/a))

print (s)
Buggy python submission (verdict: Runtime Error):
List = map(int, input().split())
if List.count("5")==2 and List.count("7")==1:
  	print("YES")
else:
	print("NO")




Fixed submission:
List = input().split()
if List.count("5")==2 and List.count("7")==1:
  	print("YES")
else:
	print("NO")
Buggy python submission (verdict: Runtime Error):
N = int(input()) 
s = [int(input()) for i in range(N)] 

for nu in range(len(s)):
	for i in range(3):
		for j in range(3):
			if a[i][j] == s[nu]:
				a[i][j] = 0
#縦横斜めチェック
for r in range(3):
	if a[i][0]==a[i][1]==a[i][2]==0:
		print('Yes')
		exit()
	if a[0][i]==a[1][i]==a[2][i]==0:
		print('Yes')
		exit()

if a[0][0]==a[1][1]==a[2][2]==0	or a[0][2]==a[1][1]==a[2][0]==0:	
		print('Yes')
		exit() 
print('No')
	


Fixed submission:
a = [list(map(int, input().split())) for l in range(3)]

N = int(input()) 
s = [int(input()) for i in range(N)] 

for nu in range(len(s)):
	for i in range(3):
		for j in range(3):
			if a[i][j] == s[nu]:
				a[i][j] = 0
for r in range(3):
	if a[r][0]==a[r][1]==a[r][2]==0:
		print('Yes')
		exit()
	if a[0][r]==a[1][r]==a[2][r]==0:
		print('Yes')
		exit()

if a[0][0]==a[1][1]==a[2][2]==0	or a[0][2]==a[1][1]==a[2][0]==0:	
		print('Yes')
		exit() 
print('No')
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
l = []
r = []

for i in range(m):
    a,b = map(int,input().split())
    l.append(a)
    r.append(b)


if min(r) < max(l):
    print(min(r) - max(l) + 1)
else:
    print(0)

Fixed submission:
a,b = map(int,input().split())
 
if a >= 13:
    print(b)
elif a>= 6:
    print(int(b/2))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
A = [list(map(int,input().split())) for i in range(3)]
A_flat=[]
for i in range(len(A)):
    A_flat.append(A[i][0])
    A_flat.append(A[i][1])
    A_flat.append(A[i][2])

N = int(input())
b = [int(input()) for i in range(N)]
for i in range(len(b)):
    if b[i] in A_flat:
        index = A_flat.index(b[i])
        A_flat[index] = 0

 judge=False
for i in range(3):
    if A_flat[0+i] == A_flat[3+i] == A_flat[6+i]:
        print("Yes")
        judge = True
        break
    elif A_flat[0+i*3]==A_flat[1+i*3]==A_flat[2+i*3]:
        print("Yes")
        judge = True
        break
    elif A_flat[0]==A_flat[4]==A_flat[8] or A_flat[2]==A_flat[4]==A_flat[6]:
        print("Yes")
        judge = True
        break

if judge is False:
    print("No")


Fixed submission:
A = [list(map(int,input().split())) for i in range(3)]
A_flat=[]
for i in range(len(A)):
    A_flat.append(A[i][0])
    A_flat.append(A[i][1])
    A_flat.append(A[i][2])

N = int(input())
b = [int(input()) for i in range(N)]
for i in range(len(b)):
    if b[i] in A_flat:
        index = A_flat.index(b[i])
        A_flat[index] = 0

judge=False
for i in range(3):
    if A_flat[0+i] == A_flat[3+i] == A_flat[6+i]:
        print("Yes")
        judge = True
        break
    elif A_flat[0+i*3]==A_flat[1+i*3]==A_flat[2+i*3]:
        print("Yes")
        judge = True
        break
    elif A_flat[0]==A_flat[4]==A_flat[8] or A_flat[2]==A_flat[4]==A_flat[6]:
        print("Yes")
        judge = True
        break

if judge is False:
    print("No")
Buggy python submission (verdict: Runtime Error):
judge = False
target = [-1 for i in range(N)]
for i in range(M):
    if sc[i][1] + target[sc[i][0]-1] == sc[i][1]-1 or sc[i][1] + target[sc[i][0]-1] == 2*sc[i][1]:
        target[sc[i][0]-1] = sc[i][1]
    else:
        print(-1)
        judge = True
        break

if judge is False:
    for i in range(N):
        if len(target) == 1:
            if target[0] == -1:
                target[0] = 0
        else:
            if i == 0 and target[i] == -1:
                target[i] = 1
            elif target[i] == -1:
                target[i] = 0

    res = 0
    for i in range(N):
        res = res+target[i]*(10**(N-i-1))
    if len(str(res)) != N:
        print(-1)
    else:
        print(res)

Fixed submission:
N,M = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(M)]

s = [sc[i][0] for i in range(len(sc))]
c = [sc[i][1] for i in range(len(sc))]

judge=False
for i in range(len(s)):
    for j in range(len(s)):
        if s[i]==s[j] and c[i] != c[j]:
            print(-1)
            judge=True
            break
        break




target = [0 for i in range(N)]

if N != 1 and target[0]==0:
    target[0]=1

for i in range(M):
    target[sc[i][0]-1] = sc[i][1]

if judge==False:
    res=0
    for i in range(N):
        res = res + target[i]*(10**(N-i-1))
    if len(str(res)) != N:
        print(-1)
    else:
        print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [[c for c in input()] for i in range(N)]
for i in range(len(S)):
    S[i].sort()
    S[i] = str(S[i])
wa = 0
for i in range(len(S)):
    for j in range(i+1,len(S)):
        if S[i] == S[j]:
            wa +=1
print(wa)

Fixed submission:
N = int(input())
S = [[c for c in input()] for i in range(N)]
dic={}
for i in range(len(S)):
    S[i].sort()
    S[i] = str(S[i])
    if S[i] in dic:
        dic[S[i]] +=1
    else:
        dic[S[i]] = 1

comb=0
for i in dic.keys():
    if dic[i] !=0:
        comb = comb + dic[i]*(dic[i]-1)/2
print(int(comb))
Buggy python submission (verdict: Runtime Error):
 = int(input())
A = list(map(int, input().split()))
A_index = [i for i in range(N)]
dic = dict(zip(A_index, A))

for j in range(len(A)):
    if j < len(A)-1:
        dic[j] = dic[j+1]
    else:
        del dic[j]

    for i in range(0,len(dic)):
        if i == 0:
            wa = abs(dic[0])
        elif i == len(dic)-1:
            wa = wa + abs(dic[i-1]-dic[i]) + abs(dic[i])
        else:
            wa = wa + abs(dic[i-1]-dic[i])
    print(wa)
    dic[j] = A[j]


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A = [0] + A + [0]
wa = 0
rem1=[]
rem2=[]
add=[]

for i in range(1,len(A)):
    wa = wa + abs(A[i-1] - A[i])
    rem1.append(abs(A[i-1]-A[i]))
    rem2.append(abs(A[i]- A[i+1]) if i+1 < len(A) else 0)
    add.append(abs(A[i-1]-A[i+1]) if i+1 < len(A) else abs(A[i-1]))

for j in range(0,len(A)-2):
    print(wa-rem1[j]-rem2[j]+add[j])
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(map(str, input().split()))
if 'Y' in S:
    print('Four')
else:
    print('Three')


Fixed submission:
N = int(input())

print(N // 3)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(input()) for i in range(N)]
a.sort(reverse=True)
sum1 = 0
sum2 = 0
for j in range(N):
    if j%2 == 0:
        print(a[j])
        sum1 = sum1 + a[j]
    elif j%2 ==1:
        print(a[j])
        sum2 = sum2 + a[j]
print(sum1 - sum2)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
sum1 = 0
sum2 = 0
for j in range(N):
    if j%2 == 0:
        sum1 = sum1 + a[j]
    elif j%2 ==1:
        sum2 = sum2 + a[j]
print(sum1 - sum2)
Buggy python submission (verdict: Time Limit Exceeded):
# Atcoder forces me to use fractions.gcd instead of math.gec because the contest accepts only python 3.4

import fractions
from functools import reduce


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


N = int(input())
A = list(map(int, input().split()))

if len(A) == 1:
    ans = A[0]
else:
    ans = 1
    for i in range(len(A)):
        ans = max(ans, gcd_list(A[:i] + A[i + 1:]))

print(ans)


Fixed submission:
# Atcoder forces me to use fractions.gcd instead of math.gec because the contest accepts only python 3.4

import fractions
from functools import reduce


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


N = int(input())
A = list(map(int, input().split()))
A_set = list(set(A))
A_lib = {}
for a in A:
    if a in A_lib:
        A_lib[a] += 1
    else:
        A_lib[a] = 1

if len(A_set) == 1:
    ans = A_set[0]
else:
    ans = gcd_list(A_set)
    for i in range(len(A_set)):
        if A_lib[A_set[i]] == 1:
            ans = max(ans, gcd_list(A_set[:i] + A_set[i + 1:]))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# Atcoder forces me to use fractions.gcd instead of math.gec because the contest accepts only python 3.4

import fractions
from functools import reduce


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


N = int(input())
A = list(map(int, input().split()))

if len(A) == 1:
    ans = A[0]
else:
    ans = 1
    for i in range(len(A)):
        ans = max(ans, gcd_list(A[:i] + A[i + 1:]))

print(ans)


Fixed submission:
# Atcoder forces me to use fractions.gcd instead of math.gec because the contest accepts only python 3.4

import fractions
from functools import reduce


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


N = int(input())
A = list(map(int, input().split()))
A_set = list(set(A))
A_lib = {}
for a in A:
    if a in A_lib:
        A_lib[a] += 1
    else:
        A_lib[a] = 1

if len(A_set) == 1:
    ans = A_set[0]
else:
    ans = gcd_list(A_set)
    for i in range(len(A_set)):
        if A_lib[A_set[i]] == 1:
            ans = max(ans, gcd_list(A_set[:i] + A_set[i + 1:]))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
AB = [[] for i in range(N)]
for i in range(N):
    AB[i] = list(map(int, input().split()))

remain_drink = M
price = 0
while remain_drink > 0:
    min_ind = -1
    min_price = 10 ** 10
    for i in range(N):
        if AB[i][0] < min_price:
            min_price = AB[i][0]
            min_ind = i

    if AB[min_ind][1] <= remain_drink:
        price += AB[min_ind][0] * AB[min_ind][1]
        remain_drink -= AB[min_ind][1]
    else:
        price += AB[min_ind][0] * remain_drink
        remain_drink = 0
    AB[min_ind][0] = 10 ** 10

print(price)



Fixed submission:
N, M = map(int, input().split())
AB = [[] for i in range(N)]
for i in range(N):
    AB[i] = list(map(int, input().split()))

AB = sorted(AB)

remain_drink = M
price = 0
i = 0
while remain_drink > 0:
    if AB[i][1] <= remain_drink:
        price += AB[i][0] * AB[i][1]
        remain_drink -= AB[i][1]
    else:
        price += AB[i][0] * remain_drink
        remain_drink = 0
    i += 1
print(price)
Buggy python submission (verdict: Time Limit Exceeded):
def recursin_operation(S, len_init_s):
    S = list(S)
    N = len(S)
    lst = [i for i in range(N - 1) if S[i] != S[i + 1]]
    nums_of_deleted = []
    if len(lst) != 0:
        for i in lst:
            S_next = [S[j] for j in range(len(S)) if j < i or j > i + 1]
            nums_of_deleted.append(recursin_operation(S_next, len_init_s))
    else:
        nums_of_deleted.append(len_init_s - len(S))

    return max(nums_of_deleted)


def main():
    S = input()
    len_init_s = len(S)
    ans = recursin_operation(S, len_init_s)
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
S = input()
len_S = len(S)
zero_lst = [S[i] for i in range(len_S) if S[i] == "0"]
one_lst = [S[i] for i in range(len_S) if S[i] == "1"]
ans = min(len(zero_lst), len(one_lst)) * 2
print(ans)
Buggy python submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    if N >= M:
        print(0)
        return

    X = list(map(int, input().split()))
    X.sort()
    dist = [abs(X[i] - X[i+1]) for i in range(M-1)]
    ranking = [[i for i in range(N-1)], [dist[i] for i in range(N-1)]]
    for i in range(N-1, M-1):
        mind = min(ranking[1])
        if dist[i] > mind:
            ind = ranking[1].index(mind)
            ranking[0][ind] = i
            ranking[1][ind] = dist[i]

    ranking[0].sort()
    ans = 0
    start = 0
    for i in range(M-1):
        if i not in ranking[0]:
            ans += dist[i]

    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N, M = map(int, input().split())
    X = list(map(int, input().split()))
    if N >= M:
        print(0)

    else:
        X.sort()
        dist = [abs(X[i] - X[i+1]) for i in range(M-1)]
        dist.sort()
        ans = sum(dist[:(M-N)])
        print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    h_lst = list(map(int, input().split()))
    while h_lst[0] == 0:
        h_lst = h_lst[1:]
    ans = 0
    while len(h_lst) > 0:
        r = len(h_lst) - 1
        for i in range(len(h_lst) - 1):
            if h_lst[i + 1] == 0:
                r = i
                break

        block_min = min(h_lst[:r + 1])
        for i in range(r + 1):
            h_lst[i] -= block_min
        ans += block_min

        while h_lst[0] == 0:
            del h_lst[0]
            if h_lst == []:
                break

    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N = int(input())
    h_lst = list(map(int, input().split()))
    while h_lst[0] == 0:
        del h_lst[0]
        if h_lst == []:
            break
    ans = 0
    while len(h_lst) > 0:
        r = len(h_lst) - 1
        for i in range(len(h_lst) - 1):
            if h_lst[i + 1] == 0:
                r = i
                break

        block_min = min(h_lst[:r + 1])
        for i in range(r + 1):
            h_lst[i] -= block_min
        ans += block_min

        while h_lst[0] == 0:
            del h_lst[0]
            if h_lst == []:
                break

    print(ans)


if __name__ == "__main__":
    main()