Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,k  = map(int,input().split())
a = list(map(int,input().split()))
a.insert(0,0)

town =1
visited = [0] * (n+1)

for i in range(1,k+1):
    town = a[town]
    if visited[town] !=0:
        rest =(k - visited[town]) % (i -visited[town])
        goal =visited.index(visited[town]+rest)
        break
    visited[town] = i 
    

print(goal)

Fixed submission:
import sys
import numpy as np
from collections import defaultdict



#input = sys.stdin.readline

def main():
    N, K = map(int,input().split())
    A = list(map(int,input().split()))
    A = [0] +A  #transporter
    visited = [0] * (N+1)
    town = 1
    cycle = 0
    for i in range(1,K+1):
        town = A[town]
        if visited[town] ==0:
            visited[town] = i
        else:
            cycle = i - visited[town]
            place = (K - visited[town]) % cycle + visited[town]
            for j in range(N+1):
                if visited[j] == place:
                    print(j)
                    exit()
    print(town)




if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
n,k  = map(int,input().split())
a = list(map(int,input().split()))
a.insert(0,0)
print(a)

town =1
visited = [0] * (n+1)

for i in range(1,k+1):
    town = a[town]
    if visited[town] !=0:
        rest =(k - visited[town]) % (i -visited[town])
        goal =visited.index(visited[town]+rest)
        break
    visited[town] = i 
    

print(goal)

Fixed submission:
import sys
import numpy as np
from collections import defaultdict



#input = sys.stdin.readline

def main():
    N, K = map(int,input().split())
    A = list(map(int,input().split()))
    A = [0] +A  #transporter
    visited = [0] * (N+1)
    town = 1
    cycle = 0
    for i in range(1,K+1):
        town = A[town]
        if visited[town] ==0:
            visited[town] = i
        else:
            cycle = i - visited[town]
            place = (K - visited[town]) % cycle + visited[town]
            for j in range(N+1):
                if visited[j] == place:
                    print(j)
                    exit()
    print(town)




if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import itertools
s = input()
count = 0

for i,j in itertools.combinations(range(0,len(str(s))+1),2):
    if int(s[i:j]) % 2019 ==0:
        count +=1
    print(s[i:j])
print(count)
    

Fixed submission:
s , w = map(int, input().split())

if w>=s:
    print("unsafe")
else:
    print("safe")
Buggy python submission (verdict: Runtime Error):
import numpy as np

r = int(input())
print(r*2*np.pi)

Fixed submission:
r = int(input())
print(r*2*3.141)

Buggy python submission (verdict: Runtime Error):
import numpy as np

r = int(input())
print(r*2*np.pi)

Fixed submission:
r = int(input())
print(r*2*3.141)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a =list(map(int, input().split()))

for i in range(1,n+1):
    print(a.count(i))
    

Fixed submission:
n = int(input())
a =list(map(int, input().split()))
l =[0] * (n+1)

for i in range(0,n-1):
    l[a[i]] +=1
    
for i in range(1,n+1):
    print(l[i])
Buggy python submission (verdict: Runtime Error):
import itertools


input()
s = list(input())
r =[]
g =[]
b =[]
n= len(s)
ans =0
for i in range(n):
    if s[i]== "R":
        r.append(i+1)
    elif s[i]== "G":
        g.append(i+1)
    else:
        b.append(i+1)

for ri , gi in itertools.product(r,g):
    rg=gi-a
    if rg+gi in b:
        ans -=1
    if  ri-rg in b:
        ans -=1
    if (gi+ri)/2 in b:
        ans -=1

ans += len(r)*len(b)*len(g)
print(ans)

Fixed submission:
n = list(input())
if "7" in n:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import itertools

n = int(input())
ans =0
for a,b,c in itertools.product(range(1,n+1),repeat=3):

    g = np.gcd(np.gcd(a,b),c)
    ans +=g
print(ans)

Fixed submission:
import numpy as np
K = int(input())
l = [0] *(K+1)
res = 0
for i in range(1,K+1):
    for j in range(1, K+1):
        gcd_ab = np.gcd(i,j)
        l[gcd_ab] +=1

for i in range(1, K+1):
    for j in range(1,K+1):
        gcd_c = np.gcd(i,j)
        res += l[j]* gcd_c


print(res)

Buggy python submission (verdict: Runtime Error):

import numpy as np
import itertools

n = int(input())
ans =0
for a,b,c in itertools.product(range(1,n+1),repeat=3):

    g = np.gcd(np.gcd(a,b),c)
    ans +=g
print(ans)
    

Fixed submission:
import numpy as np
K = int(input())
l = [0] *(K+1)
res = 0
for i in range(1,K+1):
    for j in range(1, K+1):
        gcd_ab = np.gcd(i,j)
        l[gcd_ab] +=1

for i in range(1, K+1):
    for j in range(1,K+1):
        gcd_c = np.gcd(i,j)
        res += l[j]* gcd_c


print(res)
Buggy python submission (verdict: Runtime Error):
import numpy as np
n, k = map(int, input().split())
ans = n%k , (k-n%k)%k 
answer = np.min(ans)
print(answer)

Fixed submission:
import numpy as np
n, k = map(int, input().split())
ans = n%k , (k-n%k)%k 
answer = np.min(ans)
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N, X, Y = map(int, input().split())
l = [0] * N
for i in range(1,N):
    for j in range(i+1,N+1):
        #i j
        ij = j - i
        #i x y j
        ixyj = abs(X - i) + 1+ abs(Y -j)
        #i y x j
        iyxj = abs(Y - i) + 1 + abs(X- j)
        length = min(min(ij,ixyj),iyxj)
        l[length] +=1
for i in range(1,N):
    print(l[i])

Fixed submission:
N, X, Y = map(int, input().split())
l = [0] * N
for i in range(1,N):
    for j in range(i+1,N+1):
        #i j
        ij = j - i
        #i x y j
        ixyj = abs(X - i) + 1+ abs(Y -j)
        #i y x j
        iyxj = abs(Y - i) + 1 + abs(X- j)
        length = min(min(ij,ixyj),iyxj)
        l[length] +=1
for i in range(1,N):
    print(l[i])
Buggy python submission (verdict: Runtime Error):
2 2 4 4 4
11 12 13 14
21 22 23 24
1 2 3 4

Fixed submission:
X,Y,A,B,C =map(int,input().split())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
R = list(map(int,input().split()))

P.sort()
Q.sort()
R.sort()

P_new = P[-X::]
Q_new = Q[-Y::]


agg = P_new + Q_new +R
agg.sort()
print(sum(agg[-X-Y::]))

Buggy python submission (verdict: Runtime Error):
2 2 2 2 2
8 6
9 1
2 1

Fixed submission:
X,Y,A,B,C =map(int,input().split())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
R = list(map(int,input().split()))

P.sort()
Q.sort()
R.sort()

P_new = P[-X::]
Q_new = Q[-Y::]


agg = P_new + Q_new +R
agg.sort()
print(sum(agg[-X-Y::]))
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = np.array(list(map(int,input().split())))
L = [0]*(N+2)
L = np.array(L)

for i in A:
    L[i] +=1

LL  = np.multiply(L,L-1)/2

gros = int(sum(LL))

for k in A:
    print(gros +1 - L[k])


Fixed submission:
import numpy as np

N = int(input())
A = np.array(list(map(int,input().split())))
L = [0]*(N+2)
L = np.array(L)

for i in A:
    L[i] +=1

LL  = np.multiply(L,L-1)/2

gros = int(sum(LL))

for k in A:
    print(gros +1 - L[k])

Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = np.array(list(map(int,input().split())))
L = [0]*(N+1)
L = np.array(L)

for i in A:
    L[i] +=1

LL  = np.multiply(L,L-1)/2

gros = int(sum(LL))

for k in A:
    print(gros +1 - L[k])


Fixed submission:
import numpy as np

N = int(input())
A = np.array(list(map(int,input().split())))
L = [0]*(N+2)
L = np.array(L)

for i in A:
    L[i] +=1

LL  = np.multiply(L,L-1)/2

gros = int(sum(LL))

for k in A:
    print(gros +1 - L[k])
Buggy python submission (verdict: Runtime Error):
N , A, B, =map(int,input().split())
d, m =divmod(N, A+B)
print(d*A + min(m,A))

Fixed submission:
N , A, B, =map(int,input().split())
d, m =divmod(N, A+B)
print(d*A + min(m,A))
Buggy python submission (verdict: Runtime Error):
import numpy as np
A, B = map(int,input().split())
minA = math.floor(A/0.08)
maxA = math.ceil((A+1)/0.08) -1
minB = math.floor(B/0.08)
maxB = math.ceil((B+1)/0.08) -1
if (minA>maxB) or (minB>maxA):
    print(-1)
else:
    print(min(minA,minB))


Fixed submission:
import math
A, B = map(int,input().split())
minA = math.ceil(A/0.08)
maxA = math.ceil((A+1)/0.08) -1
minB = math.ceil(B/0.1)
maxB = math.ceil((B+1)/0.1) -1

if (minA>maxB) or (minB>maxA):
    print(-1)
else:
    print(max(minA,minB))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
times = int(input())

for i in range(times):
    Q =input().split()
    if Q[0] =="1":
        S = S[::-1]
    else:
        if Q[1] == "1":
            S = Q[2] +S
        else:
            S = S + Q[2]

print(S)

Fixed submission:
S = input()
times = int(input())

top =0
first = str()
last = str()

for i in range(times):
    Q =input().split()
    if Q[0] =="1":
        top = (top+1)%2
    else:
        if Q[1] == "1":
            #先頭に追加する 0のとき先頭
            if top ==0:
                first +=Q[2]
            else:
                last += Q[2]
        else:
            if top ==1:
                first +=Q[2]
            else:
                last += Q[2]
if top == 0:
    S = first[::-1] + S + last
else:
    S = last[::-1] + S[::-1] + first


print(S)
Buggy python submission (verdict: Time Limit Exceeded):
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():

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

    ans =0
    for i in range(N-K+1):
        ans = max(ans, sum(A[i:i+K],K)/2  )
    print(ans)



if __name__ == "__main__":
    main()


Fixed submission:
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():

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

    current = sum(A[:K])
    ans =(current+K)/2

    for i in range(1,N-K+1):
        current = current - A[i-1] + A[i+K-1]
        ans = max(ans, (current+K)/2 )
    print(ans)



if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
N,K =map(int,input().split())
p = list(map(int,input().split()))
ans = 0
for i in range(N-K+1):
    ans = max(sum(p[i:i+K]),ans)
    
print(ans/2+K/2)

Fixed submission:
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():

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

    current = sum(A[:K])
    ans =(current+K)/2

    for i in range(1,N-K+1):
        current = current - A[i-1] + A[i+K-1]
        ans = max(ans, (current+K)/2 )
    print(ans)



if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
N,K =map(int,input().split())
p = list(map(int,input().split()))
ans = 0
for i in range(N-K+1):
    ans = max(sum(p[i:i+K]),ans)
    
print(ans/2+K/2)

Fixed submission:
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():

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

    current = sum(A[:K])
    ans =(current+K)/2

    for i in range(1,N-K+1):
        current = current - A[i-1] + A[i+K-1]
        ans = max(ans, (current+K)/2 )
    print(ans)



if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import math
import numpy as np
N = int(input())
tb = [[0]*10]*10
tb = np.array(tb)
for i in range(1,N+1):
    s = str(i)
    tb[int(s[0])][int(s[-1])] =tb[int(s[0])][int(s[-1])] +1
 
point =0
 
for i in range(0,10):
    for j in range(0,10):
        point += tb[i][j] * tb[j][i]
 

Fixed submission:
import math
import numpy as np
N = int(input())
tb = [[0]*10]*10
tb = np.array(tb)
for i in range(1,N+1):
    s = str(i)
    tb[int(s[0])][int(s[-1])] =tb[int(s[0])][int(s[-1])] +1
 
point =0
 
for i in range(0,10):
    for j in range(0,10):
        point += tb[i][j] * tb[j][i]
 
print(point)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
import bisect
import heapq


def input():
    return sys.stdin.readline().rstrip()


def main():
    H, W = map(int, input().split())
    M = 80
    A = [[0] * W for _ in range(H)]
    K = M * (H + W) + 1
    for i in range(H):
        a = list(map(int, input().split()))
        A[i] = a

    for i in range(H):
        b = list(map(int, input().split()))
        for j in range(W):
            A[i][j] -= b[j]

    dp = [[[False] * K for i in range(W)] for i in range(H)]
    # dp[i][j][k]
    dp[0][0][abs(A[0][0])] = True

    for i in range(H):
        for j in range(W):
            if i != 0:
                for k in range(K):
                    if dp[i - 1][j][k] is True:
                        dp[i][j][abs(k - A[i][j])] = True
                        dp[i][j][abs(k + A[i][j])] = True

            if j != 0:
                for k in range(K):
                    if dp[i][j - 1][k] == True:
                        dp[i][j][abs(k - A[i][j])] = True
                        dp[i][j][abs(k + A[i][j])] = True


    for k in range(K):
        if dp[H-1][W-1][k] ==True:
            print(k)
            exit()

if __name__ == "__main__":
    main()


Fixed submission:
import sys
import math
import bisect
import heapq


def input():
    return sys.stdin.readline().rstrip()


def main():
    H, W = map(int, input().split())
    A = [[0] * W for _ in range(H)]
    for i in range(H):
        a = list(map(int, input().split()))
        A[i] = a

    for i in range(H):
        b = list(map(int, input().split()))
        for j in range(W):
            A[i][j] -= b[j]

    dp = [[set() for i in range(W)] for i in range(H)]
    # dp[i][j][k]
    dp[0][0].add(A[0][0])

    for i in range(H):
        for j in range(W):
            if i != 0:
                for k in dp[i-1][j]:
                    dp[i][j].add(abs(k - A[i][j]))
                    dp[i][j].add(abs(k + A[i][j]))
            if j != 0:
                for k in dp[i][j-1]:
                    dp[i][j].add(abs(k - A[i][j]))
                    dp[i][j].add(abs(k + A[i][j]))

    print(min(dp[H-1][W-1]))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
N = int(input())
root = int(N**0.5)
for i in range(root,1,-1):
  if N % i ==0:
    break

print(N/i + i -2)


Fixed submission:
N = int(input())
root = int(N**0.5)
for i in range(root,-1,-1):
  if N % i ==0:
    break

print(int(N/i + i -2))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math


# input = sys.stdin.readline

def binary_search(arr, key,j):
    ok = j
    ng = len(arr)

    while abs(ok - ng) > 1:
        mid = int((ok + ng) / 2)

        if arr[mid] < key:
            ok = mid
        else:
            ng = mid

    return ok


def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    ans =0
    for i in range(N-2):
        for j in range(i+1,N-1):
            ok = binary_search(L,L[i]+L[j],j)
            ans += ok-j
    print(ans)
if __name__ == "__main__":
    main()


Fixed submission:
import sys
#import math


# input = sys.stdin.readline

def binary_search(arr, key,j):
    ok = j
    ng = len(arr)

    while abs(ok - ng) > 1:
        mid = int((ok + ng) / 2)

        if arr[mid] < key:
            ok = mid
        else:
            ng = mid

    return ok


def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    ans =0
    for i in range(N-2):
        for j in range(i+1,N-1):
            ok = binary_search(L,L[i]+L[j],j)
            ans += ok-j
    print(ans)
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque
import itertools
from collections import deque
sys.setrecursionlimit(10 ** 9)
import heapq
import numpy as np

# map(int, sys.stdin.read().split())


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    print(int(N*( N-1)/2))

    pass



if __name__ == "__main__":
    main()


Fixed submission:
import sys
from collections import deque
import itertools
from collections import deque
sys.setrecursionlimit(10 ** 9)

# map(int, sys.stdin.read().split())


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    print(int(N*(N-1)//2))




if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
S =input()
if int(S[:4])<2018:
  print("Heisei")
elif int(S[:4])>2019:
  print("TBD")
else:
  if int(S[6:8])>4:
    print("TBD")
  else:
    print("Heisei")

Fixed submission:
import sys
import math


def input():
    return sys.stdin.readline().rstrip()


def main():
    S = input()
    if int(S[:4]) < 2018:
        print("Heisei")
    elif int(S[:4]) > 2019:
        print("TBD")
    else:
        if int(S[5:7]) > 4:
            print("TBD")
        else:
            print("Heisei")

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
#import numpy as np
#from collections import defaultdict
import math
#from collections import deque

input = sys.stdin.readline



def main():


    N ,K= map(int,input().split())
    H = list(map(int,input().split()))
    H = [0] + H
    dp= [0] *(N+1)
    dp = [10**5] * (N + 1)
    dp[1] = 0

    for i in range(2, N + 1):
        way =[10**10]*(K+2)
        for j in range(1, K+1):
            if j<i:
                way[j]=(dp[i-j]+abs(H[i]-H[i-j]))
        dp[i] = min(way)


    print(dp[N])





if __name__ == "__main__":
    main()

Fixed submission:
import sys
#import numpy as np
#from collections import defaultdict
#import math
#from collections import deque

input = sys.stdin.readline



def main():


    N ,K= map(int,input().split())
    H = list(map(int,input().split()))
    H = [0] + H
    dp= [0] *(N+1)
    dp = [10**5] * (N + 1)
    dp[1] = 0

    for i in range(2, N + 1):
        way =[10**10]*(K+2)
        for j in range(1, K+1):
            if j<i:
                way[j]=(dp[i-j]+abs(H[i]-H[i-j]))
        dp[i] = min(way)


    print(dp[N])





if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
#import numpy as np
#from collections import defaultdict
import math
#from collections import deque

input = sys.stdin.readline



def main():


    N ,K= map(int,input().split())
    H = list(map(int,input().split()))
    H = [0] + H
    dp= [0] *(N+1)
    dp = [math.inf] * (N + 1)
    dp[1] = 0

    for i in range(2, N + 1):
        way =[]
        for j in range(1, K+1):
            if j<i:
                way.append(dp[i-j]+abs(H[i]-H[i-j]))
        dp[i] = min(way)


    print(dp[N])





if __name__ == "__main__":
    main()

Fixed submission:
import sys
#import numpy as np
#from collections import defaultdict
#import math
#from collections import deque

input = sys.stdin.readline



def main():


    N ,K= map(int,input().split())
    H = list(map(int,input().split()))
    H = [0] + H
    dp= [0] *(N+1)
    dp = [10**5] * (N + 1)
    dp[1] = 0

    for i in range(2, N + 1):
        way =[10**10]*(K+2)
        for j in range(1, K+1):
            if j<i:
                way[j]=(dp[i-j]+abs(H[i]-H[i-j]))
        dp[i] = min(way)


    print(dp[N])





if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
#import numpy as np
#from collections import defaultdict
import math
#from collections import deque

input = sys.stdin.readline
import numpy as np



def main():

    N,W = map(int,input().split())

    dp = [0] * (W+2)

    for _ in range(N):
        w,v = map(int,input().split())

        for j in range(W+1,w-1,-1):
            dp[j] =max(dp[j-w] +v ,dp[j])

    print(dp[W])
#    print(dp)




if __name__ == "__main__":
    main()

Fixed submission:
import sys
#import numpy as np
#from collections import defaultdict
import math
#from collections import deque

input = sys.stdin.readline
#import numpy as np



def main():

    N,W = map(int,input().split())

    dp = [0] * (W+2)

    for _ in range(N):
        w,v = map(int,input().split())

        for j in range(W+1,w-1,-1):
            dp[j] =max(dp[j-w] +v ,dp[j])

    print(dp[W])
#    print(dp)




if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
#import numpy as np
#from collections import defaultdict
import math
#from collections import deque

input = sys.stdin.readline
#import numpy as np



def main():

    N,W = map(int,input().split())

    dp = [0] * (W+2)

    for _ in range(N):
        w,v = map(int,input().split())

        for j in range(W+1,w-1,-1):
            dp[j] =max(dp[j-w] +v ,dp[j])

    print(dp[W])
#    print(dp)




if __name__ == "__main__":
    main()

Fixed submission:
import sys
import bisect


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, W = map(int, input().split())
    vsup = 10 ** 3 * N + 2
    dp = [10 ** 12 + 1] * (vsup)  # 価値の総和を i (以上にするための重さの最小値
    dp[0] = 0

    for i in range(N):
        w, v = map(int, input().split())
        for j in range(vsup-2, -1, -1):
            if j - v >= 0:
                dp[j] = min(dp[j], dp[j - v] + w)
            dp[j] = min(dp[j],dp[j+1])

    print(bisect.bisect_right(dp,W)-1)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
from functools import lru_cache
@lru_cache(maxsize = None)

edges, vertices = map(int, input().split())
dp = [None for _ in range(edges)]

nodes = [[] for _ in range(edges)]

for i in range(vertices):
    start, end = map(int, input().split())
    nodes[end -1].append(start-1)

for i in range(edges):
    if not len(nodes[i]):
        dp[i] = 0
@lru_cache(maxsize = None)
def find(arr):
    if not len(arr):
        return 0
    for x in arr:
        if dp[x] is None:
            dp[x] = find(nodes[x])
    return 1 + max(dp[x] for x in arr)

for i in range(edges):
    dp[i] = find(nodes[i])

print(max(dp))


Fixed submission:
import sys
sys.setrecursionlimit(10**6)
edges, vertices = map(int, input().split())
dp = [None for _ in range(edges)]

nodes = [[] for _ in range(edges)]

for i in range(vertices):
    start, end = map(int, input().split())
    nodes[end -1].append(start-1)

for i in range(edges):
    if not len(nodes[i]):
        dp[i] = 0
def find(arr):
    if not len(arr):
        return 0
    for x in arr:
        if dp[x] is None:
            dp[x] = find(nodes[x])
    return 1 + max(dp[x] for x in arr)

for i in range(edges):
    dp[i] = find(nodes[i])

print(max(dp))
Buggy python submission (verdict: Runtime Error):
N= int(input())
A = list(map(int,input().split()))
for i in range(N):
  A = A[i]+i+1
A.sort()
b =A[N//2]
ans =0
for a in A:
  ans += abs(a -b)
  
  
print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    A[i] = A[i] - i + 1
A.sort()
b = A[N // 2]
ans = 0
for a in A:
    ans += abs(a - b)

print(ans)
Buggy python submission (verdict: Runtime Error):
N = input()
n = int(N)
s =0
while N:
  s+= N%10
  N=N//10
if n%2==0:
  print("Yes")
else:
  print("No")

Fixed submission:
import sys
import math

def input():
    return sys.stdin.readline().rstrip()

def main():
    N = input()
    n = int(N)
    s = 0

    while n:
        s += n % 10
        n = n // 10
    if int(N) % s == 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
lb = [0] * len(B)
for i in range(len(B)):
    lb[i]= bisect.bisect_left(A,B[i])

ans = 0    
for i in range(len(C)):
    temp = bisect.bisect_left(B,C[i])
    ans +=sum(lb[0:temp])


print(ans)

Fixed submission:
import bisect
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
lb = [0] * (len(B)+1)
lsum = [0] * (len(B)+1)
temp = 0
for i in range(len(B)):
    lb[i]= bisect.bisect_left(A,B[i])
    
for i in range(len(B)):
    lsum[i] = lb[i] +lsum[i-1]


ans = 0    
for i in range(len(C)):
    temp = bisect.bisect_left(B,C[i])
    ans +=lsum[temp-1]


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

Fixed submission:
X, T =map(int,input().split())
print(max(0,X-T))