Buggy python submission (verdict: Time Limit Exceeded):
l = list(map(int, input().split()))
n = l[0]
t = l[1]

l = list(map(int, input().split()))
maxdiff = 0
count = 0
startindex = 0
endindex = 0

i = 0
while i < n:
    # 最大値を見つける
    maxnum = 0
    maxindex = 0
    for j in range(i, n):
        if l[j] > maxnum:
            maxnum = l[j]
            maxindex = j
    #print("max: " + str(maxnum))
    #print("index: " + str(maxindex))
    if maxindex == i:
        i += 1
        continue
    # 最大の差を見つける
    for j in range(i, maxindex):
        if maxnum - l[j] > maxdiff:
            maxdiff = maxnum - l[j]
            count = 1
            #print("maxdiff: " + str(maxdiff))
            #print("count: " + str(count))
        elif maxnum - l[j] == maxdiff:
            count += 1
            #print("maxdiff: " + str(maxdiff))
            #print("count: " + str(count))
    i = maxindex + 1
print(count)


Fixed submission:
l = list(map(int, input().split()))
n = l[0]
t = l[1]

l = list(map(int, input().split()))
maxdiff = 0
count = 0
currentmin = 10000000000

for i in l:
    if i - currentmin > maxdiff:
        maxdiff = i - currentmin
        count = 1
    elif i - currentmin == maxdiff:
        count += 1
    elif i < currentmin:
        currentmin = i
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
l = list(map(int, input().split()))
n = l[0]
t = l[1]

l = list(map(int, input().split()))
maxdiff = 0
count = 0
startindex = 0
endindex = 0

currentIndex = 0
for currentIndex in range(n):
    maxnum = 0
    if l[currentIndex] > l[startindex] and currentIndex <= endindex:
        continue
    for j in range(currentIndex+1, n):
        if l[j] > maxnum:
            maxnum = l[j]
        else:
            continue
        if l[j] - l[currentIndex] > maxdiff:
            maxdiff = l[j] - l[currentIndex]
            count = 1
            startindex = currentIndex
            endindex = j
        elif l[j] - l[currentIndex] == maxdiff:
            count += 1
            startindex = currentIndex
            endindex = j
print(count)


Fixed submission:
l = list(map(int, input().split()))
n = l[0]
t = l[1]

l = list(map(int, input().split()))
maxdiff = 0
count = 0
currentmin = 10000000000

for i in l:
    if i - currentmin > maxdiff:
        maxdiff = i - currentmin
        count = 1
    elif i - currentmin == maxdiff:
        count += 1
    elif i < currentmin:
        currentmin = i
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
l = list(map(int, input().split()))
n = l[0]
t = l[1]

l = list(map(int, input().split()))
maxdiff = 0
count = 0
minprice = None
maxprice = None

for i in range(n):
    for j in range(i+1, n):
        if l[j] - l[i] > maxdiff:
            maxdiff = l[j] - l[i]
            count = 1
        elif l[j] - l[i] == maxdiff:
            count += 1
print(count)


Fixed submission:
l = list(map(int, input().split()))
n = l[0]
t = l[1]

l = list(map(int, input().split()))
maxdiff = 0
count = 0
currentmin = 10000000000

for i in l:
    if i - currentmin > maxdiff:
        maxdiff = i - currentmin
        count = 1
    elif i - currentmin == maxdiff:
        count += 1
    elif i < currentmin:
        currentmin = i
print(count)