Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
sumA = sum(A)

ans = [None] * N
for i in range(N):
    if i < 2:
        ans[i] = str(sumA - 2 * sum(A[i + 1::2]))
    else:
        ans[i] = str(sumA - 2 * sum(A[i - 2::-2]) - 2 * sum(A[i + 1::2]))

print(" ".join(ans))

Fixed submission:
from itertools import accumulate

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

cumevA = list(accumulate(A[::2]))
cumodA = list(accumulate(A[1::2]))

ans = [None] * N
for i in range(N):
    if i == 0:
        ans[i] = str(sumA - 2 * cumodA[-1])
    elif i == 1:
        ans[i] = str(sumA - 2 * (cumevA[-1] - cumevA[0]))
    elif i == N-1:
        ans[i] = str(sumA - 2 * (cumevA[-2]))
    else:
        if i % 2 == 0:
            ans[i] = str(sumA - 2 * (cumodA[-1] - cumodA[i // 2 - 1] + cumevA[i // 2 - 1]))
        else:
            ans[i] = str(sumA - 2 * (cumevA[-1] - cumevA[(i - 1) // 2] + cumodA[(i - 3) // 2]))

print(" ".join(ans))

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

ans = [0]*N
for i in range(N):
    if i < 2:
        ans[i] = sumA - 2 * sum(A[i+1::2])
    else:
        ans[i] = sumA - 2 * sum(A[i-2::-2]) - 2 * sum(A[i+1::2])

Ans = str(ans)[1:-1].replace(", ", " ")
print(Ans)

Fixed submission:
from itertools import accumulate

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

cumevA = list(accumulate(A[::2]))
cumodA = list(accumulate(A[1::2]))

ans = [None] * N
for i in range(N):
    if i == 0:
        ans[i] = str(sumA - 2 * cumodA[-1])
    elif i == 1:
        ans[i] = str(sumA - 2 * (cumevA[-1] - cumevA[0]))
    elif i == N-1:
        ans[i] = str(sumA - 2 * (cumevA[-2]))
    else:
        if i % 2 == 0:
            ans[i] = str(sumA - 2 * (cumodA[-1] - cumodA[i // 2 - 1] + cumevA[i // 2 - 1]))
        else:
            ans[i] = str(sumA - 2 * (cumevA[-1] - cumevA[(i - 1) // 2] + cumodA[(i - 3) // 2]))

print(" ".join(ans))
Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 6)

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]

dp = [0] * N
dp[1] = 1
dp[2] = 2


def fib(n):
    if n == 0:
        return 0
    elif dp[n] == 0:
        dp[n] = fib(n - 1) + fib(n - 2)
    return dp[n]


if a[0] == 1:
    ans = 1
else:
    ans = fib(a[0] - 1)
if M > 1:
    for i in range(1, M):
        if a[i] - a[i - 1] <= 1:
            ans = 0
        else:
            ans = ans * fib(a[i] - a[i - 1] - 2) % 1000000007
ans = ans * fib(N - a[-1] - 1) % 1000000007
print(ans)


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

if M == 0:
    maxM = N
else:
    maxM = a[0] - 1
    for i in range(1, M):
        maxM = max(maxM, a[i] - a[i-1] - 2)
    maxM = max(maxM, N - a[-1])

dp = [0] * (maxM+1)
dp[1] = 1
if maxM > 1:
    dp[2] = 2
    if maxM > 2:
        for n in range(3, maxM+1):
            dp[n] = (dp[n-1] + dp[n - 2]) % 1000000007

if M == 0:
    print(dp[-1])
    exit()

if a[0] == 1:
    ans = 1
else:
    ans = dp[a[0] - 1]

if M > 1:
    for i in range(1, M):
        if a[i] - a[i - 1] == 1:
            ans = 0
        elif a[i] - a[i - 1] == 2:
            continue
        else:
            ans = ans * dp[a[i] - a[i - 1] - 2] % 1000000007
if N - a[-1] != 1:
    ans = ans * dp[N - a[-1] - 1] % 1000000007
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

ans = 0
while S:
    now = S.find("ABC")
    if now == -1:
        break

    num_A = 1
    num_BC = 1
    S1 = S[:now]
    while len(S1) > 0 and S1[-1] == "A":
        num_A += 1
        S1 = S1[:-1]

    S2 = S[now+3:]
    while len(S2) > 0 and S2[0:2] == "BC":
        num_BC += 1
        S2 = S2[2:]

    ans += num_A*num_BC
    S = "A" + S[(now + 2 * num_BC + 1):]

print(ans)

Fixed submission:
S = input()
T = S.replace("BC", "D")
a = 0
ans = 0
for i in T:
    if i == "A":
        a += 1
    elif i == "D":
        ans += a
    else:
        a = 0

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()

ans = 0
num = S.count("ABC")
while num > 0:
    ans += num
    S = S.replace("ABC", "BCA")
    num = S.count("ABC")

print(ans)

Fixed submission:
S = input()
T = S.replace("BC", "D")
a = 0
ans = 0
for i in T:
    if i == "A":
        a += 1
    elif i == "D":
        ans += a
    else:
        a = 0

print(ans)
Buggy python submission (verdict: Runtime Error):
K = int(input().split()[3])
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

ans = []
for i in range(len(A)):
    for j in range(len(B)):
        if (i+1) * (j+1) > K:
            break
        for k in range(len(C)):
            if (i+1)*(j+1)*(k+1) > K:
                break
            ans.append(A[i]+B[j]+C[k])
ans.sort(reverse=True)
for _ in range(K):
    print(ans[_])



Fixed submission:
List = list(map(int, [input() for _ in range(5)]))
k = int(input())

if List[4] - List[0] <= k:
    print("Yay!")
else:
    print(":(")
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
H = list(map(int, input().split()))

dp = [float("inf")]*N
dp[0] = 0
dp[1] = abs(H[1]-H[0])

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

print(dp[N-1])



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

dp = [float("inf")]*N
dp[0] = 0
dp[1] = abs(H[1]-H[0])

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

print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
wv = [tuple(map(int, input().split())) for _ in range(N)]

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(N):
    for sum_w in range(W+1):
        if sum_w >= wv[i][0]:
            dp[i+1][sum_w] = max(dp[i][sum_w], dp[i][sum_w - wv[i][0]] + wv[i][1])
        else:
            dp[i+1][sum_w] = dp[i][sum_w]

print(dp[-1][-1])

Fixed submission:
import numpy as np
N, W = map(int, input().split())

dp = np.zeros(W+1, dtype=int)

for i in range(N):
    w, v = map(int, input().split())
    np.maximum(dp[:W-w+1]+v, dp[w:], out=dp[w:])
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, W = map(int, input().split())

inf = float("inf")

max_v = 1000 * N + 1
dp = [inf for _ in range(max_v)]
dp[0] = 0
sum_v = 0

for i in range(N):
    w, v = map(int, input().split())
    for j in range(max_v, v-1, -1):
        new = dp[j-v] + w
        if new > W:
            continue
        if dp[j] > new:
            dp[j] = new

ans = 0
for sum_v in range(max_v):
    if dp[sum_v] <= W:
        ans = sum_v
print(ans)

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

inf = float("inf")

max_v = 1000 * N + 1
dp = [inf for _ in range(max_v)]
dp[0] = 0
sum_v = 0

for i in range(N):
    w, v = map(int, input().split())
    for j in range(max_v, v-1, -1):
        new = dp[j-v] + w
        if new > W:
            continue
        if dp[j] > new:
            dp[j] = new

ans = 0
for sum_v in range(max_v):
    if dp[sum_v] <= W:
        ans = sum_v
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque

H, W = map(int, input().split())
matrix = [input() for _ in range(H)]
(sy, sx) = (0, 0)
(gy, gx) = (H - 1, W - 1)

dist = [[None for _ in range(W)] for _ in range(H)]

q = deque([(sy, sx)])
dist[sy][sx] = 1

count_dots = 0
for i in range(H):
    count_dots += matrix[i].count(".")

while q:
    cy, cx = q.popleft()
    if (cy, cx) == (gy, gx):
        break

    for (dy, dx) in ((0, 1), (1, 0), (0, -1), (-1, 0)):
        ny, nx = cy + dy, cx + dx

        if 0 <= nx < W and 0 <= ny < H and matrix[ny][nx] == ".":
            if dist[ny][nx] is None:
                q.append((ny, nx))
                dist[ny][nx] = dist[cy][cx] + 1

print(count_dots - dist[gy][gx])

Fixed submission:
from collections import deque

H, W = map(int, input().split())
matrix = [input() for _ in range(H)]
(sy, sx) = (0, 0)
(gy, gx) = (H - 1, W - 1)

dist = [[None for _ in range(W)] for _ in range(H)]

q = deque([(sy, sx)])
dist[sy][sx] = 1

count_dots = 0
for i in range(H):
    count_dots += matrix[i].count(".")

while q:
    cy, cx = q.popleft()
    if (cy, cx) == (gy, gx):
        break

    for (dy, dx) in ((0, 1), (1, 0), (0, -1), (-1, 0)):
        ny, nx = cy + dy, cx + dx

        if 0 <= nx < W and 0 <= ny < H and matrix[ny][nx] == ".":
            if dist[ny][nx] is None:
                q.append((ny, nx))
                dist[ny][nx] = dist[cy][cx] + 1

if dist[gy][gx] is None:
    print(-1)
    exit()

print(count_dots - dist[gy][gx])
Buggy python submission (verdict: Runtime Error):
A, B, C, X = map(int, [input() for i in range(4)])

count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500 * a + 100 * b + 50 * c == X:
                count += 1

print(count)

Fixed submission:
X, A, B = map(int, [input() for i in range(3)])
print((X - A) % B)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, [input() for i in range(4)])
X = int(input()) / 50

count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 10 * a + 2 * b + c == X:
                count += 1

print(count)

Fixed submission:
A, B, C, X = map(int, [input() for i in range(4)])

count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500 * a + 100 * b + 50 * c == X:
                count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
Y = Y / 1000

for i in range(N+1):
    for j in range(N-i+1):
        if 10*i + 5*j + N-i-j == Y:
            print("{} {} {}".format(i, j, N-i-j))
            exit()

print("-1 -1 -1")

Fixed submission:
print("2018"+input()[4:])

Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
Y = Y / 1000

isTrue = False
for i in range(N+1):
    for j in range(N-i+1):
        for k in range(N-i-j+1):
            if 10*i + 5*j + k == Y:
                isTrue = True
                print("{} {} {}".format(i, j, k))
                break
        else:
            continue
        break
    else:
        continue
    break

if not isTrue:
    print("-1 -1 -1")

Fixed submission:
print("2018"+input()[4:])
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = list(map(int, input().split()))

ans = 0
flag = False
for i in range(N):
    if flag:
        n = p[i+1]
    else:
        n = p[i]
    if n == i+1:
        ans += 1
        flag = True
    else:
        flag = False
print(ans)

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

ans = 0
flag = False
for i in range(N - 1):
    if flag:
        n = p[i+1]
    else:
        n = p[i]
    if n == i+1:
        ans += 1
        flag = True
    else:
        flag = False
if flag:
    n = p[-2]
else:
    n = p[-1]
if n == N:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
print(input()[{
  "SAT": 1 
  "FRI": 2,
  "THU": 3,
  "WED": 4,
  "TUE": 5,
  "MON": 6,
  "SUN": 7
}])

Fixed submission:
print({
  "SAT": 1,
  "FRI": 2,
  "THU": 3,
  "WED": 4,
  "TUE": 5,
  "MON": 6,
  "SUN": 7
}[input()])

Buggy python submission (verdict: Runtime Error):
print(input()[{
  "SAT": 1
  "FRI": 2,
  "THU": 3,
  "WED": 4,
  "TUE": 5,
  "MON": 6,
  "SUN": 7
}])

Fixed submission:
print({
  "SAT": 1,
  "FRI": 2,
  "THU": 3,
  "WED": 4,
  "TUE": 5,
  "MON": 6,
  "SUN": 7
}[input()])
Buggy python submission (verdict: Runtime Error):
import sys
N = input()
TA = input()
T, A = TA.split()
Hinp = input()
H = Hinp.split()
ans = None
for x in range(H):
    _ans = T - x * 0.006
    if _ans == ans:
        print(ans)
        sys.exit()
    if not ans or abs(A - _ans) < abs(A - ans):
        ans = _ans
print(ans)

Fixed submission:
import sys
N = input()
TA = input()
T, A = TA.split()
Hinp = input()
H = Hinp.split()
ansnum = None
ans = 0
def getdiff(A, ans):
    return abs(max(ans, A) - min(ans, A))
def chk(A, _ans, ans):
    new_d, old_d = getdiff(A, _ans), getdiff(A, ans)
    if new_d < old_d:
        return True
    return False
for i, x in enumerate(H):
    _ans = int(T) - int(x) * 0.006
    if _ans == A:
        break
    if not ansnum or chk(int(A), _ans, ansnum):
        ans = i+1
        ansnum = _ans
print(ans)

Buggy python submission (verdict: Runtime Error):
N = input()
TA = input()
T, A = TA.split()
Hinp = input()
H = Hinp.split()
ans = None
for x in range(H):
    _ans = T - x * 0.006
    if _ans == ans:
        print(ans)
        return
    if not ans or abs(A - _ans) < abs(A - ans):
        ans = _ans
print(ans)

Fixed submission:
import sys
N = input()
TA = input()
T, A = TA.split()
Hinp = input()
H = Hinp.split()
ansnum = None
ans = 0
def getdiff(A, ans):
    return abs(max(ans, A) - min(ans, A))
def chk(A, _ans, ans):
    new_d, old_d = getdiff(A, _ans), getdiff(A, ans)
    if new_d < old_d:
        return True
    return False
for i, x in enumerate(H):
    _ans = int(T) - int(x) * 0.006
    if _ans == A:
        break
    if not ansnum or chk(int(A), _ans, ansnum):
        ans = i+1
        ansnum = _ans
print(ans)
Buggy python submission (verdict: Runtime Error):
return int(input()) >= 30

Fixed submission:
print("Yes" if int(input()) >= 30 else "No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = 0
for i in range(1,n+1):
  for j in range(i, n+1):
    for k in range(j, n+1):
      if s[i-1] != s[j-1] and s[i-1] != s[k-1] and s[j-1] != s[k-1] and j-i != k-j:
        ans += 1

print(ans)



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

ans = s.count('R')*s.count('G')*s.count('B')
for i in range(n):
    for j in range(i,n-1):
        k = 2*j - i
        if k >= n:
            continue
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            ans -= 1


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n,k = [int(_) for _ in input().split()]
base = n

if n % k == 0 :
  print("0")
  sys.exit()

while base > abs(base - k):
  base = abs(base - k)

print(base)

Fixed submission:
import sys
n,k = [int(_) for _ in input().split()]

amari = n % k
if amari == 0 :
  print("0")
  sys.exit()

base = amari
while base > abs(base - k):
  base = abs(base - k)

print(base)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n,k = [int(_) for _ in input().split()]
base = n

if k == 1:
  print("0")
  sys.exit()

while base > abs(base - k):
  base = abs(base - k)

print(base)

Fixed submission:
import sys
n,k = [int(_) for _ in input().split()]

amari = n % k
if amari == 0 :
  print("0")
  sys.exit()

base = amari
while base > abs(base - k):
  base = abs(base - k)

print(base)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
w_count = s.count('W')

result = 0
for i in range(len(s)):
  if s[i] == 'W':
    result += s[0:i].count('B')

print(result)

Fixed submission:
s = input()
b_count = s.count('B')
shoki = 0
for i in range(len(s)):
  if s[i] == 'B':
    shoki += i
saigo = sum(range(len(s) - b_count,len(s)))
print(saigo-shoki)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
w_count = s.count('W')

result = 0
for i in range(len(s)):
  if s[i] == 'W':
    result += s[0:i].count('B')

print(result)

Fixed submission:
s = input()
b_count = s.count('B')
shoki = 0
for i in range(len(s)):
  if s[i] == 'B':
    shoki += i
saigo = sum(range(len(s) - b_count,len(s)))
print(saigo-shoki)

Buggy python submission (verdict: Time Limit Exceeded):
s = [_ for _ in input()]
w_count = s.count('W')

result = 0
for i in range(len(s)):
  if s[i] == 'W':
    result += s[0:i].count('B')

print(result)

Fixed submission:
s = input()
b_count = s.count('B')
shoki = 0
for i in range(len(s)):
  if s[i] == 'B':
    shoki += i
saigo = sum(range(len(s) - b_count,len(s)))
print(saigo-shoki)

Buggy python submission (verdict: Time Limit Exceeded):
s = [_ for _ in input()]


def f(s):
  result = 0
  for i in range(len(s)-1):
    if s[i] == 'B' and s[i+1] == 'W':
      result += 1
      s[i] = 'W'
      s[i+1] = 'B'
  return result

result = 0
while True:
  temp = f(s)
  if temp == 0:
    break
  else:
    result += temp
print(result)

Fixed submission:
s = input()
b_count = s.count('B')
shoki = 0
for i in range(len(s)):
  if s[i] == 'B':
    shoki += i
saigo = sum(range(len(s) - b_count,len(s)))
print(saigo-shoki)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()
for i in range(len(s)):
  if s[i] != t[i]:
    s = s.translate(str.maketrans(s[i]+t[i],t[i]+s[i]))

if s == t:
  print("Yes")
else:
  print("No")

Fixed submission:
s = input()
t = input()
used_str = []
for i in range(len(s)):
  if s[i] != t[i] and not s[i] in used_str and not t[i] in used_str:
    s = s.translate(str.maketrans(s[i]+t[i],t[i]+s[i]))
    used_str.append(s[i])
    used_str.append(t[i])

if s == t:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
for i in range(len(s)):
  if s[i] == t[i]:
  else:
    s = s.translate(str.maketrans(s[i]+t[i],t[i]+s[i]))

if s == t:
  print("Yes")
else:
  print("No")

Fixed submission:
s = input()
t = input()
used_str = []
for i in range(len(s)):
  if s[i] != t[i] and not s[i] in used_str and not t[i] in used_str:
    s = s.translate(str.maketrans(s[i]+t[i],t[i]+s[i]))
    used_str.append(s[i])
    used_str.append(t[i])

if s == t:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
h,w = [int(_) for _ in input().split()]
board = [ list(input())  for _ in range(h)]

goodx = [False] * w
goody = [False] * h

for i in range(w):
  for j in range(h):
    if board[i][j] == '#':
      goodx[i] = True
      goody[j] = True

for i in range(w):
  if goodx[i]:
    for j in range(h):
      if goody[j]:
        print(board[i][j], end='')
    print("")

Fixed submission:
h,w = [int(_) for _ in input().split()]
board = [ list(input())  for _ in range(h)]

goodx = [False] * h
goody = [False] * w

for i in range(h):
  for j in range(w):
#    print("i={}\tj={}\tboard={}".format(i,j,board[i][j]))
    if board[i][j] == '#':
      goodx[i] = True
      goody[j] = True

for i in range(h):
  if goodx[i]:
    for j in range(w):
      if goody[j]:
        print(board[i][j], end='')
    print("")

Buggy python submission (verdict: Runtime Error):
h,w = [int(_) for _ in input().split()]
board = [ list(input())  for _ in range(h)]

goodx = [False] * w
goody = [False] * h

for i in range(w):
  for j in range(h):
    print("i ={}, j ={}".format(i,j))
    if board[i][j] == '#':
      goodx[i] = True
      goody[j] = True

for i in range(w):
  if goodx[i]:
    for j in range(h):
      if goody[j]:
        print(board[i][j], end='')
    print("")

Fixed submission:
h,w = [int(_) for _ in input().split()]
board = [ list(input())  for _ in range(h)]

goodx = [False] * h
goody = [False] * w

for i in range(h):
  for j in range(w):
#    print("i={}\tj={}\tboard={}".format(i,j,board[i][j]))
    if board[i][j] == '#':
      goodx[i] = True
      goody[j] = True

for i in range(h):
  if goodx[i]:
    for j in range(w):
      if goody[j]:
        print(board[i][j], end='')
    print("")
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())

if s[0] != "1":
  print(s[0])
elif s[1] != "1":
  print(s[1])
elif s[2] != "1":
  print(s[2])
elif s[3] != "1":
  print(s[3])

Fixed submission:
s = input()
k = int(input())

for i in range(k):
  if s[i] != "1":
    print(s[i])
    exit()
print("1")
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

if S == T:
  print("Yes")
  exit()

nibun = int(len(S)/2)

startline = 0
while nibun > 1:
  if not S[0:nibun] in T:
    startline = ninbun
  nibun = int(nibun / 2)

for i in range(startline, len(S)):
  if not S[0:i] in T:
      sep = i
      break

try:
  sep
except NameError:
  print("No")
  exit()

if S[sep:len(S)] in T[0:len(S)-4+1]:
  print("Yes")
else:
  print("No")

Fixed submission:
S = input()
T = input()

if S == T:
  print("Yes")
  exit()

for i in range(len(S)):
  S = S[-1]+S[:-1]
  if S == T:
    print("Yes")
    exit()

print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
i = 2

while i < 10**9:
  if i % 2 == 0 and i % n == 0:
    print(i)
    break
  i = i+1

Fixed submission:
n = int(input())
if n % 2 == 0:
  print(n)
else:
  print(n*2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(_) for _ in input().split()]
i = 1
result = 0
result2=[]
for b in range(abs(max(a))*-1,abs(max(a))):
  for data in a:
    result = result + abs(data - b -i)
    i += 1
  result2.append(result)
  result = 0
  i = 0

print(min(result2))

Fixed submission:
n = int(input())
a = [int(_) for _ in input().split()]
B = [ av - i  for i, av in enumerate(a,1)]
B.sort()

middle = n //2
b = B[middle]

result = 0
for a2 in B:
  result = result + abs(a2 -b)
print(result)
Buggy python submission (verdict: Runtime Error):
X = 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):
def close_aircondition(x):
  if x >= 30:
    print("Yes")
  else:
    print('No')

if __name__ == "__main__":
  X = input()
  close_aircondition(X)

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

Fixed submission:
x, y = input().split()
print(int(x)*int(y))

Buggy python submission (verdict: Runtime Error):
print(int(input())*int(input()))

Fixed submission:
x, y = input().split()
print(int(x)*int(y))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input()]
ans = 1/sum(1/x for x in a)
print(ans)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
ans = 1/sum(1/x for x in a)
print(ans)
Buggy python submission (verdict: Runtime Error):
import string
s = input()
d = {i:0 for i in string.ascii_uppercase}
for i in s:
  d[i] += 1

def solve():
	for i in d.values():
	  if i not in [0, 2]:
	    print("No")
        return
    print("Yes")

solve()


Fixed submission:
import string
s = input()
d = {i:0 for i in string.ascii_uppercase}
for i in s:
  d[i] += 1

def solve():
  for i in d.values():
    if i not in [0, 2]:
      print("No")
      return
  print("Yes")

solve()
Buggy python submission (verdict: Runtime Error):
n, k = [int(x) for x in input().strip().split()]
s = input().strip()
s[k-1:k] = s[k-1].lower()
print(s[:k-1]+s[k-1].lower()+s[k:])

Fixed submission:
n, k = [int(x) for x in input().strip().split()]
s = input().strip()
print(s[:k-1]+s[k-1].lower()+s[k:])

Buggy python submission (verdict: Runtime Error):
n, k = [int(x) for x in input().strip().split()]
s = input().strip()
s[k-1] = s[k-1].lower()
print(s)

Fixed submission:
n, k = [int(x) for x in input().strip().split()]
s = input().strip()
print(s[:k-1]+s[k-1].lower()+s[k:])
Buggy python submission (verdict: Runtime Error):
ri = lambda: int(input())
n = ri()
x = min([ri() for _ range(5)])
print(n//x+min(1,n%x)+4)

Fixed submission:
ri = lambda: int(input())
n = ri()
x = min([ri() for _ in range(5)])
print(n//x+min(1,n%x)+4)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())

n = -1
for i, ki = enumerate(s):
  if ki!='1':
	n = i+1
    break
    
if n<0 or k<n:
  print(1)
else:
  print(s[n-1])


Fixed submission:
s = input()
k = int(input())

n = -1
for i, ki in enumerate(s):
  if ki!='1':
    n = i+1
    break
    
if n<0 or k<n:
  print(1)
else:
  print(s[n-1])
Buggy python submission (verdict: Runtime Error):
n, d = map(int,input().split())
ans = 0

for i in range(x):
  x, y = map(int,input().split())
  z = (x**2 + y**2)**0.5
  if z <= d:
    ans += 1

print(ans)

Fixed submission:
n, d = map(int,input().split())
ans = 0
 
for i in range(n):
  x, y = map(int,input().split())
  z = (x**2 + y**2)**0.5
  if z <= d:
    ans += 1

print(ans)