Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys

# sys.setrecursionlimit(10**9)

N = int(input())

ab = []
graph = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    ab.append((a, b))
    graph[a].append(b)

colors = [-1] * (N + 1)
K = 0


def bfs(p_node, p_color):
    global K
    children_node = graph[p_node]
    c_color = 1
    for child_node in children_node:
        if c_color == p_color:
            c_color += 1
        colors[child_node] = c_color
        bfs(child_node, c_color)
        c_color += 1
    K = max(K, c_color - 1)


bfs(1, -1)

print(K)
for a, b in ab:
    print(colors[b])


Fixed submission:
import sys

sys.setrecursionlimit(10**9)

N = int(input())

ab = []
graph = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    ab.append((a, b))
    graph[a].append(b)

colors = [-1] * (N + 1)
K = 0


def bfs(p_node, p_color):
    global K
    children_node = graph[p_node]
    c_color = 1
    for child_node in children_node:
        if c_color == p_color:
            c_color += 1
        colors[child_node] = c_color
        bfs(child_node, c_color)
        c_color += 1
    K = max(K, c_color - 1)


bfs(1, -1)

print(K)
for a, b in ab:
    print(colors[b])
Buggy python submission (verdict: Runtime Error):
import math
a, b, x = map(float, input().split())
_x = x / a
if _x <= a * b / 2.0:
    theta = math.atan(_x * 2.0 / b / b)
    print(90.0 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2.0 / _x)
    print(90.0 - math.degrees(theta))


Fixed submission:
import math
a, b, x = map(int, input().split())
_x = x / a
if _x == a * b:
    print(0.0)
elif _x <= a * b / 2:
    theta = math.atan(_x * 2 / b / b)
    print(90 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2 / _x)
    print(90 - math.degrees(theta))

Buggy python submission (verdict: Runtime Error):
import math
a, b, x = map(float, input().split())
_x = x / a
if _x <= a * b / 2.0:
    theta = math.atan(_x * 2.0 / b / b)
    print(90.0 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2.0 / _x)
    print(90.0 - math.degrees(theta))


Fixed submission:
import math
a, b, x = map(int, input().split())
_x = x / a
if _x == a * b:
    print(0.0)
elif _x <= a * b / 2:
    theta = math.atan(_x * 2 / b / b)
    print(90 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2 / _x)
    print(90 - math.degrees(theta))

Buggy python submission (verdict: Runtime Error):
import math
a, b, x = map(float, input().split())
_x = x / a
if _x <= a * b / 2.0:
    theta = math.atan(_x * 2.0 / b / b)
    print(90.0 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2.0 / _x)
    print(90.0 - math.degrees(theta))


Fixed submission:
import math
a, b, x = map(int, input().split())
_x = x / a
if _x == a * b:
    print(0.0)
elif _x <= a * b / 2:
    theta = math.atan(_x * 2 / b / b)
    print(90 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2 / _x)
    print(90 - math.degrees(theta))

Buggy python submission (verdict: Runtime Error):
import math
a, b, x = map(float, input().split())
_x = x / a
if _x <= a * b / 2:
    theta = math.atan(_x * 2 / b / b)
    print(90.0 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2 / _x)
    print(90.0 - math.degrees(theta))


Fixed submission:
import math
a, b, x = map(int, input().split())
_x = x / a
if _x == a * b:
    print(0.0)
elif _x <= a * b / 2:
    theta = math.atan(_x * 2 / b / b)
    print(90 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2 / _x)
    print(90 - math.degrees(theta))

Buggy python submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())
_x = x / a
if _x <= a * b / 2:
    theta = math.atan(_x * 2 / b / b)
    print(90 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2 / _x)
    print(90 - math.degrees(theta))


Fixed submission:
import math
a, b, x = map(int, input().split())
_x = x / a
if _x == a * b:
    print(0.0)
elif _x <= a * b / 2:
    theta = math.atan(_x * 2 / b / b)
    print(90 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2 / _x)
    print(90 - math.degrees(theta))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(map(int, input().split()))
for i in range(N):
    print(str(A.index(i+1)+1), end=' ')

Fixed submission:
import numpy as np
n = int(input())
a = list(map(int, input().split()))
a = np.argsort(np.array(a)) + 1
for i in range(len(a)):
    print(a[i], end='')
    if i != len(a) - 1:
        print(' ', end='')
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())
a = []
for i in range(q):
    a.append(int(input()))
# n, k, q = 6, 3, 4
# a = [3, 1, 3, 2]
ans = []
s = []
for i in range(n):
    ans.append('Yes')
    s.append(k)
# print(s, ans)
for i in range(q):
    s[a[i] - 1] += 1
    for j in range(n):
        s[j] -= 1
        if s[j] <= 0:
            ans[j] = 'No'
print('\n'.join(ans))


Fixed submission:
n, k, q = map(int, input().split())
a = []
for i in range(q):
    a.append(int(input()))
# n, k, q = 6, 3, 4
# a = [3, 1, 3, 2]
ans = []
s = []
for i in range(n):
    # ans.append('Yes')
    s.append(k - q)
# print(s, ans)
for i in range(q):
    s[a[i] - 1] += 1
ans = []
for i in s:
    if i > 0:
        ans.append('Yes')
    else:
        ans.append('No')
# print(s)
print('\n'.join(ans))
Buggy python submission (verdict: Runtime Error):
from math import log10

n = int(input())
ans = log10(n) + log10(n-1) - log10(2)
print(round(10**ans))

Fixed submission:
N = int(input())
print(N * (N - 1) // 2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for _ in range(N):
    s = list(input())
    s.sort()
    s = ''.join(s)
    S.append(s)

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


Fixed submission:
from collections import Counter

N = int(input())
S = []
for _ in range(N):
    s = list(input())
    s.sort()
    s = ''.join(s)
    S.append(s)

counter = Counter(S)

ans = 0
for v in counter.values():
    ans += v * (v - 1) // 2
print(ans)

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

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


Fixed submission:
from collections import Counter

N = int(input())
S = []
for _ in range(N):
    s = list(input())
    s.sort()
    s = ''.join(s)
    S.append(s)

counter = Counter(S)

ans = 0
for v in counter.values():
    ans += v * (v - 1) // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
monsters = list(map(int, input().split()))
heros = list(map(int, input().split()))

def f(i, j):
  if i == j == 0:
    return min(monsters[i], heros[i])
  if i == j - 1:
    return min(monsters[i+1], heros[i] - f(i, i))
  if i == j:
    return min(monsters[i] - f(i-1, i), heros[i])

s = 0
for i in range(n):
	s += f(i, i) + f(i, i+1)
print(s)

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

sum_A = sum(A)

for i in range(N):
    if B[i] > A[i]:
        B[i] -= A[i]
        A[i] = 0
        A[i + 1] = max(0, A[i + 1] - B[i])
    else:
        A[i] = max(0, A[i] - B[i])

ans = sum_A - sum(A)
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
monsters = list(map(int, input().split()))
heros = list(map(int, input().split()))

def f(i, j):
  if i == j == 1:
    return min(monsters[i], heros[i])
  if i == j - 1:
    return min(monsters[i+1], heros[i] - f(i, i)
  if i == j:
	return min(monsters[i] - f(i-1, i), heros[i])

s = 0
for i in range(1, 1+n):
	s += f(i, i) + f(i, i+1)


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

sum_A = sum(A)

for i in range(N):
    if B[i] > A[i]:
        B[i] -= A[i]
        A[i] = 0
        A[i + 1] = max(0, A[i + 1] - B[i])
    else:
        A[i] = max(0, A[i] - B[i])

ans = sum_A - sum(A)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))

cnt = 0
for i in range(n-2):
    if sorted([p[i], p[i+1], p[i+2])[1] == p[i+1]:
        cnt += 1
print(cnt)


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

cnt = 0
for i in range(n - 2):
    if sorted([p[i], p[i + 1], p[i + 2]])[1] == p[i + 1]:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
s = list(map(int, list(input())))
for i in range(s - 1):
    if s[i] == s[i + 1]:
        print('Bad')
    print('Good')


Fixed submission:
s = list(map(int, list(input())))
for i in range(len(s) - 1):
    if s[i] == s[i + 1]:
        print('Bad')
        break
else:
    print('Good')
Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())

r = l + n - 1

if r <= 0:
    eat = r
elif l >= 0:
    eat = l
else:
    eat = 0
print((R + L) * (R - L + 1) / 2 - eat)


Fixed submission:
import numpy as np

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

apple = np.array([L + i - 1 for i in range(1, N + 1)])
abs_apple = np.abs(apple)
idx = abs_apple.argmin()
print(apple.sum() - apple[idx])
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
# n, x = 3, 6
# l = [3, 4, 5]
d = 0
i = 0
for i in range(1, n + 2):
    d = d + l[i - 1]
    if d > x:
        break
print(i)


Fixed submission:
import numpy as np
N, X = map(int, input().split())
L = np.array(list(map(int, input().split())))
L = np.append(0, L)
print(np.count_nonzero(L.cumsum() <= X))

Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
# n, x = 3, 6
# l = [3, 4, 5]
d = 0
for i in range(1, n + 2):
    d = d + l[i - 1]
    if d > x:
        break
print(i)


Fixed submission:
import numpy as np
N, X = map(int, input().split())
L = np.array(list(map(int, input().split())))
L = np.append(0, L)
print(np.count_nonzero(L.cumsum() <= X))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = map(int, input().split())
A = tuple([int(input()) for _ in range(M)])
MOD = 1000000007

dp = np.zeros(N + 2, dtype='int')
dp[0] = 1
for now in range(N):
    for _next in range(now + 1, now + 3):
        if _next not in A:
            dp[_next] += dp[now]
            dp[_next] %= MOD
print(dp[N])


Fixed submission:
import numpy as np
N, M = map(int, input().split())
A = np.ones(N + 2, dtype='bool')
for _ in range(M):
    A[int(input())] = False
MOD = 1000000007

dp = np.zeros(N + 2, dtype='int')
dp[0] = 1
for now in range(N):
    for _next in range(now + 1, now + 3):
        if A[_next]:
            dp[_next] += dp[now]
            dp[_next] %= MOD
print(dp[N])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = map(int, input().split())
A = np.array([int(input()) for _ in range(M)])
MOD = 1000000007

dp = np.zeros(N + 2, dtype='int')
dp[0] = 1
for now in range(N):
    for _next in range(now + 1, now + 3):
        if _next not in A:
            dp[_next] += dp[now]
            dp[_next] %= MOD
print(dp[N])


Fixed submission:
import numpy as np
N, M = map(int, input().split())
A = np.ones(N + 2, dtype='bool')
for _ in range(M):
    A[int(input())] = False
MOD = 1000000007

dp = np.zeros(N + 2, dtype='int')
dp[0] = 1
for now in range(N):
    for _next in range(now + 1, now + 3):
        if A[_next]:
            dp[_next] += dp[now]
            dp[_next] %= MOD
print(dp[N])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
A.sort()
A = A[::-1]

# B, Cで出てくる数字全部並べて最後にsortしてAの数だけ取れば良さそう？
D = []
for _ in range(M):
    b, c = map(int, input().split())
    tmp = [c for _ in range(b)]
    D.extend(tmp)
D = np.array(D)
D.sort()

if len(D) < len(A):
    tmp = np.array([0 for _ in range(len(A) - len(D))])
    D = np.append(tmp, D)
else:
    D = D[-len(A):]
print(np.maximum(D, A).sum())


Fixed submission:
import numpy as np
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
A.sort()

# B, Cで出てくる数字全部並べて最後にsortしてAの数だけ取れば良さそう？
BC = []
for _ in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))
BC = sorted(BC, key=lambda x: -x[1])

D = []
n = 0
for b, c in BC:
    if n + b >= N:
        while len(D) < N:
            D.append(c)
        break
    else:
        for i in range(b):
            D.append(c)
        n += b

while len(D) < N:
    D.append(0)

print(np.maximum(D, A).sum())

Buggy python submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
A.sort()
A = A[::-1]

# B, Cで出てくる数字全部並べて最後にsortしてAの数だけ取れば良さそう？
D = []
for _ in range(M):
    b, c = map(int, input().split())
    tmp = [c for _ in range(b)]
    D.extend(tmp)
D = np.array(D)
D.sort()
print(D)
print(A)
print(np.maximum(D, A))
print(np.maximum(D, A).sum())


Fixed submission:
import numpy as np
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
A.sort()

# B, Cで出てくる数字全部並べて最後にsortしてAの数だけ取れば良さそう？
BC = []
for _ in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))
BC = sorted(BC, key=lambda x: -x[1])

D = []
n = 0
for b, c in BC:
    if n + b >= N:
        while len(D) < N:
            D.append(c)
        break
    else:
        for i in range(b):
            D.append(c)
        n += b

while len(D) < N:
    D.append(0)

print(np.maximum(D, A).sum())

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
A.sort()
A = A[::-1]

# B, Cの結果を先にマージする
D = np.zeros((N, ), dtype='int')
for _ in range(M):
    D.sort()
    # print('sorted D', D)
    b, c = map(int, input().split())
    # print('bc', b, c)
    for i in range(min(b, len(D))):
        if D[i] < c:
            D[i] = c
        else:
            break
    # print('after D', D)
D.sort()
# print(D)
# print(A)
# print(np.maximum(D, A))
print(np.maximum(D, A).sum())


Fixed submission:
import numpy as np
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
A.sort()

# B, Cで出てくる数字全部並べて最後にsortしてAの数だけ取れば良さそう？
BC = []
for _ in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))
BC = sorted(BC, key=lambda x: -x[1])

D = []
n = 0
for b, c in BC:
    if n + b >= N:
        while len(D) < N:
            D.append(c)
        break
    else:
        for i in range(b):
            D.append(c)
        n += b

while len(D) < N:
    D.append(0)

print(np.maximum(D, A).sum())
Buggy python submission (verdict: Runtime Error):
import sys
a, b, k = map(int, input().split())
c = 0
for i in range(min(a, b)):
  if a % i == 0 and b % i == 0:
    c += 1
  if c == k:
    print(a)
    sys.exit(0)

Fixed submission:
a, b, k = map(int, input().split())
c = [i for i in range(1, min(a, b) + 1) if a % i == 0 and b % i == 0]
print(c[-k])
Buggy python submission (verdict: Runtime Error):
s = input()
c = 0
for i in s:
  if i == '0':
    break
  c += 1
r = list(range(len(s)))
r.reverse()
for i in r:
  if s[i] == '1':
    break
  c += 1
print(len(s) - c + d)

Fixed submission:
s = input()
zero = 0
one = 0
for i in s:
  if i == '0':
    zero += 1
  else:
    one += 1
print(min(zero, one) * 2)
Buggy python submission (verdict: Runtime Error):
N, W = map(int, input().split())

dp = [0] + [-1] * W
for i in range(1, N + 1):
    w, v = map(int, input().split())
    for sum_w in range(W - w, -1, -1):
        if dp[sum_w] >= 0:
            dp[sum_w + w] = max(dp[sum_w + w], dp[sum_w] + v)
    # print(dp)
print(max(dp))


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

# dp[i] := 足場iに来るのにかかる最小のコスト
dp = [0 for _ in range(N)]
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    c1 = dp[i - 2] + abs(H[i] - H[i - 2])
    c2 = dp[i - 1] + abs(H[i] - H[i - 1])
    dp[i] = min(c1, c2)
ans = dp[-1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())

dp = [0] + [-1] * W
for i in range(1, N + 1):
    w, v = map(int, input().split())
    for sum_w in range(W - w, -1, -1):
        if dp[sum_w] >= 0:
            dp[sum_w + w] = max(dp[sum_w + w], dp[sum_w] + v)
    # print(dp)
print(max(dp))


Fixed submission:
import numpy as np

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

W, V = [0], [0]
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)
# dp[i][sum_w] := i-1 番目までの品物から重さが sum_w を超えないように選んだときの、価値の総和の最大値
# dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]

dp = np.array([0] * (_W + 1))
for i in range(1, N + 1):
    w, v = W[i], V[i]
    np.maximum(dp[:-w] + v, dp[w:], out=dp[w:])
    # print(dp)

# print('dp')
print(dp.max())

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

W, V = [0], [0]
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)
# print('W', W)
# print('V', V)
# dp[i][sum_w] := i-1 番目までの品物から重さが sum_w を超えないように選んだときの、価値の総和の最大値
# dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]

dp = [[0] * (_W + 2) for _ in range(N + 3)]
for i in range(1, N + 1):
    w, v = W[i], V[i]
    for sum_w in range(_W + 1):
        dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w])
        if sum_w - w < 0:
            continue
        dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - w] + v)

import numpy as np
# print('dp')
print(np.array(dp).max())


Fixed submission:
import numpy as np

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

W, V = [0], [0]
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)
# dp[i][sum_w] := i-1 番目までの品物から重さが sum_w を超えないように選んだときの、価値の総和の最大値
# dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]

dp = np.array([0] * (_W + 1))
for i in range(1, N + 1):
    w, v = W[i], V[i]
    np.maximum(dp[:-w] + v, dp[w:], out=dp[w:])
    # print(dp)

# print('dp')
print(dp.max())
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

H, W = map(int, input().split())
A = [[1] * (W + 2)]
for _ in range(H):
    tmp = list(input())
    tmp = [1] + [0 if t == '.' else 1 for t in tmp] + [1]
    A.append(tmp)
A += [[1] * (W + 2)]
A = np.array(A)

MOD = 10**9 + 7

dp = np.zeros(A.shape, dtype='int')
dp[H][W] = 1
# dp[H][W]
# dp[i][j] : (i, j)マスから(H, W)マスへいくのに通れる経路の数
# dp[i][j] : dp[i + 1][j] + dp[i][j + 1] ?
for i in range(H + 1, 0, -1):
    for j in range(W + 1, 0, -1):
        if A[i][j] == 0:
            dp[i][j] = (dp[i][j] + dp[i + 1][j] + dp[i][j + 1]) % MOD
ans = dp[1][1]
print(ans)


Fixed submission:
H, W = map(int, input().split())
A = [[1] * (W + 2)]
for _ in range(H):
    tmp = list(input())
    tmp = [1] + [0 if t == '.' else 1 for t in tmp] + [1]
    A.append(tmp)
A += [[1] * (W + 2)]

MOD = 10**9 + 7

dp = [[0] * (W + 2) for _ in range(H + 2)]
dp[H][W] = 1
# dp[H][W]
# dp[i][j] : (i, j)マスから(H, W)マスへいくのに通れる経路の数
# dp[i][j] : dp[i + 1][j] + dp[i][j + 1] ?
for i in range(H + 1, 0, -1):
    for j in range(W + 1, 0, -1):
        if A[i][j] == 0:
            dp[i][j] = (dp[i][j] + dp[i + 1][j] + dp[i][j + 1]) % MOD
ans = dp[1][1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left as bl


def f(v):
    v = str(v)
    return '0' * (6 - len(v)) + v


N, M = map(int, input().split())
dic = dict()
PY = []
for i in range(M):
    p, y = map(int, input().split())
    if dic.get(p, False):
        dic[p].append(y)
    else:
        dic[p] = [y]
    PY.append((p, y))

for i in range(1, N + 1):
    if dic.get(i, False):
        dic[i] = sorted(dic[i])

# print('dic', dic, PY)
for i in range(M):
    p, y = PY[i]
    # print('p y', p, y)
    l = dic[p]
    ans = f(p) + f(l.index(y) + 1)
    print(ans)


Fixed submission:
from bisect import bisect_left as bl


def f(v):
    v = str(v)
    return '0' * (6 - len(v)) + v


N, M = map(int, input().split())
dic = dict()
PY = []
for i in range(M):
    p, y = map(int, input().split())
    if dic.get(p, False):
        dic[p].append(y)
    else:
        dic[p] = [y]
    PY.append((p, y))

for i in range(1, N + 1):
    if dic.get(i, False):
        dic[i] = sorted(dic[i])

# print('dic', dic, PY)
for i in range(M):
    p, y = PY[i]
    # print('p y', p, y)
    l = dic[p]
    ans = f(p) + f(bl(l, y) + 1)
    print(ans)
Buggy python submission (verdict: Runtime Error):
V = list(map(int, input().split()))
V = sorted(V, reversed=True)
ans = V[0] * 10 + V[1] + V[2]
print(ans)

Fixed submission:
V = list(map(int, input().split()))
V = sorted(V, reverse=True)
ans = V[0] * 10 + V[1] + V[2]
print(ans)
Buggy python submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(int, input().split())
x = x1 - x2
y = y1 - y2
point3 = [x2 + y, y2 - x]
point4 = [x1 + y, y1 - x]
print(*[*point3, *point4], sep=' ')


Fixed submission:
x1, y1, x2, y2 = map(int, input().split())
x = x1 - x2
y = y1 - y2
point3 = [x2 + y, y2 - x]
point4 = [x1 + y, y1 - x]
print(*[point3[0], point3[1], point4[0], point4[1]], sep=' ')

Buggy python submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(int, input().split())
diff_x = abs(x1 - x2)
diff_y = abs(y1 - y2)

if x1 > x2 and y1 > y2:
    pass
elif x1 <= x2 and y1 > y2:
    pass
elif x1 > x2 and y1 <= y2:
    point3 = (x2 - diff_y, y2 - diff_x)
    point4 = (point3[0] + diff_x, point3[1] - diff_y)
else:  # x1 <= x2 and y1 <= y2
    point3 = (x2 - diff_y, y2 + diff_x)
    point4 = (point3[0] - diff_x, point3[1] - diff_y)

print(*[*point3, *point4], sep=' ')


Fixed submission:
x1, y1, x2, y2 = map(int, input().split())
x = x1 - x2
y = y1 - y2
point3 = [x2 + y, y2 - x]
point4 = [x1 + y, y1 - x]
print(*[point3[0], point3[1], point4[0], point4[1]], sep=' ')
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = ((N - 1) + (K - 1 - 1)) // (K - 1)
print(ans)


Fixed submission:
import numpy as np
N, K = map(int, input().split())
X = np.array(list(map(int, input().split())))
idx = np.searchsorted(X, 0)
# print('idx', idx)
ans = 10**10
for i in range(N - K + 1):
    l = i
    r = i + K - 1
    d1 = np.abs(X[l]) + np.abs(X[r] - X[l])
    d2 = np.abs(X[r]) + np.abs(X[r] - X[l])
    d = min(d1, d2)
    ans = min(ans, d)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))


def f(x):
    v = 0
    for i in range(len(A)):
        v += abs(A[i] - (x + i + 1))
    return v


left = -(10**9 + 2 * 10**5)
right = 10**9 + 2 * 10**5
v = 10**18
while left + 1 < right:
    x = (left + right) // 2
    # print('left right x', left, right, x)
    a = f(x)
    v = min(v, a)
    if a <= f(x + 1):
        right = x
    elif f(x - 1) >= a:
        left = x

# ans = f(left)
# print('left ans v', left, ans, v)
print(v)


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


def f(x):
    v = 0
    for i in range(len(A)):
        v += abs(A[i] - (x + i + 1))
    return v


left = -(10**9 + 2 * 10**5)
right = 10**9 + 2 * 10**5
v = 10**18
while left + 1 < right:
    x = (left + right) // 2
    # print('left right x', left, right, x)
    a = f(x)
    v = min(v, a)
    if a <= f(x + 1):
        right = x
    elif f(x - 1) >= a:
        left = x

# ans = f(left)
# print('left ans v', left, ans, v)
print(v)
Buggy python submission (verdict: Runtime Error):
S = input()
S = sorted(S)
for i in range(len(S)):
    if S[i] == '-':
        ans = 2 * i - 4
        break
print(ans)


Fixed submission:
S = input()
S = sorted(S)
for i in range(len(S)):
    if S[i] == '-':
        ans = 2 * i - 4
        break
else:
    ans = 4
print(ans)