Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b =map(int,input().split())
print("GREATER" if a>b else "LESS" if a<b else "equal")

Fixed submission:
a = int(input())
b = int(input())
print("GREATER" if a>b else "LESS" if a<b else "EQUAL")
Buggy python submission (verdict: Runtime Error):
a,b=input.split()
print("H" if a==b else "D")

Fixed submission:
a,b=input().split()
print("H" if a==b else "D")
Buggy python submission (verdict: Runtime Error):

import numpy as np
from scipy import signal

N = int(input())
H = list(map(int, input().split(" ")))

H = np.array(H)

ans = 'Yes'
min_ind = signal.argrelmin(H)[0]
tmp_ind = 0
for ind in min_ind:
    
    if H[tmp_ind:ind].max() > H[ind]+1:
        ans = 'No'
        break
    tmp_ind = ind

if H[tmp_ind:-1].max() > H[-1]+1:
    ans = 'No'

print(ans)



Fixed submission:

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

if C+B > A:
    d = (C+B)-A
else:
    d = 0

print(d)

Buggy python submission (verdict: Runtime Error):

import numpy as np
from scipy import signal

N = int(input())
H = list(map(int, input().split(" ")))

H = np.array(H)

ans = 'Yes'
min_ind = signal.argrelmin(H)[0]
tmp_ind = 0
for ind in min_ind:
    
    if H[tmp_ind:ind].max() > H[ind]+1:
        ans = 'No'
        break
    tmp_ind = ind

if H[tmp_ind:ind].max() > H[-1]+1:
    ans = 'No'

print(ans)


Fixed submission:

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

if C+B > A:
    d = (C+B)-A
else:
    d = 0

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

H_ls = list(map(int,input().split(" ")))

h_left = H_ls[0]-1

ans = "Yes"
for h in H_ls:
    if h_left < h:
        h-=1:
    elif h_left > h:
        ans = 'No'
        break:
    h_left = h

print(ans)


Fixed submission:
N = int(input())

H_ls = list(map(int,input().split(" ")))

h_left = H_ls[0]-1

ans = "Yes"
for h in H_ls:
    if h_left < h:
        h-=1
    elif h_left > h:
        ans = 'No'
        break
    h_left = h

print(ans)

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

H_ls = list(map(int,input().split(" ")))

h_left = H_ls[0]-1

ans = "Yes"
for h in H_ls:
    if h_left < h:
        h-=1:
    elif h_left > h:
        ans = 'No'
        break:
    h_left = h

print(ans)


Fixed submission:
N = int(input())

H_ls = list(map(int,input().split(" ")))

h_left = H_ls[0]-1

ans = "Yes"
for h in H_ls:
    if h_left < h:
        h-=1
    elif h_left > h:
        ans = 'No'
        break
    h_left = h

print(ans)

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

H_ls = list(map(int,input().split("")))

h_left = H_ls[0]-1

ans = "Yes"
for h in H_ls:
    if h_left < h:
        h-=1:
    elif h_left > h:
        ans = 'No'
        break:
    h_left = h

print(ans)


Fixed submission:
N = int(input())

H_ls = list(map(int,input().split(" ")))

h_left = H_ls[0]-1

ans = "Yes"
for h in H_ls:
    if h_left < h:
        h-=1
    elif h_left > h:
        ans = 'No'
        break
    h_left = h

print(ans)

Buggy python submission (verdict: Runtime Error):

import numpy as np
from scipy import signal

N = int(input())
H = list(map(int, input().split(" ")))

H = np.array(H)

H_dif = H[1:]-H[:-1]

if (H_dif <=-2).any() == True:
    ans = "No"
elif (H_dif >= 0).all() == True:
    ans = "Yes"

else:
    ans = 'Yes'
    min_ind = signal.argrelmin(H)[0]
    tmp_ind = 0
    for ind in min_ind:
        
        if H[tmp_ind:ind].max() > H[ind]+1:
            ans = 'No'
            break
        tmp_ind = ind

    if H[tmp_ind:ind].max() > H[-1]+1:
        ans = 'No'

print(ans)

Fixed submission:
N = int(input())

H_ls = list(map(int,input().split(" ")))

h_left = H_ls[0]-1

ans = "Yes"
for h in H_ls:
    if h_left < h:
        h-=1
    elif h_left > h:
        ans = 'No'
        break
    h_left = h

print(ans)

Buggy python submission (verdict: Runtime Error):

import numpy as np
N = int(input())
H = list(map(int, input().split(" ")))

H = np.array(H)

H_dif = H[1:]-H[:-1]

if (H_dif <=-2).any() == True:
    answer = "No"

elif (H_dif >= 0).all() == True:
    ans = "Yes"
else:
    H_check = (H_dif == -1)
    H_c = H_check[1:].dot(H_check[:-1])
    if (H_c == 1).any() == True:
        ans = "No"
    else:
        ans = "Yes"

print(ans)


Fixed submission:
N = int(input())

H_ls = list(map(int,input().split(" ")))

h_left = H_ls[0]-1

ans = "Yes"
for h in H_ls:
    if h_left < h:
        h-=1
    elif h_left > h:
        ans = 'No'
        break
    h_left = h

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

import numpy as np
N = int(input())

A_ls = np.array(list(map(int,input().split(" "))))
B_ls = np.array(list(map(int,input().split(" "))))

S = 0

for i,b in enumerate(B_ls):
    if b > A_ls[i]:
        b -= A_ls[i]
        S += A_ls[i]
        if A_ls[i+1] >= b:
            A_ls[i+1] -=b
            S+=b
        else:
            S+=A_ls[i+1]
            A_ls[i+1] = 0 
    else:
        S += b

print(S)


Fixed submission:

import numpy as np
N = int(input())

A_ls = np.array(list(map(int,input().split(" "))))
B_ls = np.array(list(map(int,input().split(" "))))

S = 0

for i,b in enumerate(B_ls):
    if b > A_ls[i]:
        b -= A_ls[i]
        S += A_ls[i]
        if A_ls[i+1] >= b:
            A_ls[i+1] -=b
            S+=b
        else:
            S+=A_ls[i+1]
            A_ls[i+1] = 0 
    else:
        S += b

print(S)

Buggy python submission (verdict: Runtime Error):

import numpy as np
N = int(input())

A_ls = np.array(list(map(int,input().split(" "))))
B_ls = np.array(list(map(int,input().split(" "))))

S = 0

for i,b in B_ls:
    if b > A_ls[i]:
        A_ls[i] == 0
        b -= A_ls[i]
        S += A_ls[i]
        if A_ls[i+1] >= b:
            A_ls[i+1] -=b
            S+=b
        else:
            A_ls[i+1] = 0
            S+=(A_ls[i+1])
    else:
        S += b

print(S)


Fixed submission:

import numpy as np
N = int(input())

A_ls = np.array(list(map(int,input().split(" "))))
B_ls = np.array(list(map(int,input().split(" "))))

S = 0

for i,b in enumerate(B_ls):
    if b > A_ls[i]:
        b -= A_ls[i]
        S += A_ls[i]
        if A_ls[i+1] >= b:
            A_ls[i+1] -=b
            S+=b
        else:
            S+=A_ls[i+1]
            A_ls[i+1] = 0 
    else:
        S += b

print(S)

Buggy python submission (verdict: Runtime Error):

import numpy as np
N = int(input())

A_ls = np.array(list(map(int,input().split(" "))))
B_ls = np.array(list(map(int,input().split(" "))))

S = 0

for i,a in A_ls:
    if a > B_ls[i]:
        B_ls[i] == 0
        a -= B_ls[i]
        S += B_ls[i]
        if B_ls[i+1] >= a:
            B_ls[i+1] -=a
            S+=a
        elif:
            B_ls[i+1] = 0
            S+=(B_ls[i+1])
    elif:
        S += a

print(S)


Fixed submission:

import numpy as np
N = int(input())

A_ls = np.array(list(map(int,input().split(" "))))
B_ls = np.array(list(map(int,input().split(" "))))

S = 0

for i,b in enumerate(B_ls):
    if b > A_ls[i]:
        b -= A_ls[i]
        S += A_ls[i]
        if A_ls[i+1] >= b:
            A_ls[i+1] -=b
            S+=b
        else:
            S+=A_ls[i+1]
            A_ls[i+1] = 0 
    else:
        S += b

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

N = int(input())
A = np.zeros(N)

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

ind = A.argsort()[:2:-1]

first_a = A[ind[0]]
second_a = A[ind[1]]

for i, a in enumerate(A):
    if i == ind[0]:
        print(second_a)
    else:
        print(first_a)



Fixed submission:
import numpy as np

N = int(input())
A = np.zeros(N)

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

ind = A.argsort()[::-1][:2]

first_a = A[ind[0]]
second_a = A[ind[1]]

for i, a in enumerate(A):
    if i == ind[0]:
        print(int(second_a))
    else:
        print(int(first_a))

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

N = int(input())
A = np.zeros(N)

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

ind = A.argsort()[:2]

first_a = A[ind[0]]
second_a = A[ind[1]]

for i, a in A:
    if i == ind[0]:
        print(second_a)
    else:
        print(first_a)



Fixed submission:
import numpy as np

N = int(input())
A = np.zeros(N)

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

ind = A.argsort()[::-1][:2]

first_a = A[ind[0]]
second_a = A[ind[1]]

for i, a in enumerate(A):
    if i == ind[0]:
        print(int(second_a))
    else:
        print(int(first_a))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a_ls = list(map(int,input().split(" ")))
N = [0]*N
l = len(a_ls)

# 大きい方からチェック
for i in range(l):
    a = a_ls[-(i+1)]
    s = sum(N[(l-i)-1::(l-i)])%2
    # print(s)
    # print(a)
    if a != s:
        N[-(i+1)]=1
        
sen = ""
for i,n in enumerate(N):
    if n == 1:
        sen += "{} ".format(i+1)

if len(sen) == 0:
    print(0)
else:
    print(sum(N))
    print(sen[:-1])


Fixed submission:
N = int(input())
a_ls = list(map(int,input().split(" ")))
N = [0]*N
l = len(a_ls)

# 大きい方からチェック
for i in range(l):
    a = a_ls[-(i+1)]
    s = sum(N[(l-i)-1::(l-i)])%2
    # print(s)
    # print(a)
    if a != s:
        N[-(i+1)]=1
        
sen = ""
for i,n in enumerate(N):
    if n == 1:
        sen += "{} ".format(i+1)

if len(sen) == 0:
    print(0)
else:
    print(sum(N))
    print(sen[:-1])
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int,input().split(" "))

m = 2018
for l in range(L,R):
    for r in range(l+1,R+1):
        m = min(m,l*r%2019)

print(m)


Fixed submission:
L, R = map(int,input().split(" "))

m = 2018

if R-L>=2019:
    print(0)
    exit()

for l in range(L,R):
    for r in range(l+1,R+1):
        m = min(m,l*r%2019)

print(m)
Buggy python submission (verdict: Runtime Error):
N = int(input())
h_ls = list(map(int,input().split(" ")))

h_ls = np.array(h_ls)
n = 0
h_len = len(h_ls)
while max(h_ls)!=0:
    max_ind = h_ls.argmax()
    d = 0
    while max_ind+d < h_len -1 and h_ls[max_ind+d+1]==h_ls[max_ind]:
        d+=1
    h_ls[max_ind:max_ind+d+1] =h_ls[max_ind:max_ind+d+1]-1
    n+=1

print(n)


Fixed submission:
import numpy as np

N = int(input())
h_ls = list(map(int,input().split(" ")))

h_ls = np.array(h_ls)
n = 0
h_len = len(h_ls)
while max(h_ls)!=0:
    max_ind = h_ls.argmax()
    d = 0
    while max_ind+d < h_len -1 and h_ls[max_ind+d+1]==h_ls[max_ind]:
        d+=1
    h_ls[max_ind:max_ind+d+1] =h_ls[max_ind:max_ind+d+1]-1
    n+=1

print(n)

Buggy python submission (verdict: Runtime Error):
N = int(input())
h_ls = list(map(int,input().split(" ")))

h_ls = np.array(h_ls)
n = 0
h_len = len(h_ls)
while max(h_ls)!=0:
    max_ind = h_ls.argmax()
    d = 0
    while max_ind+d < h_len -1 and h_ls[max_ind+d+1]==h_ls[max_ind]:
        d+=1
    h_ls[max_ind:max_ind+d+1] =h_ls[max_ind:max_ind+d+1]-1
    n+=1
    print(h_ls)

print(n)


Fixed submission:
import numpy as np

N = int(input())
h_ls = list(map(int,input().split(" ")))

h_ls = np.array(h_ls)
n = 0
h_len = len(h_ls)
while max(h_ls)!=0:
    max_ind = h_ls.argmax()
    d = 0
    while max_ind+d < h_len -1 and h_ls[max_ind+d+1]==h_ls[max_ind]:
        d+=1
    h_ls[max_ind:max_ind+d+1] =h_ls[max_ind:max_ind+d+1]-1
    n+=1

print(n)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
count = 0
for a in range(1, n+1):
  for b in range(1, n+1):
    if a * b < n: count += 1
    else: break
print(count)

Fixed submission:
n = int(input())
count = 0
for a in range(1, n+1):
  for b in range(1, n+1):
    if a * b < n: count += 1
    else: break
print(count)
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb as c
N = int(input())
if N == 1: print(0)
else:
  ans = 0
  for i in range(1, N):
    ans += c(i+1, N-1, exact=True)
print(ans % (10 ** 9 + 7))

Fixed submission:
N = int(input())
ans = 10 ** N - ((9 ** N) * 2 - 8 ** N)
print(ans % (10 ** 9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N - 1):
  ans += A[i] * sum(A[i+1:N])
print(ans % (10 ** 9 + 7))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = 0
num = sum(A)
for i in range(N - 1):
  num -= A[i]
  ans += A[i] * num
print(ans % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N - 1):
  for j in range(i+1, N):
    ans += A[i] * A[j]
print(ans % (10 ** 9 + 7))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = 0
num = sum(A)
for i in range(N - 1):
  num -= A[i]
  ans += A[i] * num
print(ans % (10 ** 9 + 7))
Buggy python submission (verdict: Runtime Error):
D, T, S = map(int,input().split())
if S * T >= D: print("Yes")
else: print("No")

Fixed submission:
S = input()
count = 0
ans = 0
for i in range(3):
  if S[i] == "R":
    count += 1
    ans = max(ans, count)
  else:
    ans = max(ans, count)
    count = 0


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X, K, D = map(int,input().split())

def func(i):
  if i >= 0: return i
  else: return -i

for _ in range(K):
  if func(X + D) <= func(X - D): X += D
  else: X -= D

print(func(X))

Fixed submission:
X, K, D = map(int,input().split())
if X < 0: X *= -1
n = X // D
if K <= n: print(X - K * D)
else:
  X -= n * D
  K -= n
  if K % 2 == 0: print(X)
  else: print(-X + D)
Buggy python submission (verdict: Runtime Error):
from math import sqrt as s

N = int(input())

if N == 1: print(1)
else:
  total = 1
  for i in range(2, N+1):
    count = 0
    for j in range(1, int(s(i))+1):
      if i % j == 0: count += 1
    if s(i) % 1 == 0: count = count * 2 - 1
    else: count *= 2
    total += i * count

print(total)

Fixed submission:
N = int(input())
ans = 0
for i in range(1, N+1):
  j = N // i
  ans += j * (j + 1) * i // 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int,input().split())
t = 0
for x in range(1, N+1):
  t = max(t, (A * x) // B - A * (x // B))
print(t)

Fixed submission:
A, B, N = map(int,input().split())
x = min(B-1, N)
print((A * x) // B - A * int(x // B))

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int,input().split())
t = 0
for x in range(1, N+1):
  t = max(t, (A * x) // B - A * (x // B))
print(t)

Fixed submission:
A, B, N = map(int,input().split())
x = min(B-1, N)
print((A * x) // B - A * int(x // B))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

li = [0] * (N + 1)
for i in A:
  li[i] += 1

for i in A:
  li[i] -= 1
  count = 0
  for j in li[1:]:
    if j >= 2: count += j * (j - 1) // 2
  li[i] += 1
  print(count)

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

li = [0] * (N + 1)
total = 0

for i in A:
  li[i] += 1
for i in li[1:]:
  total += i * (i - 1) // 2

for i in A:
  j = li[i]
  print(total - (j * (j - 1) // 2) + ((j - 1) * (j - 2) // 2))

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

li = [0] * (N + 1)
for i in A:
  li[i] += 1

for i in A:
  li[i] -= 1
  count = 0
  for j in li[1:]:
    if j >= 2: count += j * (j - 1) // 2
  li[i] += 1
  print(count)

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

li = [0] * (N + 1)
total = 0

for i in A:
  li[i] += 1
for i in li[1:]:
  total += i * (i - 1) // 2

for i in A:
  j = li[i]
  print(total - (j * (j - 1) // 2) + ((j - 1) * (j - 2) // 2))
Buggy python submission (verdict: Runtime Error):
S = input()
Q = int(input())
Query = list(input().split() for _ in range(Q))

count = 0
L, R = "", ""

for i in range(Q):
  if Query[i][0] == "1": count += 1
  else:
    if Query[i][1] == "1":
      if count % 2 == 0: L = Query[i][2] + L
      else: R += Query[i][2]
    else:
      if count % 2 == 0: R += Query[i][2]
      else: L = Query[i][2] + L
  print(L + S + R)

if count % 2 == 0: print(L + S + R)
else: print(R[::-1] + S[::-1] + L[::-1])

Fixed submission:
S = input()
Q = int(input())
Query = list(input().split() for _ in range(Q))

count = 0
L, R = "", ""

for i in range(Q):
  if Query[i][0] == "1": count += 1
  else:
    if Query[i][1] == "1":
      if count % 2 == 0: L = Query[i][2] + L
      else: R += Query[i][2]
    else:
      if count % 2 == 0: R += Query[i][2]
      else: L = Query[i][2] + L

if count % 2 == 0: print(L + S + R)
else: print(R[::-1] + S[::-1] + L[::-1])
Buggy python submission (verdict: Runtime Error):
def main():
  N, M = map(int,input().split())
  sc = list(list(input().split()) for _ in range(M))

  li = [""] * N

  for i in range(M):
    j = li[int(sc[i][0]) - 1]
    if j == "": li[int(sc[i][0]) - 1] = sc[i][1]
    elif j != sc[i][1]: return -1

  for i in range(N):
    if i == 0:
      if li[0] == "0" and N != 1: return -1
      if li[0] == "":
        if N == 1: li[0] = "0"
        elif: li[0] = "1"
    elif li[i] == "": li[i] = "0"

  return "".join(li)

print(main())

Fixed submission:
def main():
  N, M = map(int,input().split())
  sc = list(list(input().split()) for _ in range(M))

  li = [""] * N

  for i in range(M):
    j = li[int(sc[i][0]) - 1]
    if j == "": li[int(sc[i][0]) - 1] = sc[i][1]
    elif j != sc[i][1]: return -1

  for i in range(N):
    if i == 0:
      if li[0] == "0" and N != 1: return -1
      if li[0] == "":
        if N == 1: li[0] = "0"
        else: li[0] = "1"
    elif li[i] == "": li[i] = "0"

  return "".join(li)

print(main())
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input() for _ in range(N))
D = list(set(S))
D.sort()
n = 0
for d in D:
  if n < S.count(d):
    n = S.count(d)
    li = []
    li.append(d)
  elif n == S.count(d):
    li.append(d)
for l in li:
  print(l)

Fixed submission:
from collections import Counter as c
N = int(input())
S = list(input() for _ in range(N))
S.sort()
C, i = c(S).most_common(), 0
l, n = len(C), C[0][1]
while i < l:
  if n == C[i][1]: print(C[i][0])
  else: break
  i += 1

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input() for _ in range(N))
S.sort()

n, c, l = 0, [], []

for s in S:
  if not s in c:
    c.append(s)
    l.append(1)
  else: l[-1] += 1
  n = max(n, l[-1])

S = list(set(S))
S.sort()

for i in range(len(l)):
  if l[i] == n: print(S[i])

Fixed submission:
from collections import Counter as c
N = int(input())
S = list(input() for _ in range(N))
S.sort()
C, i = c(S).most_common(), 0
l, n = len(C), C[0][1]
while i < l:
  if n == C[i][1]: print(C[i][0])
  else: break
  i += 1
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  N = int(input())
  A = list(input().split())
  A.sort()
  c = []
  for a in A:
    if a in c: return "NO"
    c.append(a)
  return "YES"

print(main())

Fixed submission:
from collections import Counter as c
N = int(input())
A = list(input().split())
if c(A).most_common()[0][1] == 1: print("YES")
else: print("NO")

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  N = int(input())
  A = list(input().split())
  D = list(set(A))
  for d in D:
    if A.count(d) >= 2: return "NO"
  return "YES"

print(main())

Fixed submission:
from collections import Counter as c
N = int(input())
A = list(input().split())
if c(A).most_common()[0][1] == 1: print("YES")
else: print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int,input().split())
p = list(map(int,input().split()))

li = [0] * N
for i in range(N): li[i] = sum(range(1, p[i]+1)) / p[i]

ans, total = sum(li[:K]), sum(li[:K])
if N != K:
  for i in range(1, N - K + 1):
    total = total - li[i-1] + li[i-1+K]
    ans = max(ans, total)
  print(ans)
else: print(ans)

Fixed submission:
N, K = map(int,input().split())
p = list(map(int,input().split()))

li = [0] * N
for i in range(N): li[i] = sum(range(1, p[i]+1)) / p[i]

ans, total = sum(li[:K]), sum(li[:K])
if N != K:
  for i in range(1, N - K + 1):
    total = total - li[i-1] + li[i-1+K]
    ans = max(ans, total)
  print(ans)
else: print(ans)

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

li = [0] * N
for i in range(N):
  for j in range(1, p[i] + 1):
    li[i] += j / p[i]

ans, total = sum(li[:K]), sum(li[:K])
if N != K:
  for i in range(1, N - K + 1):
    total = total - li[i-1] + li[i-1+K]
    ans = max(ans, total)
  print(ans)
else:
  print(ans)

Fixed submission:
N, K = map(int,input().split())
p = list(map(int,input().split()))

li = [0] * N
for i in range(N): li[i] = sum(range(1, p[i]+1)) / p[i]

ans, total = sum(li[:K]), sum(li[:K])
if N != K:
  for i in range(1, N - K + 1):
    total = total - li[i-1] + li[i-1+K]
    ans = max(ans, total)
  print(ans)
else: print(ans)
Buggy python submission (verdict: Runtime Error):
from itertools import permutations as p

N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

j = 1

for i in p(range(1, N + 1)):
  if i == P: a = j
  elif i == Q: b = j
  j += 1

if a - b >= 0: print(a - b)
else: print(b - a)  

Fixed submission:
from itertools import permutations as p

N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

j = 0

for i in p(range(1, N + 1)):
  j += 1
  if i == P: a = j
  if i == Q: b = j

if a - b >= 0: print(a - b)
else: print(b - a)
Buggy python submission (verdict: Runtime Error):
from math import sqrt as s
from math import factorial as f

def func(x1, x2, y1, y2): return s((x2-x1) ** 2 + (y2-y1) ** 2)

N = int(input())
xy = list(list(map(int,input().split())) for _ in range(N))

total = 0

for i in range(N-1):
  for j in range(i+1, N):
    total += func(xy[l[i]][0], xy[l[j]][0], xy[l[i]][1], xy[l[j]][1])

print(total / f(N))

Fixed submission:
from itertools import permutations as p
from math import factorial as f
from math import sqrt as s

def func(x1, x2, y1, y2): return s((x2-x1) ** 2 + (y2-y1) ** 2)

N = int(input())
xy = list(list(map(int,input().split())) for _ in range(N))

total = 0

for l in p(range(1, N+1)):
  for i in range(N-1):
    total += func(xy[l[i]-1][0], xy[l[i+1]-1][0], xy[l[i]-1][1], xy[l[i+1]-1][1])

print(total / f(N))

Buggy python submission (verdict: Runtime Error):
from math import sqrt as s
from math import factorial as f

def func(x1, x2, y1, y2): return s((x2-x1) ** 2 + (y2-y1) ** 2)

N = int(input())
xy = list(list(map(int,input().split())) for _ in range(N))

total = 0

for i in range(N-1):
  for j in range(i+1, N)
    total += func(xy[l[i]][0], xy[l[j]][0], xy[l[i]][1], xy[l[j]][1])

print(total / f(N))

Fixed submission:
from itertools import permutations as p
from math import factorial as f
from math import sqrt as s

def func(x1, x2, y1, y2): return s((x2-x1) ** 2 + (y2-y1) ** 2)

N = int(input())
xy = list(list(map(int,input().split())) for _ in range(N))

total = 0

for l in p(range(1, N+1)):
  for i in range(N-1):
    total += func(xy[l[i]-1][0], xy[l[i+1]-1][0], xy[l[i]-1][1], xy[l[i+1]-1][1])

print(total / f(N))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(1, n+1):
  b.append(a.index(i) + 1)
print(*b)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = [0] * n
for i in range(n):
  b[a[i]-1] = i+1
print(*b)
Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = list(map(lambda x: int(x) * (-1), input().split()))
heapq.heapify(A)

for _ in range(M):
  tmp_min = heapq.heappop(A)
  heapq.heappush(A, (-1) * (-tmp_min // 2))

print(-sum(A))

Fixed submission:
from bisect import bisect_left as bs
#ソート順序を保ったまま値を挿入する
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

while M > 0:
  i = A.pop(-1) // 2
  A.insert(bs(A, i), i)
  M -= 1

print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left as bs
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

while M > 0:
  i = A.pop(-1) // 2
  A.insert(bs(A, i), i)
  M -= 1

print(sum(A))

Fixed submission:
from bisect import bisect_left as bs
#ソート順序を保ったまま値を挿入する
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

while M > 0:
  i = A.pop(-1) // 2
  A.insert(bs(A, i), i)
  M -= 1

print(sum(A))