Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
listn = list(str(N))
a = []
if len(str(N)) < K:
    for i in range(len(str(N))):
        if listn[i] != str(1):
            a.append(str(listn[i]))
else:
    for i in range(K):
        if listn[i] != str(1):
            a.append(str(listn[i]))
if a == []:
    print(1)
else:
    print(a[0])


Fixed submission:
N, K = [int(input()) for _ in range(2)]
listn = list(str(N))
a = []
if len(str(N)) < K:
    for i in range(len(str(N))):
        if listn[i] != str(1):
            a.append(str(listn[i]))
else:
    for i in range(K):
        if listn[i] != str(1):
            a.append(str(listn[i]))
if a == []:
    print(1)
else:
    print(a[0])

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
listn = list(str(N))
for i in range(K):
    if listn[i] != str(1):
        a.append(str(listn[i]))
if a == []:
    print(1)
else:
    print(a[0])

Fixed submission:
N, K = [int(input()) for _ in range(2)]
listn = list(str(N))
a = []
if len(str(N)) < K:
    for i in range(len(str(N))):
        if listn[i] != str(1):
            a.append(str(listn[i]))
else:
    for i in range(K):
        if listn[i] != str(1):
            a.append(str(listn[i]))
if a == []:
    print(1)
else:
    print(a[0])
Buggy python submission (verdict: Runtime Error):
n = map(int,input())

def basen(n):
    a = []
    while n!= 0:
        r = n % 2
        if (r < 0):
            r += 2

        n = (n - r)//(-2)
        a.append(r)
        if(a == " "):
            a.append(0)
        reversed(a)
    return a
 
print(basen(n))

Fixed submission:
n = int(input())

def basen(n):
    a = []
    while n!= 0:
        r = n % 2
        if (r < 0):
            r += 2

        n = (n - r)//(-2)
        a.append(r)
    if a == []:
        a.append(0)
    a.reverse()
    return "".join(map(str,a))
print(basen(n))

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


def base-2(n):
    a = ()
    while n! = 0:
        r = n % 2:
        if (r < 0):
            r += 2

            n = (n - r)/2
            a.append(str(r))
    if(a = ""):
    a = "0"
    reversed(a)
print(base(n))

Fixed submission:
n = int(input())

def basen(n):
    a = []
    while n!= 0:
        r = n % 2
        if (r < 0):
            r += 2

        n = (n - r)//(-2)
        a.append(r)
    if a == []:
        a.append(0)
    a.reverse()
    return "".join(map(str,a))
print(basen(n))
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = N/10
b = N%10
if a == 9  b == 9:
  print('Yes')
else:
  print('No')


Fixed submission:
N = int(input())
a = int(N/10)
b = N%10
#print(N)
#print(a)
#print(b)
if a == 9 or b == 9:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
def ABC_169_B():
    N=int(input())
    A = input().split()
    A = [int(s) for s in A]
    sum=1

    for i in range(len(A)):
        sum=sum*A[i]
    if sum>10**18:
        print('-1')
    else:
        print(sum)


if __name__ == '__main__':

    ABC_169_B()

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]

reg = A[0]
flg=True
if 0 in A:
    print(0)
    flg=False
    reg=0
for i in range(1, N):
    reg *= A[i]
    if reg>10**18:
        print(-1)
        flg=False
        break
if flg:
    print(reg)
Buggy python submission (verdict: Runtime Error):
from decimal import *
def ABC_169_C():
    getcontext().prec=28
    i=0
    A,B= map(float, input().split())
    k=Decimal(A)*Decimal(B)
    k=str(k)
    i=k.index('.')
    print(int(k[0:i]))

if __name__ == '__main__':

    ABC_169_C()

Fixed submission:
from decimal import *
def ABC_169_C():
    getcontext().prec=28
    A,B= map(float, input().split())
    k=Decimal(str(A))*Decimal(str(B))
    print(int(k))

if __name__ == '__main__':

    ABC_169_C()

Buggy python submission (verdict: Runtime Error):
from decimal import *
def ABC_169_C():
    getcontext().prec=28
    i=0
    A,B= map(float, input().split())
    k=Decimal(A)*Decimal(B)
    k=str(k)
    i=k.index('.')
    print(k[0:i])

if __name__ == '__main__':

    ABC_169_C()

Fixed submission:
from decimal import *
def ABC_169_C():
    getcontext().prec=28
    A,B= map(float, input().split())
    k=Decimal(str(A))*Decimal(str(B))
    print(int(k))

if __name__ == '__main__':

    ABC_169_C()
Buggy python submission (verdict: Runtime Error):
def ABC_86_B():
    T=list(input())
    for i in range(len(T)):
        if T[i] == '?':
            if i==0 and T[0]=='P':
                i=i
            elif i == 0 and T[0]=='D':
                i=i
            elif i == 0 and T[0]=='?' and T[1]=='D':
                T[0] = 'D'
            elif i == 0 and T[0]=='?' and T[1]=='P':
                T[0] = 'D'
            elif T[i-1] == 'P':
                T[i]='D'
            elif T[i-1] == 'D':
                T[i]='P'

    print(''.join(T))

if __name__ == '__main__':

    ABC_86_B()

Fixed submission:
def ABC_86_B():
    T=list(input())
    for i in range(len(T)):
        if T[i] == '?':
            T[i]='D'

    print(''.join(T))

if __name__ == '__main__':

    ABC_86_B()

Buggy python submission (verdict: Runtime Error):
def ABC_86_B():
    T=list(input())
    for i in range(len(T)):
        if T[i] == '?':
            if i==0 and T[0]=='P':
                i=i
            elif i == 0 and T[0]=='D':
                i=i
            elif i == 0 and T[0]=='?' and T[1]=='D':
                T[0] = 'P'
            elif i == 0 and T[0]=='?' and T[1]=='P':
                T[0] = 'D'
            elif T[i-1] == 'P':
                T[i]='D'
            elif T[i-1] == 'D':
                T[i]='P'

    print(''.join(T))

if __name__ == '__main__':

    ABC_86_B()

Fixed submission:
def ABC_86_B():
    T=list(input())
    for i in range(len(T)):
        if T[i] == '?':
            T[i]='D'

    print(''.join(T))

if __name__ == '__main__':

    ABC_86_B()
Buggy python submission (verdict: Time Limit Exceeded):
N,A,B = map(int, input().split())
red=0
blue=0
count=0

for i in range(N):

  if count == A+B:
      count=0

  if A!=0 and count < A :
      blue+=1
      count+=1
  elif count < A + B:
      red+=1
      count+=1

print(blue)

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

if N%(A+B) <= A:
    print(int(int(N/(A+B))*A+N%(A+B)))
else:
    print(int(int(N/(A+B))*A+A))
Buggy python submission (verdict: Runtime Error):
def ABC_135_A():
    A,B = map(int, input().split())

    if (A+B)/%2 == 0:
        print(int((A+B)/2))
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':

    ABC_135_A()

Fixed submission:
def ABC_135_A():
    A,B = map(int, input().split())

    if (A+B)%2 == 0:
        print(int((A+B)/2))
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':

    ABC_135_A()
Buggy python submission (verdict: Time Limit Exceeded):
def ABC_102_A():
    N = int(input())

    for i in range(1000000000):
         if 2*i%N == 0 and i>0:
             print(2*i)
             break
         else:
             continue
         break
 


if __name__ == '__main__':

    ABC_102_A()

Fixed submission:
def ABC_102_A():
    N = int(input())

    if N%2 == 0:
        print(N)
    else:
        print(2*N)

if __name__ == '__main__':

    ABC_102_A()
Buggy python submission (verdict: Runtime Error):
  M = int(input())
    
  print(48-M)

Fixed submission:
def ABC_84_A():
    M = int(input())
    
    print(48-M)

if __name__ == '__main__':

    ABC_84_A()

Buggy python submission (verdict: Runtime Error):
  M = int(input())
    
    print(48-M)

Fixed submission:
def ABC_84_A():
    M = int(input())
    
    print(48-M)

if __name__ == '__main__':

    ABC_84_A()
Buggy python submission (verdict: Runtime Error):
X,Y,Z = map(int, input().split())
N=0
while sum<= X:
	um = Y*N+Z*(N+1)
	N+=1  
print(N-2)

Fixed submission:
def ABC_78_B():
    X,Y,Z = map(int, input().split())
    sum=0
    N=0
    while sum<= X:
        sum = Y*N+Z*(N+1)
        N+=1  
    print(N-2)


if __name__ == '__main__':

    ABC_78_B()
Buggy python submission (verdict: Runtime Error):
def ABC_77_A():
    A,B,C = map(str, input().split())
    A2,B2,C2 = map(str, input().split())
    
    if A == C2 and C == A2 and B == B2:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':

    ABC_77_A()

Fixed submission:
def ABC_77_A():
    C1= input()
    C2 =input()
    
    if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':

    ABC_77_A()
Buggy python submission (verdict: Runtime Error):

    A,B = map(int, input().split())
    
    if A%3 == 0:
        print('Possible')
    elif B%3 == 0:
        print('Possible')
    elif (A+B)%3 == 0:
        print('Possible')
    else:
        print('Impossible')

Fixed submission:
def ABC_67_A():
    A,B = map(int, input().split())
    
    if A%3 == 0:
        print('Possible')
    elif B%3 == 0:
        print('Possible')
    elif (A+B)%3 == 0:
        print('Possible')
    else:
        print('Impossible')

if __name__ == '__main__':

    ABC_67_A()
Buggy python submission (verdict: Runtime Error):
def ABC_61_B():
    N,M = map(int, input().split())
    t = [ 0 for _ in range(N)]
    t2 = [ 0 for _ in range(N)]

    for i in range(M):
        a,b = map(str, input().split())
        t[int(a)-1] = str(t[int(a)-1])+b
        t[int(b)-1] = str(t[int(b)-1])+a

    for i in range(len(t)):
        t2=list(t[i])
        print(len(t2)-1)

if __name__ == '__main__':

    ABC_61_B()

Fixed submission:
N,M = map(int, input().split())
t=[0 for _ in range(N)]

for i in range(M):
	a,b = map(int, input().split())
	t[a-1]+=1
	t[b-1]+=1

for i in range(N):
	print(t[i])
Buggy python submission (verdict: Runtime Error):
#たてなが
def ABC_49_B():
    H,W = map(int, input().split())
    C = [0 for _ in range(W)]

    for i in range(H):
        C[i] = input()

    for i in range(H):
        print(C[i])
        print(C[i])


if __name__ == '__main__':

    ABC_49_B()

Fixed submission:
H,W = map(int, input().split())
C = [0 for _ in range(H)]

for i in range(H):
	C[i] = input()

for i in range(H):
	print(C[i])
	print(C[i])

Buggy python submission (verdict: Runtime Error):
H,W = map(int, input().split())
C = [0 for _ in range(W)]

for i in range(H):
	C[i] = input()

for i in range(H):
	print(C[i])
	print(C[i])

Fixed submission:
H,W = map(int, input().split())
C = [0 for _ in range(H)]

for i in range(H):
	C[i] = input()

for i in range(H):
	print(C[i])
	print(C[i])
Buggy python submission (verdict: Runtime Error):
#AtCoder *** Contest
def ABC_48_A():
    A,B,C = map(str, input().split())
    print('A' + B[0] + 'C')


if __name__ == '__main__':


Fixed submission:
def ABC_48_A():
    A,B,C = map(str, input().split())
    print('A' + B[0] + 'C')


if __name__ == '__main__':

    ABC_48_A()
Buggy python submission (verdict: Runtime Error):
def ABC_43_B():
    s = input()
    t=[]

    for i in range(len(s)):
        if s[i] == '0':
            t.append('0')
        elif s[i] == '1':
            t.append('1')
        else:
            if len(t)==0:
                a=0
            else:
                del t[i-1]

    print(''.join(t))



if __name__ == '__main__':

    ABC_43_B()

Fixed submission:
def ABC_43_B():
    s = input()
    t=[]

    for i in range(len(s)):
        if s[i] == '0':
            t.append('0')
        elif s[i] == '1':
            t.append('1')
        else:
            if len(t)==0:
                a=0
            else:
                del t[len(t)-1]

    print(''.join(t))



if __name__ == '__main__':

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

c = a * b

if c % 2 == 0:
    print("Even")
else:
    print("Odd")


Fixed submission:
t = input().split()
for i in range(len(t)):
    t[i] = int(t[i])

a = t[0]
b = t[1]

if (a * b) % 2 == 0:
    print("Even")
else :
    print("Odd")
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
# n, k = map(int, "2 6".split())

while True:
    nc = n
    n = n - k
    if n <= 0:
        if abs(n) < nc:
            print(abs(n))
            break
        else:
            print(nc)
            break


Fixed submission:
n, k = map(int, input().split())
# n, k = map(int, "2 6".split())
q = n // k #答え
mod = n % k #あまり

if q == 0:

    while True:
        nc = n
        n = n - k
        if n <= 0:
            if abs(n) < nc:
                print(abs(n))
                break
            else:
                print(nc)
                break
else:
    n1 = abs(n - (q * k))
    n2 = abs(n - ((q + 1) * k))
    if n1 < n2:
        print(n1)
    else:
        print(n2)
Buggy python submission (verdict: Runtime Error):
import math

firstInputText = input()
inputList = firstInputText.split()
a = int(inputList[0])
b = int(inputList[1])
c = int(inputList[2])
x = math.sqrt(a) + math.sqrt(b)
y = math.sqrt(c)
# print(x)
# print(y)

# if math.isclose(x,y):
#     print("Yes")
# else:
#     print("No")
if x == y:
    print("No")
elif x < y:
    print("Yes")
else:
    print("No")


Fixed submission:
list = [1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51]
firstInputText = input()
print(list[int(firstInputText) - 1])

Buggy python submission (verdict: Runtime Error):
list = [1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51]
firstInputText = input()
print(textList[int(firstInputText) - 1])


Fixed submission:
list = [1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51]
firstInputText = input()
print(list[int(firstInputText) - 1])

Buggy python submission (verdict: Runtime Error):
text = "1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51"
textList = text.split(",")
firstInputText = input()
print(textList[int(firstInputText) - 1])
secondInputText = input()
print(textList[int(secondInputText) - 1])


Fixed submission:
list = [1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51]
firstInputText = input()
print(list[int(firstInputText) - 1])
Buggy python submission (verdict: Runtime Error):
n, b, r = map(int, input().split())
# inputText1 = "8 3 4"
inputText1List = inputText1.split()
# n = int(inputText1List[0])
# b = int(inputText1List[1])
# r = int(inputText1List[2])
if b == 0:
    print(b)
else:
    # i = (count // (b + r)) + 1 # 最大繰り返し数
    baseTextCount = b + r # 7
    i = n // baseTextCount
    mod = n % baseTextCount
    # print(i * b) # あまりを除いた青のボール数
    if mod < b:
        print(i * b + mod)
    else:
        print(i * b + b)


Fixed submission:
inputText1 = input()
# inputText1 = "8 3 4"
inputText1List = inputText1.split()
n = int(inputText1List[0])
b = int(inputText1List[1])
r = int(inputText1List[2])
count = 10 **100
if b == 0:
    print(b)
else:
    # i = (count // (b + r)) + 1 # 最大繰り返し数
    baseTextCount = b + r # 7
    i = n // baseTextCount
    mod = n % baseTextCount
    # print(i * b) # あまりを除いた青のボール数
    if mod < b:
        print(i * b + mod)
    else:
        print(i * b + b)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
 
b=[0]*n
for i in a:
    b[i-1]+=1
 
for i in b:
    print(i)

Fixed submission:
import math
pi=math.pi

R=float(input())

print(2.0*pi*R)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
 
res=1
for i in A:
    print(A.count(res))
    res+=1
 
print(0)

Fixed submission:
import collections
 
N = int(input())
A = list(map(int, input().split()))
cnt = collections.Counter(A)
for i in range(1, N+1):
    print(cnt[i])

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
 
count=1
for i in A:
    print(A.count(count))
    count+=1
 
print(0)

Fixed submission:
import collections
 
N = int(input())
A = list(map(int, input().split()))
cnt = collections.Counter(A)
for i in range(1, N+1):
    print(cnt[i])

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))

count=1
for i in A:
    print(A.count(count))
    count+=1

print(0)

Fixed submission:
import collections
 
N = int(input())
A = list(map(int, input().split()))
cnt = collections.Counter(A)
for i in range(1, N+1):
    print(cnt[i])
Buggy python submission (verdict: Time Limit Exceeded):
input()
ans = 1
for i in map(int, input().split()):
  ans *= i
  
if ans > 10**18:
    print(-1)
    exit()
print(ans)

Fixed submission:
input()
ans = 1
l = list(map(int, input().split()))
if 0 in l:
  print(0)
  exit()
for i in l:
  ans *= i
  if ans > 10**18:
    print(-1)
    exit()
  

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
input()
ans = 1
for i in map(int, input().split()):
  ans *= i
  
if ans > 10**18:
    print(-1)
    exit()
print(ans)

Fixed submission:
input()
ans = 1
l = list(map(int, input().split()))
if 0 in l:
  print(0)
  exit()
for i in l:
  ans *= i
  if ans > 10**18:
    print(-1)
    exit()
  

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
teleport_list = list(map(int, input().split()))
t_cycle = [1]
now = 1
while len(t_cycle) == len(set(t_cycle)):
  now = teleport_list[now-1]
  t_cycle.append(now)

start_cycle = t_cycle[-1]
before_cycle_len = t_cycle.index(start_cycle)
cycle_len = len(t_cycle) - t_cycle.index(start_cycle) - 1

if k <= before_cycle_len:
  print(t_cycle[k])
else:
  print(t_cycle[(k-before_cycle_len)%cycle_len + before_cycle_len])

Fixed submission:
n, k = map(int, input().split())
teleport_list = list(map(int, input().split()))
t_cycle = [1]
c_set = set([1])
now = 1
while len(t_cycle) == len(c_set):
  now = teleport_list[now-1]
  t_cycle.append(now)
  c_set.add(now)

start_cycle = t_cycle[-1]
before_cycle_len = t_cycle.index(start_cycle)
cycle_len = len(t_cycle) - t_cycle.index(start_cycle) - 1

if k <= before_cycle_len:
  print(t_cycle[k])
else:
  print(t_cycle[(k-before_cycle_len)%cycle_len + before_cycle_len])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
teleport_list = list(map(int, input().split()))
t_cycle = [1]
now = 1
while len(t_cycle) == len(set(t_cycle)):
  now = teleport_list[now-1]
  t_cycle.append(now)

start_cycle = t_cycle[-1]
before_cycle_len = t_cycle.index(start_cycle)
cycle_len = len(t_cycle) - t_cycle.index(start_cycle) - 1

if k <= before_cycle_len:
  print(t_cycle[k])
else:
  print(t_cycle[(k-before_cycle_len)%cycle_len + before_cycle_len])

Fixed submission:
n, k = map(int, input().split())
teleport_list = list(map(int, input().split()))
t_cycle = [1]
c_set = set([1])
now = 1
while len(t_cycle) == len(c_set):
  now = teleport_list[now-1]
  t_cycle.append(now)
  c_set.add(now)

start_cycle = t_cycle[-1]
before_cycle_len = t_cycle.index(start_cycle)
cycle_len = len(t_cycle) - t_cycle.index(start_cycle) - 1

if k <= before_cycle_len:
  print(t_cycle[k])
else:
  print(t_cycle[(k-before_cycle_len)%cycle_len + before_cycle_len])
Buggy python submission (verdict: Runtime Error):
group = {}
for _ in range(int(input())):
  group.add(input())
print(len(group))

Fixed submission:
group = set()
for _ in range(int(input())):
  group.add(input())
print(len(group))
Buggy python submission (verdict: Runtime Error):
H, N = map(int, input())
skills_sum = sum(map(int, input()))
print("Yes" if H-skills_sum <= 0 else "No")

Fixed submission:
H, N = map(int, input().split())
skills_sum = sum(map(int, input().split()))
print("Yes" if H-skills_sum <= 0 else "No")
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input())
print(max(a-k, 0), max(min(a+b-k, b), 0)) 

Fixed submission:
a, b, k = map(int, input().split())
print(max(a-k, 0), max(min(a+b-k, b), 0))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input())
print((a+b)//2 if not (a+b)%2 else "IMPOSSIBLE")

Fixed submission:
a, b = map(int, input().split())
print((a+b)//2 if not (a+b)%2 else "IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = [int(input()) for _ in range(n)]

for i in range(n):
  print(max(a_list[:i]+a_list[i+1:])) 

Fixed submission:
n = int(input())
a_list = [int(input()) for _ in range(n)]
m1 = max(a_list)
k = a_list.index(m1)
m2 = max(a_list[:k]+a_list[k+1:])
for i in range(n):
  if i == k:
    print(m2)
  else:
    print(m1)
Buggy python submission (verdict: Runtime Error):
print(1110-int(input())

Fixed submission:
print(1110-int(input()))
Buggy python submission (verdict: Time Limit Exceeded):
i = int(input())

while True:
    if set(str(i)) == 1:
        print(i)
        break
    i += 1

Fixed submission:
i = int(input())

while True:
    if len(set(str(i))) == 1:
        print(i)
        break
    i += 1
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input())
print((a-1)*(b-1))

Fixed submission:
a, b = map(int, input().split())
print((a-1)*(b-1))
Buggy python submission (verdict: Runtime Error):
n = inpt(input())
ans = 0
for i in range(1, n+1):
  stock = 0
  for j in range(1, n+1):
    if i % j == 0:
      stock += 1
  if stock == 8 and i % 2:
    ans += 1
print(ans)

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

for i in range(1, N+1):
	div_num = 0
	if i % 2:
		for j in range(1, i+1):
			if not i % j:
				div_num += 1
		if div_num == 8:
			ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
input()
numbers = map(int, input().split())
print(max(numbers)-min(numbers))

Fixed submission:
input()
numbers = list(map(int, input().split()))
print(max(numbers)-min(numbers))
Buggy python submission (verdict: Runtime Error):
N = int(input())
numbers = map(int, input().split())
min_num = min(numbers)
max_num = max(numbers)
abs_= float('inf')
for b in range(min_num, max_num):
    abs_pre = sum([abs(a-b-i) for i, a in enumerate(numbers)])
    if abs_pre < abs_:
        abs_ = abs_pre
print(abs_)

Fixed submission:
from statistics import median

N = int(input())
numbers = [int(a)-i for i, a in enumerate(input().split())]
b = median(numbers)
abs_1 = sum([abs(c-int(b)) for c in numbers])
abs_2 = sum([abs(c-int(b)-1) for c in numbers])
print(min(abs_1, abs_2))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
ans = 3 * 10 ** 5

for i in range(N):
	left = S[:i]
	right = S[i+1:]
	ans = min(ans, left.count('W') + right.count('E'))

print(ans)

Fixed submission:
N = int(input())
S = input()
ans = 3 * 10 ** 5
w = S.count('W')
w_r = 0

for i, a in enumerate(S):
	if a == 'W':
		w_r += 1
		ans = min(ans, 2*w_r+N-w-i-2)
	else:
		ans = min(ans, 2*w_r+N-w-i-1)
	

print(ans)
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
picture = [input() for _ in range(H)]

for i in range(H):
	for j in range(W):
		if picture[i][j] == '#':
			if i == 0 or picture[i-1][j] == '.':
				if j == 0 or picture[i][j-1] == '.':
					if i == H or picture[i+1][j] == '.':
						if j == W or picture[i][j+1] == '.':
							print('No')
							exit()

print('Yes')


Fixed submission:
H, W = map(int, input().split())
picture = [input() for _ in range(H)]

for i in range(H):
	for j in range(W):
		if picture[i][j] == '#':
			if i == 0 or picture[i-1][j] == '.':
				if j == 0 or picture[i][j-1] == '.':
					if i == H-1 or picture[i+1][j] == '.':
						if j == W-1 or picture[i][j+1] == '.':
							print('No')
							exit()

print('Yes')