Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())

s = input()

count = []

for i in range(0, q) :
    l, r = map(int, input().split())
    print(str(s[l-1:r].count('AC')))

Fixed submission:
n, q = map(int, input().split())

s = input()

count = [0] * n

for i in range(n) :
    if s[i-1] + s[i] == 'AC' :
        count[i] = count[i-1] + 1
    else :
        count[i] = count[i-1]

for j in range(0, q) :
    l, r = map(int, input().split())
    print(count[r-1] - count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())

s = input()

count = []

for i in range(0, q) :
    l, r = map(int, input().split())
    count.append(str(s[l-1:r].count('AC')))

print('\n'.join(count))

Fixed submission:
n, q = map(int, input().split())

s = input()

count = [0] * n

for i in range(n) :
    if s[i-1] + s[i] == 'AC' :
        count[i] = count[i-1] + 1
    else :
        count[i] = count[i-1]

for j in range(0, q) :
    l, r = map(int, input().split())
    print(count[r-1] - count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())

s = input()

count = []

for i in range(0, q) :
    l, r = map(int, input().split())
    count.append(s[l-1:r].count('AC'))

for j in range(0,q) :
    print(count[j])


Fixed submission:
n, q = map(int, input().split())

s = input()

count = [0] * n

for i in range(n) :
    if s[i-1] + s[i] == 'AC' :
        count[i] = count[i-1] + 1
    else :
        count[i] = count[i-1]

for j in range(0, q) :
    l, r = map(int, input().split())
    print(count[r-1] - count[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

x_org = list(map(int, input().split()))

for i in range(n) :
    x = x_org[:]
    del x[i]
    x.sort()
    print(x[n // 2 - 1])

Fixed submission:
n = int(input())

x_org = list(map(int, input().split()))

x = sorted(x_org)

mid = x[n // 2 - 1]
midr = x[n // 2]

for i in range(n) :
    if x_org[i] <= mid :
        print(midr)
    else :
        print(mid)
Buggy python submission (verdict: Runtime Error):
c = []
c_diff = []
 
for i in range(3) :
    c.append([int(x) for x in input().split()])
 
for i in range(3) :
    c_diff.append([c[i][j] - c[i][0] for j in range(3)])
 
if c_diff[0] == c_diff[1] == c_diff[2] :
    print('Yes')
else :
    print('No')

Fixed submission:
n = int(input())
a = int(input())

if n % 500 <=a :
    print('Yes')
else :
    print('No')
Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())

s = []

for i in range(l) :
    s.append(input())

s.sort()

print(*s, sep='')

Fixed submission:
n, l = map(int, input().split())

s = []

for i in range(n) :
    s.append(input())

s.sort()

print(*s, sep='')
Buggy python submission (verdict: Runtime Error):

import math

X = int(input())
  
#素数判定
#Nが素数か True/False で返す
#O(√N)
def is_prime(N):
    if N == 1:
        return False
    for i in range(2,N+1):
        #調べるのはNの1/2乗まででよい
        if i * i > N:
            break
        #割り切れたら素数じゃない
        if N % i == 0:
            return False
    
    return True

for i in range(X,10**10):
    if isPrime(i):
        print(i)
        break


Fixed submission:

import math

X = int(input())

#xが素数か判定する    
def isPrime(x):
    if x == 2:
        return True

    if x < 2 or x % 2 == 0:
        return False
    
    i = 3
    while i <= math.sqrt(x):
        if x % i == 0:
            return False
        i += 2    
    return True

for i in range(X,10**10):
    if isPrime(i):
        print(i)
        break
Buggy python submission (verdict: Runtime Error):

#ユークリッドの互除法( A < B　とし, O(logA))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

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

#3個以上の最大公約数を求める必要がある
# res=0 と初期化して、res=gcd(res,x[i])と更新する
# gcd(a,b,c,....) → gcd(gcd(gcd(a,b),c),...) 
res = 0
x = list(map(int,input().split()))

for i in range(N):
    res = gcd(res,abs(x[i] - X))

print(res)


Fixed submission:

import math
import fractions

x,y = map(int,input().split())

print((x * y) // fractions.gcd(x, y))

Buggy python submission (verdict: Runtime Error):

import math

x,y = map(int,input().split())

print((x * y) // math.gcd(x, y))



Fixed submission:

import math
import fractions

x,y = map(int,input().split())

print((x * y) // fractions.gcd(x, y))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

a = list(map(int,input().split()))

#count = 0
#numdict = {}

number = 1
for i in range(N):
    print(a.index(i+1) + 1)


Fixed submission:

N = int(input())

a = list(map(int,input().split()))
b = list(range(N))


dict_a = dict(zip(a,b))

for i in range(1,N+1):
    print(dict_a[i]+1,end=' ')
Buggy python submission (verdict: Time Limit Exceeded):

import math

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

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

for i in range(M):
    max_A = max(A)
    A[A.index(max_A)] = math.floor((max_A) / 2)

print(sum(A))


Fixed submission:

#優先度付きキュー
#値の追加 O(log|Q|)
#値の削除 O(log|Q|)
#最大値の取得 O(1)
#pythonでは 最小値のみしか取得できないため事前に全要素に-1をかけておき最後のまた-1かける

import math
import heapq

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

#各要素を-1倍
A = list(map(int,input().split()))
A = list(map(lambda x: x*-1,A))
heapq.heapify(A)

for i in range(M):
    max_A = heapq.heappop(A)
    max_A = max_A * -1
    heapq.heappush(A,-1* (math.floor((max_A) / 2)) )

print(-1 * sum(A))
Buggy python submission (verdict: Runtime Error):

#L,Rの境界の数だけで処理を済ませる
#⇒いちいち書いてあるとおりに実装しない。

#内側の不幸な人を(RLの人)を消せば幸福な人が2人増える (全部Rに変えていくイメージ)
# ⇒着目するのは RL でも LR　でもどっちでもいい。
#  LRに注目する場合はこのあとのコードのRとLに関連する部分が逆になるだけ
#端っこなら１人増える
#幸福な人の最大値は N - 1

N,K = map(int,input().split())
S = input()

#端以外の人のせいで不幸な人の数
count = 0
#端の人のせいで不幸な人の数
edge_count = 0

#端のせいで不幸な人
if S[0] == 'L':
    edge_count += 1
if S[N-1] == 'R':
    edge_count += 1 

#端以外のせいで不幸になっている人の数を数える (RLを探す)
for i in range(N):
    if S[i] == 'R':
        if S[i+1] == 'L':
            count += 1

#最初の時点で幸せになれる人の数
happy = N  - (count*2 + edge_count)

#操作回数KがRLの数より小さい
if count >= K:
    print(min(N-1, K * 2 + happy  ))
#操作回数K がRLの数より大きい
else:
    print(min(N-1, K * 2 + happy + (min(edge_count,K - count) )))


Fixed submission:

#L,Rの境界の数だけで処理を済ませる
#⇒いちいち書いてあるとおりに実装しない。

#内側の不幸な人を(RLの人)を消せば幸福な人が2人増える (全部Rに変えていくイメージ)
# ⇒着目するのは RL でも LR　でもどっちでもいい。
#  LRに注目する場合はこのあとのコードのRとLに関連する部分が逆になるだけ
#端っこなら１人増える
#幸福な人の最大値は N - 1

N,K = map(int,input().split())
S = input()

#端以外の人のせいで不幸な人の数
count = 0
#端の人のせいで不幸な人の数
edge_count = 0

#端のせいで不幸な人
if S[0] == 'L':
    edge_count += 1
if S[N-1] == 'R':
    edge_count += 1 

#端以外のせいで不幸になっている人の数を数える (RLを探す)
for i in range(N-1):
    if S[i] == 'R':
        if S[i+1] == 'L':
            count += 1

#最初の時点で幸せになれる人の数
happy = N  - (count*2 + edge_count)

#操作回数KがRLの数より小さい
if count >= K:
    print(min(N-1, K * 2 + happy  ))
#操作回数K がRLの数より大きい
else:
    print(min(N-1, K * 2 + happy + (min(edge_count,K - count) )))
Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
ans = 0

#一個ずらしがよさげ
for i in range(N):
    ans += i

print(ans)


Fixed submission:
N = int(input())

#一つずらしが余りの最大になりそう
#答えは1からN-1までを足した数

ans =N * (N-1) //2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
S = []

ans = 0

for i in range(N):
    S.append(sorted(list(input())))

for i in range(N-1):
    for j in range(i+1,N):
        if S[i] == S[j]:
            ans += 1

print(ans)

Fixed submission:

N = int(input())
anagram_dict = {}
ans = 0

for i in range(N):
    s= ''.join(sorted(list(input())))
    if s in anagram_dict:
        ans += anagram_dict[s]
        anagram_dict[s] += 1
    else:
        anagram_dict[s]=1

print(ans)
Buggy python submission (verdict: Runtime Error):

import math

A,B,C,D = map(int,input().split())

U = B - A + 1

nA = ( math.floor(B / C) ) - (math.ceil(A / C)) +1

nB = ( math.floor(B / D) ) - (math.ceil(A / D)) +1

saisyoukoubaisuu = C * D / math.gcd(C, D)

saisyoukoubaisuu = int(saisyoukoubaisuu)

nAB = (B//saisyoukoubaisuu) -(B//saisyoukoubaisuu) + 1

print( U -(nA + nB - nAB) )


Fixed submission:

import fractions

#入力
A,B,C,D = map(int,input().split())

l = C * D / fractions.gcd(C, D)
l = int(l)

#条件を満たすB以下の整数の個数
Bn = B -  (B//C + B//D - B//l) 

#条件を満たすA-1以下の整数の個数
An = (A-1) - ((A-1)//C + (A-1)//D - (A-1)//l) 

print(Bn-An)

Buggy python submission (verdict: Runtime Error):

import math

A,B,C,D = map(int,input().split())
count = 0

U = B - A + 1

nA = ( math.floor(B / C) ) - (math.ceil(A / C)) +1

nB = ( math.floor(B / D) ) - (math.ceil(A / D)) +1

saisyoukoubaisuu = C * D / math.gcd(C, D)

saisyoukoubaisuu = int(saisyoukoubaisuu)

nAB = (B//saisyoukoubaisuu) -(B//saisyoukoubaisuu) + 1

print( U -(nA + nB - nAB) )


Fixed submission:

import fractions

#入力
A,B,C,D = map(int,input().split())

l = C * D / fractions.gcd(C, D)
l = int(l)

#条件を満たすB以下の整数の個数
Bn = B -  (B//C + B//D - B//l) 

#条件を満たすA-1以下の整数の個数
An = (A-1) - ((A-1)//C + (A-1)//D - (A-1)//l) 

print(Bn-An)

Buggy python submission (verdict: Runtime Error):

import math

A,B,C,D = map(int,input().split())
count = 0

U = B - A + 1

nA = ( math.floor(B / C) ) - (math.ceil(A / C)) +1

nB = ( math.floor(B / D) ) - (math.ceil(A / D)) +1

saisyoukoubaisuu = C * D / math.gcd(C, D)

saisyoukoubaisuu = int(saisyoukoubaisuu)

nAB = (B//saisyoukoubaisuu) -(B//saisyoukoubaisuu) + 1

print( U -(nA + nB - nAB) )


Fixed submission:

import fractions

#入力
A,B,C,D = map(int,input().split())

l = C * D / fractions.gcd(C, D)
l = int(l)

#条件を満たすB以下の整数の個数
Bn = B -  (B//C + B//D - B//l) 

#条件を満たすA-1以下の整数の個数
An = (A-1) - ((A-1)//C + (A-1)//D - (A-1)//l) 

print(Bn-An)
Buggy python submission (verdict: Runtime Error):

import copy

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

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

B =[]
C =[]

tA = []
ans = sum(A)

for i in range(M):
    b,c = map(int,input().split())
    B.append(b)
    C.append(c)

for i in range(N):
    for j in range(M):
        tA = copy.copy(A)
        for k in range(B[j]):
            if tA[i] < C[j]:
                tA[i] = C[j]
        if sum(tA) > ans:
            ans = sum(tA)

print (ans)


Fixed submission:


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

if A >= 13 :
    print(B)
elif A >= 6 :
    print(B//2)
else :
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):

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

li = []

ans = 0

for i in range(M):
    x,y = map(int,input().split())
    li.append([x,y])

for i in range(1,N+1):
    count = 0
    for j,k in li :
        if j <= i and i <= k :
            count += 1
            if count == len(li):
                ans += 1
        else:
            break

print(ans)


Fixed submission:

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

L = []
R = []

ans = 0

for i in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)

Lmax = max(L)
Rmin = min(R)

for i in range(1,N+1):
    if Lmax <= i and i <= Rmin:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = [int(i) for i in input().split()]

# 無限大の値
f_inf = float('inf')

# DP テーブルを初期化　(最小化問題なので INF に初期化)
dp = [f_inf] * n

# 初期条件
dp[0] = 0

# 足場 i-1 から足場 i へ移動する。コストは|h[i]−h[i-1]|
# 足場 i-2 から足場 i へと移動する コストは |h[i]−h[i-2]|
for i in range(1, n):
    dp[i] = chmin(dp[i], dp[i - 1] + abs(h[i] - h[i-1]))
    # 一番目の足場では一つ前しか存在しない
    if i > 1:
        dp[i] = chmin(dp[i], dp[i - 2] + abs(h[i] - h[i -2]))

print(dp[n-1])


Fixed submission:
N = int(input())
H = [int(x) for x in input().split()]
dp = [0] * N
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]))
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):

import bisect

N = int(input())

Ai = list(map(int,input().split()))
Bi = list(map(int,input().split()))
Ci = list(map(int,input().split()))

Bi.sort()
Ci.sort()

ans = 0

for i in range(len(Ai)):
    #Ai[i]より大きいものの絞り込み (以上ならleft、より大きいならright)
    bi = bisect.bisect_right(Bi,Ai[i])
    #Biのどの値もAi[i]より大きくないなら無理
    if bi >= len(Bi):
        continue
    #Bi[bi]以降がiよりも大きい(中部として使える)
    for j in range(bi,len(Bi)):
        #Bi[bi]以降が中部として使えるので次は下部として使える範囲を絞り込む
        ci = bisect.bisect_right(Ci,Bi[j])
        #Ciのどの値もBi[i]より大きくないなら無理
        if ci >= len(Ci):
            continue
        #Ci[ci]以降が下部として使える
        ans += len(Ci) - ci

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()
C.sort()

ans = 0

#中央を固定する
for bi in B:
    #biより小さいものをAから絞り込む
    ai = bisect.bisect_left(A,bi)
    #biより大きいものをCから絞り込む
    ci = len(C) - bisect.bisect_right(C,bi)

    ans += ai * ci

print(ans)
Buggy python submission (verdict: Runtime Error):
s=int(input())
w=int(input())
if(s<=w):
  print("unsafe")
else:
  print("safe")

Fixed submission:
s,w=(int(x) for x in input().split())
if(s<=w):
  print("unsafe")
else:
  print("safe")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
ans = 0
sum_n = [0]*n
sumall = sum(l)
sum_n = list(sumall-sum(l[:i+1]) for i in range(n))
for i in range(n):
    ans += ((l[i]*sum_n[i])%1000000007)
print(ans%1000000007)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
ans = 0
sum_n = [0]*n
sum_n[0] = l[0]
sumall = sum(l)
for i in range(1,n):
    sum_n[i] = sum_n[i-1] + l[i]
for i in range(n):
    ans += ((l[i]*(sumall-sum_n[i]))%1000000007)
print(ans%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
ans = 0
sum_n = [0]*n
for i in range(n):
    sum_n[i] = sum(l[i+1:n]) 
for i in range(n):
    ans += ((l[i]*sum_n[i])%1000000007)
print(ans%1000000007)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
ans = 0
sum_n = [0]*n
sum_n[0] = l[0]
sumall = sum(l)
for i in range(1,n):
    sum_n[i] = sum_n[i-1] + l[i]
for i in range(n):
    ans += ((l[i]*(sumall-sum_n[i]))%1000000007)
print(ans%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans += ((l[i]*sum(l[i+1:n]))%1000000007)
print(ans%1000000007)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
ans = 0
sum_n = [0]*n
sum_n[0] = l[0]
sumall = sum(l)
for i in range(1,n):
    sum_n[i] = sum_n[i-1] + l[i]
for i in range(n):
    ans += ((l[i]*(sumall-sum_n[i]))%1000000007)
print(ans%1000000007)

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans += ((l[i]*sum(l[i+1:n]))%1000000007
print(ans%1000000007)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
ans = 0
sum_n = [0]*n
sum_n[0] = l[0]
sumall = sum(l)
for i in range(1,n):
    sum_n[i] = sum_n[i-1] + l[i]
for i in range(n):
    ans += ((l[i]*(sumall-sum_n[i]))%1000000007)
print(ans%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
ans = 0
for i in range(n):
    for j in range(i+1,n):
        ans += ((l[i]*l[j])%1000000007)
print(ans%1000000007)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
ans = 0
sum_n = [0]*n
sum_n[0] = l[0]
sumall = sum(l)
for i in range(1,n):
    sum_n[i] = sum_n[i-1] + l[i]
for i in range(n):
    ans += ((l[i]*(sumall-sum_n[i]))%1000000007)
print(ans%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
ans = 0
for i in range(n):
    for j in range(i+1,n):
        ans += l[i]*l[j]
print(ans%1000000007)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
ans = 0
sum_n = [0]*n
sum_n[0] = l[0]
sumall = sum(l)
for i in range(1,n):
    sum_n[i] = sum_n[i-1] + l[i]
for i in range(n):
    ans += ((l[i]*(sumall-sum_n[i]))%1000000007)
print(ans%1000000007)
Buggy python submission (verdict: Runtime Error):
import numpy as np
h,w,m = map(int,input().split())
bomb = list(tuple(map(lambda x: int(x)-1,input().split())) for i in range(m))
Map= np.zeros((h,w))
for i in bomb:
    Map[i] = 1
    
bombx = np.count_nonzero(Map,axis=0)
bomby = np.count_nonzero(Map,axis=1)
maxx = max(bombx)
maxy = max(bomby)
maxx_index = np.where(bombx == maxx)
maxy_index = np.where(bomby == maxy)

flag = 0
for i in maxx_index[0]:
    for j in maxy_index[0]:
        if Map[i][j] == 0:
            flag = 1
if flag == 0:
    print(maxx+maxy)
else:
    print(maxx+maxy-1)

Fixed submission:
n,x,t = map(int,input().split())
cnt = -((-n)//x)
print(t*cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
ans = 0

for i in range(n):
  if A[i]>A[i+1]:
    A[i+1]=A[i]
    ans += A[i]-A[i+1]

print(ans)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
ans = 0
 
for i in range(n-1):
  if A[i]>A[i+1]:
    ans += A[i]-A[i+1]
    A[i+1] = A[i]
 
print(ans)
Buggy python submission (verdict: Runtime Error):
int x = int(input())
if x >= 30:
  print("Yes")
else:
  print("No")

Fixed submission:
x = int(input())
if x >= 30:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
int x = int(input())
if x >= 30:
  print("yes")
else:
  print("no")

Fixed submission:
x = int(input())
if x >= 30:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import math

info = list(map(int, input().split()))
num = info[0]
dis = info[1]
A = [list(map(int, input().split())) for i in range(num)]
disA = [math.squart(A[i][0]^2 + A[i][1]^2) for i in range(num)]
cnt = 0 
for i in range(num):
    if disA <= dis:
        cnt += 1
print(cnt)


Fixed submission:
import math

info = list(map(int, input().split()))
num = info[0]
dis = info[1]
A = [list(map(int, input().split())) for i in range(num)]
disA = [math.sqrt(A[i][0]**2 + A[i][1]**2) for i in range(num)]
cnt = 0 
for i in range(num):
    if disA[i] <= dis:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = list(input().split())
A = int(N[0])
b1,b2 = N[1].split('.')
B = int(b1+b2)
prd = list(str(A*B))
ans = 0
if len(prd) < 3:
    ans = 0
else:
    prd.pop(-1,-2)
    ans = int(''.join(prd))
print(ans)


Fixed submission:
N = list(input().split())
A = int(N[0])
b1,b2 = N[1].split('.')
B = int(b1+b2)
prd = list(str(A*B))
ans = 0
if len(prd) < 3:
    ans = 0
else:
    prd.pop()
    prd.pop()
    ans = int(''.join(prd))
print(ans)

Buggy python submission (verdict: Runtime Error):
N = list(input().split())
A = int(N[0])
b1,b2 = N[1].split('.')
B = int(b1+b2)
prd = list(string(A*B))
ans = int(prd[0]+prd[1]+prd[2])
print(ans)


Fixed submission:
N = list(input().split())
A = int(N[0])
b1,b2 = N[1].split('.')
B = int(b1+b2)
prd = list(str(A*B))
ans = 0
if len(prd) < 3:
    ans = 0
else:
    prd.pop()
    prd.pop()
    ans = int(''.join(prd))
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
N = list(input().split())
A = int(N[0])
B = int(N[0])*100 + int(N[2])*10 + int(N[3])
prd = A*B/100
prd = math.floor(prd)
print(prd)

Fixed submission:
N = list(input().split())
A = int(N[0])
b1,b2 = N[1].split('.')
B = int(b1+b2)
prd = list(str(A*B))
ans = 0
if len(prd) < 3:
    ans = 0
else:
    prd.pop()
    prd.pop()
    ans = int(''.join(prd))
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))

for i in range(n):
    l[i] = l[i] - i-1
print(sorted(l))
if n % 2 == 1:
    print(sum(list(map(lambda x: x-l[((n//2)+1)],l))))
else:
    print(max(sum(list(map(lambda x: x-l[(n//2)],l))),sum(list(map(lambda x: x-l[((n//2)+1)],l)))))


Fixed submission:
n = int(input())
l = list(map(int,input().split()))

for i in range(n):
    l[i] = l[i] - i-1
l.sort()
if n % 2 == 1:
    print(sum(list(map(lambda x: abs(x-l[((n//2))]),l))))
else:
    print(min(sum(list(map(lambda x: abs(x-l[(n//2)-1]),l))),sum(list(map(lambda x: abs(x-l[(n//2)]),l)))))
Buggy python submission (verdict: Runtime Error):
nlist = list(map(int,input()))
rev_n = reversed(nlist)
sn = sum(nlist)
n = 0

for i in range(len(nlist)):
    n += rev_n[i]*(10**i) 
if n%sn == 0:
    print("Yes")
else:
    print("No")

Fixed submission:
nlist = list(map(int,input()))
rev_n = list(reversed(nlist))
sn = sum(nlist)
n = 0

for i in range(len(nlist)):
    n += rev_n[i]*(10**i) 
if n%sn == 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
A = list(map(int,input.split()))

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






Fixed submission:
n,k = map(int,input().split())
A = list(map(int,input().split()))

print(-((1-n)//(k-1)))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a<9 || b<9:
  print("Yay!")
else:
  print(":(")

Fixed submission:
a,b = map(int,input().split())
if a<9 and b<9:
  print("Yay!")
else:
  print(":(")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
cnt = 0

for i in range(N):
  while A[i]%2 == 0:
    cnt += 1

print(cnt)
    

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
cnt = 0
 
for i in range(N):
  while A[i]%2 == 0:
    A[i] = A[i]/2
    cnt += 1
    
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
sum = 0
a_list = list(map(int, input().split()))
# print(a_list)
num = [0] * 10 ** 5
for i in range(n):
    num[a_list[i]] += 1
    sum += a_list[i]

q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    sum += (c - b) * num[b]
    num[c] += num[b]
    num[b] = 0
    print(sum)

    







Fixed submission:
n = int(input())
sum = 0
a_list = list(map(int, input().split()))
num = [0] * (10 ** 5 + 1)
for i in range(n):
    num[a_list[i]] += 1
    sum += a_list[i]

q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    sum += (c - b) * num[b]
    num[c] += num[b]
    num[b] = 0
    print(sum)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import fractions

s=str(input())
for i in range(len(s)):
    if(i%2==0):
        if(s[i]!='h' or s[i+1]!='i'):
            print("No")
            exit(0)
    if(s[i]!='h' and s[i]!='i'):
        print("No")
        exit(0)
print("Yes")

Fixed submission:
import numpy as np
import fractions

s=str(input())
if(len(s)%2==1):
    print("No")
    exit(0)
for i in range(len(s)-1):
    if(i%2==0):
        if(s[i]!='h' or s[i+1]!='i'):
            print("No")
            exit(0)
    if(s[i]!='h' and s[i]!='i'):
        print("No")
        exit(0)
if(s[len(s)-1]!='h' and s[len(s)-1]!='i'):
    print("No")
    exit(0)
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
s=str(input())
q=int(input())
kt=0
for k in range(q):
    List=list(map(str,input().split()))
    if(List[0]=="1"):
        kt+=1
    else:
        if(kt%2==1):
            s=s[::-1]
        kt=0
        if(List[1]=="1"):
            List[2]+=s
            s=List[2]
        else:
            s+=List[2]
    # print(s)
if(kt%2==1):
    s=s[::-1]
print(s)



Fixed submission:
from collections import deque
S = deque(input())
Q = int(input())
 
p = 0
 
for i in range(Q):
    query = input().split()
    if query[0]=='1':
        p ^= 1
    else:
        f = int(query[1])-1
        c = query[2]
        if p:
            f ^= 1
        if f:
            S.append(c)
        else:
            S.appendleft(c)
 
if p:
    print(*reversed(S), sep='')
else:
    print(*S, sep='')
Buggy python submission (verdict: Runtime Error):
INF=int(float('inf'))

a,b=map(int,input().split())
if(a>=10):
    print(b)
else:
    print(b+(100*(10-a)))

Fixed submission:


a,b=map(int,input().split())
if(a>=10):
    print(b)
else:
    print(b+(100*(10-a)))
Buggy python submission (verdict: Runtime Error):
a=input.sprit()
a=''.join(a)
print(a)

Fixed submission:
List=list(map(str,input().split()))
List.reverse()
print(''.join(List))