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

def judge(A, B, C, D):
    if A < B:   # そもそも買えない
        return False
    if D < B:   # 補充が間に合わないのでいずれ在庫が尽きる
        return False
    if B <= C:  # 補充が間に合う状況で、必ず0個以上の在庫がある
        return True
    G = math.gcd(B, D)   # 昼の買い物の後に残る在庫数の候補のステップ数
    R = A % G       # 例えば A = 3, G = 2の場合、必ず1個あまる
    if C + G - R - B  < 0:
        # C + G - R: 在庫の最小数
        return False
    else:
        return True

T = int(input())
for _ in range(T):
    A, B, C, D = map(int, input().split())
    print('Yes') if judge(A, B, C, D) else print('No')


Fixed submission:
import fractions

def judge(A, B, C, D):
    if A < B:   # そもそも買えない
        return False
    if D < B:   # 補充が間に合わないのでいずれ在庫が尽きる
        return False
    if B <= C:  # 補充が間に合う状況で、必ず0個以上の在庫がある
        return True
    G = fractions.gcd(B, D)   # 昼の買い物の後に残る在庫数の候補のステップ数
    R = A % G       # 例えば A = 3, G = 2の場合、必ず1個あまる
    if C + G - R - B  < 0:
        # C + G - R: 在庫の最小数
        return False
    else:
        return True

T = int(input())
data = []
for _ in range(T):
    data.append([int(xi) for xi in input().split()])
for A, B, C, D in data:
    print('Yes') if judge(A, B, C, D) else print('No')

Buggy python submission (verdict: Runtime Error):
import math
T = int(input())
data = []
for i in range(T):
    data.append([int(xi) for xi in input().split()])

def judge(A, B, C, D):
    if A < B:   # そもそも買えない
        return False
    if D < B:   # 補充が間に合わないのでいずれ在庫が尽きる
        return False
    if B <= C:  # 補充が間に合う状況で、必ず0個以上の在庫がある
        return True
    G = math.gcd(B, D)   # 昼の買い物の後に残る在庫数の候補のステップ数
    R = A % G       # 例えば A = 3, G = 2の場合、必ず1個あまる
    if C + G - R - B  < 0:
        # C + G - R: 在庫の最小数
        return False
    else:
        return True

for a, b, c, d in data:
    print('Yes') if judge(a, b, c, d) else print('No')



Fixed submission:
import fractions

def judge(A, B, C, D):
    if A < B:   # そもそも買えない
        return False
    if D < B:   # 補充が間に合わないのでいずれ在庫が尽きる
        return False
    if B <= C:  # 補充が間に合う状況で、必ず0個以上の在庫がある
        return True
    G = fractions.gcd(B, D)   # 昼の買い物の後に残る在庫数の候補のステップ数
    R = A % G       # 例えば A = 3, G = 2の場合、必ず1個あまる
    if C + G - R - B  < 0:
        # C + G - R: 在庫の最小数
        return False
    else:
        return True

T = int(input())
data = []
for _ in range(T):
    data.append([int(xi) for xi in input().split()])
for A, B, C, D in data:
    print('Yes') if judge(A, B, C, D) else print('No')
Buggy python submission (verdict: Runtime Error):
Ordinary Beauty

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

if d != 0:
    r = 2 * (n - d) / n**2 * (m - 1)
else:
    r = (m - 1) / n
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(x) for x in input().split(' ')]
def score(C, b):
    s = 0
    for i, Ci in enumerate(C):
        s += abs(Ci - b)
    return s

C = [Ai - (i+1) for i, Ai in enumerate(A)]
min_b = min(C)
max_b = max(C)
if min_b == max_b:
    print(0)
else:
    s = float('inf')
    for b in range(min_b, max_b):
        si = score(C, b)
        if si < s:
            s = si
    print(s)

Fixed submission:
import statistics
N = int(input())
A = [int(x) for x in input().split(' ')]
def score(C, b):
    s = 0
    for i, Ci in enumerate(C):
        s += abs(Ci - b)
    return int(s)

C = [Ai - (i+1) for i, Ai in enumerate(A)]
b = statistics.median(C)
b1 = int(b)
b2 = int(b) + 1
s1 = score(C, b1)
s2 = score(C, b2)
print(min(s1, s2))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(x) for x in input().split(' ')]
def score(A, b):
    s = 0
    for i, Ai in enumerate(A):
        s += abs(Ai - (b + i + 1))
    return s
s = float('inf')
for b in range(-max(A), max(A)):
    si = score(A, b)
    if si < s:
        s = si
print(s)

Fixed submission:
import statistics
N = int(input())
A = [int(x) for x in input().split(' ')]
def score(C, b):
    s = 0
    for i, Ci in enumerate(C):
        s += abs(Ci - b)
    return int(s)

C = [Ai - (i+1) for i, Ai in enumerate(A)]
b = statistics.median(C)
b1 = int(b)
b2 = int(b) + 1
s1 = score(C, b1)
s2 = score(C, b2)
print(min(s1, s2))

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
A = [int(x) for x in input().split(' ')]
def score(A, b):
    s = 0
    for i, Ai in enumerate(A):
        s = math.abs(Ai - i - b)
    return s
s = math.inf
for b in range(min(A), max(A)):
    si = score(A, b)
    if si < s:
        s = si
print(s)

Fixed submission:
import statistics
N = int(input())
A = [int(x) for x in input().split(' ')]
def score(C, b):
    s = 0
    for i, Ci in enumerate(C):
        s += abs(Ci - b)
    return int(s)

C = [Ai - (i+1) for i, Ai in enumerate(A)]
b = statistics.median(C)
b1 = int(b)
b2 = int(b) + 1
s1 = score(C, b1)
s2 = score(C, b2)
print(min(s1, s2))
Buggy python submission (verdict: Runtime Error):
s = input().split('')
n = 0
for si in s:
    if si == '+':
        n = n + 1
    else:
        n = n - 1
print(n)


Fixed submission:
s = input()
n = 0
for i in range(len(s)):
    if s[i] == '+':
        n = n + 1
    else:
        n = n - 1
print(n)
Buggy python submission (verdict: Runtime Error):
line = input().split()
a = line[0]
b = line[1]

if a > 8 or b > 8:
    print(':(')
else:
    print('Yay!')

Fixed submission:
line = input().split(' ')
a = line[0]
b = line[1]

if int(a) > 8 or int(b) > 8:
    print(':(')
else:
    print('Yay!')

Buggy python submission (verdict: Runtime Error):
line = input().split()
a = line[0]
b = line[1]

if a > 8 or b > 8:
    return ':('
else:
    return 'Yay!'

Fixed submission:
line = input().split(' ')
a = line[0]
b = line[1]

if int(a) > 8 or int(b) > 8:
    print(':(')
else:
    print('Yay!')

Buggy python submission (verdict: Runtime Error):
line = raw_input().split()
a = line[0]
b = line[1]

if a > 8 or b > 8:
    return ':('
else:
    return 'Yay!'

Fixed submission:
line = input().split(' ')
a = line[0]
b = line[1]

if int(a) > 8 or int(b) > 8:
    print(':(')
else:
    print('Yay!')
Buggy python submission (verdict: Runtime Error):
D, N = map(int, input().split())
if D==0:
    list1  = range(1,100,1)
    print(list1[N-1])
elif D==1:
    list2 = range(100,100*100,100)
    print(list2[N-1])
elif D==2:
    list3 = range(1000,100*1000,1000)
    print(list3[N-1])

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

if N == 100:
    print(101*100**D)
else:
    print(N*100**D)
Buggy python submission (verdict: Runtime Error):
nm = [int(ai) for ai in input().split(' ')]
N = nm[0]
M = nm[1]
cakes = [[int(si) for si in input().split(' ')] for i in range(a[0])]
signs = [[(-1)**i, (-1)**j, (-1)**k] for i in range(2)
                                     for j in range(2)
                                     for k in range(2)]
answer = 0
for sign in signs:
    values = [[cake[i] * sign[i] for i in range(3)] for cake, sign in zip(cakes, signs)]
    answer = max(max(values), answer)
print(answer)

Fixed submission:
nm = [int(ai) for ai in input().split(' ')]
N = nm[0]
M = nm[1]
cakes = [[int(si) for si in input().split(' ')] for i in range(N)]
signs = [[(-1)**i, (-1)**j, (-1)**k] for i in range(2)
                                     for j in range(2)
                                     for k in range(2)]
answer = 0
for sign in signs:
    values = [sum([cake[i] * sign[i] for i in range(3)]) for cake in cakes]
    answer = max(sum(sorted(values, reverse=True)[:M]), answer)
print(answer)

Buggy python submission (verdict: Runtime Error):
a = [int(ai) for ai in input().split(' ')]
n = a[1]
s = [input().split(' ') for i in range(a[0])]

points = []
for si in s:
    p = 0
    for sij in si:
        p += int(sij)
    points.append(p)

points = sorted(points, reverse=True)
max_point = points[0] + points[1] + points[2]
print(max_points)

Fixed submission:
nm = [int(ai) for ai in input().split(' ')]
N = nm[0]
M = nm[1]
cakes = [[int(si) for si in input().split(' ')] for i in range(N)]
signs = [[(-1)**i, (-1)**j, (-1)**k] for i in range(2)
                                     for j in range(2)
                                     for k in range(2)]
answer = 0
for sign in signs:
    values = [sum([cake[i] * sign[i] for i in range(3)]) for cake in cakes]
    answer = max(sum(sorted(values, reverse=True)[:M]), answer)
print(answer)
Buggy python submission (verdict: Runtime Error):
N = int(input())
print('ABC') if N / 999 <= 1 else print('ABD')

Fixed submission:
a, b = input().split(' ')
a, b = int(a), int(b)
diff = b - a
a_orig = sum([i for i in range(1, diff)])
snow = a_orig - a
print(snow)

Buggy python submission (verdict: Runtime Error):
a, b = input().split(' ')
diff = int(b) - int(a)
a_orig = sum([i for i in range(1, diff)])
snow = a_orig - a
print(snow)

Fixed submission:
a, b = input().split(' ')
a, b = int(a), int(b)
diff = b - a
a_orig = sum([i for i in range(1, diff)])
snow = a_orig - a
print(snow)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
H, W, D = map(int, input().split())
A = [None] * H
B = {}
for i in range(H):
    A[i] = [int(x) for x in input().split()]
    for j, Aij in enumerate(A[i]):
        B[Aij] = (i, j)
costs = defaultdict(list)
for n in range(1, W * H + 1):
    m = n
    costs[n].append(0)
    while m + D < H * W + 1:
        x1, y1 = B[m]
        m += D
        x2, y2 = B[m]
        costs[n].append(abs(x1 - x2) + abs(y1 - y2) + costs[n][-1])

Q = int(input())
for i in range(Q):
    Li, Ri = map(int, input().split())
    n_move = (Ri - Li) // D
    print(costs[Li][n_move])

Fixed submission:
from collections import defaultdict
H, W, D = map(int, input().split())
B = {}
for i in range(H):
    Ai = [int(x) for x in input().split()]
    for j, Aij in enumerate(Ai):
        B[Aij] = (i, j)
costs = defaultdict(list)

costs = [0] * (H * W + 1)
for i in range(D + 1, W * H + 1):
    x1, y1 = B[i - D]
    x2, y2 = B[i]
    costs[i] = costs[i - D] + abs(x1 - x2) + abs(y1 - y2)

Q = int(input())
for i in range(Q):
    Li, Ri = map(int, input().split())
    print(costs[Ri] - costs[Li])
Buggy python submission (verdict: Runtime Error):
s = input().split('T')
x, y = map(int, input().split())

h, v = [], []
for i, si in enumerate(s):
    if i % 2 == 0:
        h.append(len(si))
    else:
        v.append(len(si))

def search(move, goal, vertical):
    if vertical:
        goal -= move.pop(0)

    move.sort(reverse=True)
    for m in move:
        if goal > 0:
            goal -= m
        else:
            goal += m
    return goal == 0

if search(h, x, True) and search(v, y, True):
    print('Yes')
else:
    print('No')


Fixed submission:
s = input().split('T')
x, y = map(int, input().split())

h, v = [], []
for i, si in enumerate(s):
    if i % 2 == 0:
        h.append(len(si))
    else:
        v.append(len(si))

def search(move, goal, horisontal):
    if horisontal:
        goal -= move.pop(0)

    move.sort(reverse=True)
    for m in move:
        if goal > 0:
            goal -= m
        else:
            goal += m
    return goal == 0

if search(h, x, True) and search(v, y, False):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N, C = map(int, input().split())
programs = [[0 for _ in range(C)] for _ in range(2*10**5)]
for _ in range(N):
    s, t, c = map(int, input().split())
    for i in range(2*s-1, 2*t):
        programs[i][c-1] = 1
ret = 0
for i in range(2*10**5):
    ret = max(ret, sum(programs[i]))
print(ret)


Fixed submission:
N, C = map(int, input().split())
programs = [[0 for _ in range(C)] for _ in range(10**5)]
for _ in range(N):
    s, t, c = map(int, input().split())
    for i in range(s-1, t):
        programs[i][c-1] = 1
ret = 0
for i in range(10**5):
    ret = max(ret, sum(programs[i]))
print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from scipy.sparse.csgraph import dijkstra, shortest_path
from scipy.sparse import lil_matrix, csr_matrix
K = int(input())

D = lil_matrix((K, K))
for i in range(K-1):
    D[i, i + 1] = 1
    D[i, (i * 10) % K] = 10**(-8)
D[K - 1, 0] = 1
D[K - 1, ((K - 1) * 10) % K] = 10**(-8)

d = dijkstra(D.tocsr(), directed=True, indices=1)
print(int(d[0]) + 1)

Fixed submission:
from scipy.sparse.csgraph import dijkstra, shortest_path
from scipy.sparse import csr_matrix
K = int(input())

class Graph(object):

    def __init__(self, K):
        self.K = K
        self.weights = {}

    def add_edge(self, node1, node2, weight):
        if (node1, node2) in self.weights:
            self.weights[(node1, node2)] = min(self.weights[(node1, node2)], weight)
        else:
            self.weights[(node1, node2)] = weight

    def get_csr_matrix(self):
        n1, n2, w = [], [], []
        for (node1, node2), weight in self.weights.items():
            n1.append(node1)
            n2.append(node2)
            w.append(weight)
        return csr_matrix((w, (n1, n2)), shape=(self.K, self.K))

g = Graph(K)

for i in range(K - 1):
    g.add_edge(i, i + 1, 1)
    g.add_edge(i, (i * 10) % K, 10**(-16))

g.add_edge(K - 1, 0, 1)
g.add_edge(K - 1, ((K - 1) * 10) % K, 10**(-16))
d = dijkstra(g.get_csr_matrix(), directed=True, indices=1)
print(int(d[0]) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
import numpy as np

N = int(input())
A = np.asarray([[int(Aij) for Aij in input().split()] for _ in range(N)])

def warshall_floyd(D):
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(N):
                D[j][k] = min(D[j][k], D[j][i] + D[i][k])
    return D

A2 = warshall_floyd(copy.deepcopy(A))

if np.any(A != A2):
    print(-1)
else:
    d = 0
    A += np.diag([2*10**9] * N)
    for i in range(N):
        for j in range(i + 1, N):
            if np.min(A[i] + A[j]) != A[i, j]:
                d += A[i, j]
    print(d)


Fixed submission:
import numpy as np
from scipy.sparse.csgraph import floyd_warshall

N = int(input())
A = np.asarray([[int(Aij) for Aij in input().split()] for _ in range(N)])

A2 = floyd_warshall(A, directed=False)

if np.any(A != A2):
    print(-1)
else:
    d = 0
    A += np.diag([2*10**9] * N)
    for i in range(N):
        for j in range(i + 1, N):
            if np.min(A[i] + A[j]) != A[i, j]:
                d += A[i, j]
    print(d)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())
A = [[int(Aij) for Aij in input().split()] for _ in range(N)]

n = len(A)
d = 0
for i in range(n):
    for j in range(i + 1, n):
        flag = True
        for k in range(n):
            if i == k or j == k:
                continue
            if A[i][k] + A[k][j] < A[i][j]:
                print('-1')
                exit()
            elif A[i][k] + A[k][j] == A[i][j]:
                flag = False
                break
        if flag:
            d += A[i][j]
print(d)

Fixed submission:
import numpy as np
from scipy.sparse.csgraph import floyd_warshall

N = int(input())
A = np.asarray([[int(Aij) for Aij in input().split()] for _ in range(N)])

A2 = floyd_warshall(A, directed=False)

if np.any(A != A2):
    print(-1)
else:
    d = 0
    A += np.diag([2*10**9] * N)
    for i in range(N):
        for j in range(i + 1, N):
            if np.min(A[i] + A[j]) != A[i, j]:
                d += A[i, j]
    print(d)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

fn = lambda: [int(x) for x in input().split()]
N, M, R = fn()
r = [int(ri) - 1 for ri in input().split()]
A, B, C = [0]*M, [0]*M, [0]*M
for i in range(M):
    A[i], B[i], C[i] = fn()
    A[i], B[i] = A[i] - 1, B[i] - 1

G = csr_matrix((C, (A, B)), shape=(N, N), dtype=float)
dist_matrix = G.todense()
dist_matrix[dist_matrix == 0] = float('inf')
dist_matrix.flat[::N + 1] = 0
for i in range(N):
    for j in range(i + 1, N):
        if dist_matrix[j, i] <= dist_matrix[i, j]:
            dist_matrix[i, j] = dist_matrix[j, i]
        else:
            dist_matrix[j, i] = dist_matrix[i, j]
for k in range(N):
    for i in range(N):
        if dist_matrix[i, k] == float('inf'):
            continue
        for j in range(N):
            d_ijk = dist_matrix[i, k] + dist_matrix[k, j]
            if d_ijk < dist_matrix[i, j]:
                dist_matrix[i, j] = d_ijk

D = dist_matrix

# D = floyd_warshall(G, directed=False)

routes = permutations(r)
result = float('inf')
for route in routes:
    d = sum([D[route[i], route[i+1]] for i in range(len(route) - 1)])
    result = min(result, d)
print(int(result))


Fixed submission:
from itertools import permutations
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

fn = lambda: [int(x) for x in input().split()]
N, M, R = fn()
r = [int(ri) - 1 for ri in input().split()]
A, B, C = [0]*M, [0]*M, [0]*M
for i in range(M):
    A[i], B[i], C[i] = fn()
    A[i], B[i] = A[i] - 1, B[i] - 1

G = csr_matrix((C, (A, B)), shape=(N, N), dtype=int)
D = floyd_warshall(G, directed=False)

routes = permutations(r)
result = float('inf')
for route in routes:
    d = sum([D[route[i], route[i+1]] for i in range(len(route) - 1)])
    result = min(result, d)
print(int(result))
Buggy python submission (verdict: Runtime Error):
A, B, C, D = input().split(' ')
A, B, C, D = int(A), int(B), int(C), int(D)
 
print(min(min(D, B) - max(C, A), 0)

Fixed submission:
A, B, C, D = input().split(' ')
A, B, C, D = int(A), int(B), int(C), int(D)

if B < C or D < A:
    print(0)
else:
    print(min(D, B) - max(C, A))

Buggy python submission (verdict: Runtime Error):
A, B, C, D = input().split(' ')
A, B, C, D = int(A), int(B), int(C), int(D)
 
print(max(min(D, B) - max(C, A), 0)

Fixed submission:
A, B, C, D = input().split(' ')
A, B, C, D = int(A), int(B), int(C), int(D)

if B < C or D < A:
    print(0)
else:
    print(min(D, B) - max(C, A))
Buggy python submission (verdict: Time Limit Exceeded):
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

N, M = map(int, input().split())
a, b, d = [0]*M, [0]*M, [0]*M
for i in range(M):
    a[i], b[i] = map(int, input().split())
    a[i], b[i] = a[i] - 1, b[i] - 1

G = csr_matrix(([1]*M, (a, b)), shape=(N, N))
D = dijkstra(G, directed=False, indices=[0, N-1])
if D[0][N-1] == 2:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Fixed submission:
fn = lambda: map(int, input().split())
N, M = fn()
a, b = [0]*M, [0]*M
ones, goals = set(), set()
for i in range(M):
    ai, bi = fn()
    if ai == 1 and bi == N:
        print('POSSIBLE')
        exit()
    elif ai == 1:
        ones.add(bi)
    elif bi == N:
        goals.add(ai)

if len(ones.intersection(goals)) == 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Buggy python submission (verdict: Runtime Error):
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

N, M = map(int, input().split())
a, b, d = [0]*M, [0]*M, [0]*M
for i in range(M):
    a[i], b[i] = map(int, input().split())
    a[i], b[i] = a[i] - 1, b[i] - 1

G = csr_matrix(([1]*M, (a, b)), shape=(N, N))
D = dijkstra(G, directed=False, indices=[0, N-1])
if D[0][N-1] == 2:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Fixed submission:
fn = lambda: map(int, input().split())
N, M = fn()
a, b = [0]*M, [0]*M
ones, goals = set(), set()
for i in range(M):
    ai, bi = fn()
    if ai == 1 and bi == N:
        print('POSSIBLE')
        exit()
    elif ai == 1:
        ones.add(bi)
    elif bi == N:
        goals.add(ai)

if len(ones.intersection(goals)) == 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
w, v = [0]*N, [0]*N
for i in range(N):
    w[i], v[i] = map(int, input().split())

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

for i in range(N - 1, -1, -1):
    for j in range(W + 1):
        if j < w[i]:
            dp[i][j] = dp[i+1][j]
        else:
            dp[i][j] = max(dp[i+1][j], dp[i+1][j-w[i]] + v[i])
print(dp[0][W])


Fixed submission:

N, W = map(int, input().split())
w, v = [0]*N, [0]*N
for i in range(N):
    w[i], v[i] = map(int, input().split())

memo = {}

def knapsack(i, j):
    key = '{}-{}'.format(i, j)
    if key in memo:
        return memo[key]
    if i == N:
        r = 0
    elif j < w[i]:
        r = knapsack(i + 1, j)
    else:
        r = max([knapsack(i + 1, j), knapsack(i + 1, j - w[i]) + v[i]])
    memo[key] = r
    return r

print(knapsack(0, W))
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
count = 0
for X in range(K + 1):
    if X > S:
        break
    for Y in range(min(K, S - X) + 1):
        if Y < 0:
            continue
        if X + Y > S:
            break
        Z = S - X - Y
        if X <= K and Y <= K and Z <= K:
            count += 1
print(count)



Fixed submission:
K, S = map(int, input().split())
count = 0
for X in range(min(S + 1, K + 1)):
    for Y in range(min(S - X + 1, K + 1)):
        if S - X - Y <= K:
            count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N, T = map(int, input().split())
A = [int(Ai) for Ai in input().split()]
B = [0] * len(A)
for i in range(1, len(A)):
    B[i] = A[i] - min(A[:i])
print(sum([Bi == max(B) for Bi in B]))


Fixed submission:
N, T = map(int, input().split())
A = [int(Ai) for Ai in input().split()]
Amin = A[0]
Bmax = 0
count = 0
for i in range(1, len(A)):
    Amin = min(A[i-1], Amin)
    Bi = A[i] - Amin
    if Bmax == Bi:
        count += 1
    elif Bmax < Bi:
        Bmax = Bi
        count = 1
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
things = input().split()
s = ""
for i in range(n):
  s += thing[0][i]
  s += thing[1][i]
print(s)

Fixed submission:
n = int(input())
things = input().split()
s = ""
for i in range(n):
  s += things[0][i]
  s += things[1][i]
print(s)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

divisors = []
for i in range(1, min(A,B) + 1):
	if A % i == 0 and B % i == 0:
		divisors.append(i)


done = {}
def is_coprime(a,b):
	if (a,b) in done:
		return done[a,b]
	if b == 1:
		return True
	for i in range(2, min(A,B)):
		if a % i == 0 and b % i == 0:
			done[(a,b)] = False
			return False
	done[(a,b)] = True
	return True


def getMaxLen(sofar, divisors):
	if len(divisors) == 0:
		return len(sofar)
	curr_max = getMaxLen(sofar,divisors[1:])
	for i in range(len(divisors)):
		d = divisors[i]
		flag = False
		for s in sofar:
			if not is_coprime(d,s):
				flag = True
				break
		if flag:
			continue
		new = sofar.copy()
		
		new.append(d)
		curr_max = max(curr_max, getMaxLen(new, divisors[i+1:]))
	return curr_max

print(getMaxLen([], divisors))


Fixed submission:
n = int(input())
if n % 2 == 0:
	print(0.5)
else:
	print((1 + n//2) / n)

Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

divisors = []
for i in range(1, min(A,B) + 1):
	if A % i == 0 and B % i == 0:
		divisors.append(i)

def is_coprime(a,b):
	for i in range(2, min(A,B)):
		if a % i == 0 and b % i == 0:
			return False
	return True

def getMaxLen(sofar, divisors):
	if len(divisors) == 0:
		return len(sofar)
	curr_max = getMaxLen(sofar,divisors[1:])
	for i in range(len(divisors)):
		d = divisors[i]
		flag = False
		for s in sofar:
			if not is_coprime(d,s):
				flag = True
				break
		if flag:
			continue
		new = sofar.copy()
		
		new.append(d)
		curr_max = max(curr_max, getMaxLen(new, divisors[i+1:]))
	return curr_max

print(getMaxLen([], divisors))


Fixed submission:
n = int(input())
if n % 2 == 0:
	print(0.5)
else:
	print((1 + n//2) / n)