ZhenlongDai/ACPR huggingface dataset:
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
P, m = - 10 ** 9, 10 ** 9
for _ in range(N):
    n = int(input())
    m = n if m > n else m
    P = n - m if n - m > P else P
print(P)

Failing test case input:
3
1
-2
-24

Expected output:
-3


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
P, m = - 10 ** 9, int(input())
for _ in range(1, N):
    n = int(input())
    P = n - m if n - m > P else P
    m = n if m > n else m
print(P)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
R = []
for n in range(n):
    R.append(int(input()))

R_max = -10**9
for i in range(n-1):
    for j in range(i+1, n):
        if R[j] - R[i] > R_max:
            R_max = R[j] - R[i] 

print(R_max)

Failing test case input:
3
-128
-2
-1

Expected output:
127


Actual output:
126


Fixed submission (verdict: Accepted):
n = int(input())
R_max = -10**9
R_min = int(input())
for i in range(n-1):
    R = int(input())
    if R_max < R - R_min:
        R_max = R - R_min

    if R < R_min:
        R_min = R

print(R_max)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
cnt = int(input())
v = []

for i in range(cnt):
    v.append(int(input()))

len = len(v)
dif_max = -100000000
for i in range(1, len, 1):
    for j in range(i + 1, len, 1):
        dif = v[j] - v[i]
        dif_max = dif if dif_max < dif else dif_max

print(dif_max)

Failing test case input:
3
1
40
0

Expected output:
39


Actual output:
-40


Fixed submission (verdict: Accepted):
cnt = int(input())
dif_max = -1000000000
v_min = 1000000000

for i in range(cnt):
    buf = int(input())
    if i > 0:
        dif_max = dif_max if buf - v_min < dif_max else buf - v_min
    v_min = buf if buf < v_min else v_min
print(dif_max)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
R = [int(input()) for i in range(n)]
profit= R[1] - R[0]
mn = min(R[0],R[1])
for i in R:
    if profit < i - mn:
        profit = i - mn
        if 0 > i - mn:
            mn = i
    elif mn > i:
        mn = i

print(profit)

Failing test case input:
3
4
3
2

Expected output:
-1

Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
R = [int(input()) for i in range(n)]
profit= R[1] - R[0]
mn = R[0]
R.pop(0)
for i in R:
    if profit < i - mn:
        profit = i - mn
        if 0 > i - mn:
            mn = i
    elif mn > i:
        mn = i

print(profit)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = []
nowmin = -10000
for i in range(n):
  a.append(int(input()))
ans = a[1]-a[0]
for i in range(n-1):
  if a[i] < nowmin:
    k = max(a[i+1:]) - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]
    
print(ans)



Failing test case input:
6
7
3
-1
6
1
6

Expected output:
7


Actual output:
-4


Fixed submission (verdict: Accepted):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
nowmin = a[0]
nowmax = max(a[1:])
ans = nowmax - nowmin
for i in range(n-1):
  if a[i] == nowmax:
    nowmax = max(a[i+1:])
  if a[i] < nowmin:
    k = nowmax - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]


print(ans)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
nowmin = a[0]
nowmax = max(a[0:])
ans = nowmax - nowmin
for i in range(n-1):
  if a[i] < nowmin:
    k = nowmax - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]
  if a[i] == nowmax:
    nowmax = max(a[i+1:])

print(ans)



Failing test case input:
3
1
-2
-24

Expected output:
-3


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
nowmin = a[0]
nowmax = max(a[1:])
ans = nowmax - nowmin
for i in range(n-1):
  if a[i] == nowmax:
    nowmax = max(a[i+1:])
  if a[i] < nowmin:
    k = nowmax - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]


print(ans)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):

import sys
if False:
    fh=open('ALDS1_1_Da.txt','r')
else:
    fh=sys.stdin
input=fh.readline

def main():
    n = int(input())
    a=[]
    for _ in range(n):
        a.append(int(input()))

    i=0
    j=1
    pm=a[1]-a[0]
    for k in range(2, n):
        if a[k]>a[j]:
            j=k
            p=a[k]-a[i]
            pm=max(p,pm)
        else:
            i=k
            j=k
    print(pm)
    
if __name__ == "__main__":
    main()



Failing test case input:
3
1
-3
3

Expected output:
6


Actual output:
2


Fixed submission (verdict: Accepted):

import sys
if False:

    fh=open('ALDS1_1_D1.txt','r')
else:
    fh=sys.stdin
input=fh.readline

def main():
    n = int(input())
    a=[]
    for _ in range(n):
        a.append(int(input()))

    pmax=a[1]-a[0]
    pmin=a[0]
    for j in range(1, n):
        pmax = max(a[j]-pmin,pmax)
        pmin = min(pmin,a[j])

    print(pmax)
    
if __name__ == "__main__":
    main()

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):

if __name__ == "__main__":
    n = int(input())
    r0 = int(input())
    r1 = int(input())
    minv = r0 if r0 <= r1 else r1
    maxv = r1 - r0
    for i in range(2, n):
        r = int(input())
        if maxv >= (r-minv):
            maxv = r-minv
        if r <= minv:
            minv = r
    print(maxv) 



Failing test case input:
3
1
-5
-43

Expected output:
-6


Actual output:
-38


Fixed submission (verdict: Accepted):

if __name__ == "__main__":
    n = int(input())
    r0 = int(input())
    r1 = int(input())
    minv = r0 if r0 <= r1 else r1
    maxv = r1 - r0
    for i in range(2, n):
        r = int(input())
        maxv = max(maxv, (r-minv))
        minv = min(minv, r)
    print(maxv)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
import sys

mx = -float('inf')
res = mx
mn = int(input())
for i in map(int,sys.stdin.readlines()):
        if mx < i - mn:
            mx = i - mn
        if 0 > i - mn:
            mn = i
        res = max(mx,res)
print(res)

Failing test case input:
3
1
-5
-43

Expected output:
-6


Actual output:
-2


Fixed submission (verdict: Accepted):
import sys
input()
mx = -float('inf')
res = mx
mn = int(input())
for i in map(int,sys.stdin.readlines()):
        if mx < i - mn:
            mx = i - mn
        if 0 > i - mn:
            mn = i
        res = max(mx,res)
print(res)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
nowmin = a[0] + 1
nowmax = max(a[1:])
ans = a[1]-a[0]
for i in range(n-1):
  if a[i] < nowmin:
    k = nowmax - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]
  elif a[i] == nowmax:
    nowmax = max(a[i+1:])

print(ans)



Failing test case input:
3
1
-2
-24

Expected output:
-3


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
nowmin = a[0]
nowmax = max(a[1:])
ans = nowmax - nowmin
for i in range(n-1):
  if a[i] == nowmax:
    nowmax = max(a[i+1:])
  if a[i] < nowmin:
    k = nowmax - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]


print(ans)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
A = [int(input()) for i in range(n)]
max = A[1]-A[0]

for i in range(1,n-1):
    if(max < A[i+1]-A[i]):
        max = A[i+1]-A[i]

print(max)


Failing test case input:
3
-78
0
2

Expected output:
80


Actual output:
78


Fixed submission (verdict: Accepted):
n = int(input())
A = [int(input()) for i in range(n)]
max = A[1]-A[0]
min = A[0]

for i in range(1,n):
    if(max < A[i]-min):
        max = A[i]-min
    if(min > A[i]):
        min = A[i]

print(max)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):



def maximum_profit(profits):
    max_v = profits[1] - profits[0]

    for j in range(1, len(profits)):
        for i in range(0, j-1):
            max_v = max(profits[j] - profits[i], max_v)

    print(max_v)


if __name__ == '__main__':
    maximum_profit([5, 3, 1, 3, 4, 3])

Failing test case input:
3
5
2
3

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):



def maximum_profit(profits):
    max_v = profits[1] - profits[0]
    min_v = profits[0]

    for j in range(1, len(profits)):
        max_v = max(max_v, profits[j]-min_v)
        min_v = min(min_v, profits[j])

    print(max_v)


def to_int(v):
    return int(v)


if __name__ == '__main__':
    l = to_int(input())
    profits = [to_int(input()) for i in range(l)]

    maximum_profit(profits)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
import sys

def get_maximum_profit():
    element_number = int(input())
    v0 = int(input())
    v1 = int(input())

    min_v = min(v0, v1)
    max_profit = v1-v0

    for i in range(element_number-2):
        v = int(input())
        min_v = min(min_v, v)
        max_profit = max(max_profit, v-min_v)

    print(max_profit)

if __name__ == '__main__':
    get_maximum_profit()

Failing test case input:
3
4
0
-5

Expected output:
-4


Actual output:
0


Fixed submission (verdict: Accepted):
import sys

def get_maximum_profit():
    element_number = int(input())
    v0 = int(input())
    v1 = int(input())

    min_v = min(v0, v1)
    max_profit = v1-v0

    for i in range(element_number-2):
        v = int(input())
        max_profit = max(max_profit, v-min_v)
        min_v = min(min_v, v)

    print(max_profit)

if __name__ == '__main__':
    get_maximum_profit()

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
minv=int(input())
maxv=-float('inf')
for _ in range(n-1):
  tmp=int(input())
  minv=min(minv,tmp)
  maxv=max(maxv,tmp-minv)
print(maxv)


Failing test case input:
3
1
-2
-24

Expected output:
-3


Actual output:
0


Fixed submission (verdict: Accepted):
n=int(input())
minv=int(input())
maxv=-float('inf')
for _ in range(n-1):
  tmp=int(input())
  maxv=max(maxv,tmp-minv)
  minv=min(minv,tmp)
print(maxv)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
x = []
for i in range(n):
    x.append(int(input()))
m = float("inf")
for i in range(n-1):
    for j in range(i+1,n):
        if m < (x[j] - x[i]):
            m = x[j] - x[i]
print(m)


Failing test case input:
6
5
3
0
3
4
3

Expected output:
4


Actual output:
inf


Fixed submission (verdict: Accepted):
n = int(input())
x = []
for i in range(n):
    x.append(int(input()))
mx = float("inf") * (-1)
mn = x[0]
for i in range(1,n):
    if mx < (x[i] - mn):
        mx = x[i] - mn
    if mn > x[i]:
        mn = x[i]
print(mx)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
R = [int(input()) for i in list(range(N))]
maxv = -1000000000
minr = R[0]

for i in list(range(N)):
    maxv = max(maxv, R[i] - minr)
    minr = min(minr, R[i])

print(maxv)

Failing test case input:
3
4
0
-5

Expected output:
-4


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
R = [int(input()) for i in list(range(N))]
maxv = -1000000000
minr = R[0]

for i in list(range(1, N)):
    maxv = max(maxv, R[i] - minr)
    minr = min(minr, R[i])

print(maxv)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())

rt = [input() for i in range(n)]

minv = int(rt[0])
maxv = int(rt[1]) - int(rt[0])

for j in range(n):
    maxv = max(maxv,int(rt[j]) - minv)
    minv = min(minv,int(rt[j]))

print(maxv)

Failing test case input:
3
4
3
2

Expected output:
-1

Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())

rt = [input() for i in range(n)]

minv = int(rt[0])
maxv = int(rt[1]) - int(rt[0])

for j in range(1,n):
    maxv = max(maxv,int(rt[j]) - minv)
    minv = min(minv,int(rt[j]))

print(maxv)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
max = -1000000000
min = int(input())
for i in range(1, n):
  r = int(input())
  if max < (r - min):
    max = r - min
  if min > r:
    max = r
print(max)

Failing test case input:
6
6
3
-1
14
1
6

Expected output:
15


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
max = -1000000000
min = int(input())
for i in range(1, n):
  r = int(input())
  if max < (r - min):
    max = r - min
  if min > r:
    min = r
print(max)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
nowmin = a[0] + 1
nowmax = max(a[1:])
ans = a[1]-a[0]
for i in range(n-1):
  if a[i] < nowmin:
    k = nowmax - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]
  if a[i] == nowmax:
    nowmax = max(a[i+1:])

print(ans)



Failing test case input:
3
1
-5
-43

Expected output:
-6


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
nowmin = a[0]
nowmax = max(a[1:])
ans = nowmax - nowmin
for i in range(n-1):
  if a[i] == nowmax:
    nowmax = max(a[i+1:])
  if a[i] < nowmin:
    k = nowmax - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]


print(ans)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
row_num = int(input())
nums = []
for row in range(row_num):
    nums.append(int(input()))

max_diff = 0
for i in range(len(nums)):
    for j in range(i+1, len(nums)):
        diff = nums[j] - nums[i]
        if max_diff >= diff:
            continue
        else:
            max_diff = diff

print(max_diff)



Failing test case input:
3
2
1
-1

Expected output:
-1


Actual output:
0


Fixed submission (verdict: Accepted):
row_num = int(input())
nums = []
for row in range(row_num):
    nums.append(int(input()))

min_diff = nums[0]
max_diff = nums[1] - nums[0]
for i in range(1, len(nums)):
    if max_diff < nums[i] - min_diff:
        max_diff = nums[i] - min_diff
    if min_diff > nums[i]:
        min_diff = nums[i]

print(max_diff)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
list = []

for i in range(N):
    tmp = int(input())
    list.append(tmp)

maxDiff = 0
tmpMin = 10 ** 9
tmpMax = 0
for i in range(N):
    for j in range(i+1, N):
        tmpDiff = list[j] - list[i]
        if tmpDiff > maxDiff:
            maxDiff = tmpDiff
print(maxDiff)


Failing test case input:
3
1
-4
-24

Expected output:
-5


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
list = []

for i in range(N):
    tmp = int(input())
    list.append(tmp)

maxDiff = - 10 ** 9
tmpMin = list[0]
for i in range(N-1):
    maxDiff = max([maxDiff, list[i+1] - tmpMin])
    tmpMin = min([tmpMin, list[i+1]])
print(maxDiff)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
r=[int(input()) for i in range(n)]
maxv=-2000000000
minv=r[0]
for i in range(1,n-1):
    maxv=max(maxv,r[i]-minv)
    minv=min(minv,r[i])
print(maxv)


Failing test case input:
3
-141
0
4

Expected output:
145


Actual output:
141


Fixed submission (verdict: Accepted):
n=int(input())
r=[int(input()) for i in range(n)]
maxv=r[1]-r[0]
minv=r[0]
for i in range(1,n):
    maxv=max(maxv,r[i]-minv)
    minv=min(minv,r[i])
print(maxv)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
def maximum_profit(n):
    maxv = min(n) - max(n)
    for i in range(len(n)):
        m = max(n[i+1:]) if i+1 < len(n) else 0
        if maxv < m - n[i]:
            maxv = m - n[i]
    return maxv

if __name__ == '__main__':
    n = []
    for _ in range(int(input())):
        n.append(int(input()))
    print(maximum_profit(n))



Failing test case input:
3
1
-4
-24

Expected output:
-5


Actual output:
24


Fixed submission (verdict: Accepted):
def maximum_profit(n):
    maxv = min(n) - max(n)
    minv = n[0]
    for i in range(1, len(n)):
        maxv = n[i] - minv if maxv < n[i] - minv else maxv
        minv = n[i] if minv > n[i] else minv
    return maxv

if __name__ == '__main__':
    n = []
    for _ in range(int(input())):
        n.append(int(input()))
    print(maximum_profit(n))

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
x = []
for i in range(n):
    x.append(int(input()))
m = 0
for i in range(n-1):
    for j in range(i+1,n):
        if m < (x[j] - x[i]):
            m = x[j] - x[i]
print(m)



Failing test case input:
3
4
3
2

Expected output:
-1

Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
x = []
for i in range(n):
    x.append(int(input()))
mx = float("inf") * (-1)
mn = x[0]
for i in range(1,n):
    if mx < (x[i] - mn):
        mx = x[i] - mn
    if mn > x[i]:
        mn = x[i]
print(mx)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
nums = []


for v in range(n):
    num = int(input())
    nums.append(num)

ma = -10000
mi = nums[0]
for p in range(1,len(nums)):
    a = nums[p]
    if a > a-mi:
        ma = a-mi
    if a < mi:
        mi = a
    
        

    
        
print(ma)


Failing test case input:
6
5
3
0
3
4
3

Expected output:
4


Actual output:
-3


Fixed submission (verdict: Accepted):
n = int(input())
nums = []


for v in range(n):
    num = int(input())
    nums.append(num)

ma = -1000000000
mi = nums[0]
for p in range(1,len(nums)):
    a = nums[p]
    if a-mi > ma:
        ma = a-mi
    if a < mi:
        mi = a
    
        

    
        
print(ma)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):



n = int(input())


maxv = int(input())
minv = maxv
price = 0

for i in range(n-1):
    x = int(input())
    if x < minv:
        minv = x
    if x > maxv:
        maxv = x
    if price < maxv - minv:
        price = maxv - minv

print(price)

Failing test case input:
6
0
23
-2
2
5
1

Expected output:
23


Actual output:
25


Fixed submission (verdict: Accepted):



n = int(input())

b = int(input())
maxv = b
minv = b

price = -1000000000

for i in range(n-1):
    x = int(input())
    flag = (x-b > 0)
    if flag:
        maxv = max(maxv, x)
        price = max(price, maxv-minv)
    else:
        if x < minv:
            minv = x
            maxv = x
        if price < x-b:
            price = x-b
    b = x

print(price)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):



if __name__ == "__main__":
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))
    max = a[1] - a[0]
    for i in range(2, len(a)-1):
        for j in range(1, i):
            diff = i - j
            if diff > max:
                max = diff
    print(max)

Failing test case input:
6
7
3
-1
6
1
6

Expected output:
7


Actual output:
3


Fixed submission (verdict: Accepted):



if __name__ == "__main__":
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))
    max = a[1] - a[0]
    mini = a[0]
    for i in range(1, len(a)):
        diff = a[i] - mini
        if diff > max:
            max = diff
        if mini > a[i]:
            mini = a[i]
    print(max)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
maxv = -10**9
minv = 10**9
n = int(input())
for i in range(n):
    x = int(input())
    if x < minv:
        minv = x
    if x - minv > maxv:
        maxv = x - minv
print(maxv)

Failing test case input:
3
4
0
-5

Expected output:
-4


Actual output:
0


Fixed submission (verdict: Accepted):
maxv = -2*10**9
minv = 2*10**9
n = int(input())
for i in range(n):
    x = int(input())
    maxv = max(x - minv, maxv)
    minv = min(x, minv)
print(maxv)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):

import sys
lines = sys.stdin.readlines()
a = [int(i) for i in lines]

num = len(a)
minv = a[0]
maxv = -2000000000

for i in range(num):
    maxv = max(maxv, a[i] - minv)
    minv = min(minv, a[i])

print(maxv)



Failing test case input:
3
1
-2
-24

Expected output:
-3


Actual output:
0


Fixed submission (verdict: Accepted):


nums = int(input())
a = [int(input()) for i in range(nums)]

minv = a[0]
maxv = -2000000000

for i in range(1, nums):
    maxv = max(maxv, a[i] - minv)
    minv = min(minv, a[i])

print(maxv)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
if __name__ == '__main__':
	n = int(input())
	R = [int(input()) for i in range(n)]

	minv = R[0]
	maxv = R[1] - R[0]
	for j in range(1, n - 1):
		maxv = maxv if maxv > (R[j] - minv) else (R[j] - minv)
		minv = minv if minv < R[j] else R[j]

	print(maxv)

Failing test case input:
3
1
-3
9

Expected output:
12


Actual output:
-4


Fixed submission (verdict: Accepted):
if __name__ == '__main__':
	n = int(input())
	R = [int(input()) for i in range(n)]

	minv = R[0]
	maxv = R[1] - R[0]
	for j in range(1, n):
		if (maxv < R[j] - minv):
			maxv = R[j] - minv
		if (R[j] < minv):
			minv = R[j]
	print(maxv)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
num=[int(input()) for i in range(n)]

maxv=num[1]-num[2]
minv=num[0]

for j,n in enumerate(num[1:]):
    maxv=max(maxv,n-minv)
    minv=min(minv,num[j+1])

print(maxv)

Failing test case input:
6
0
23
-2
2
5
1

Expected output:
23


Actual output:
25


Fixed submission (verdict: Accepted):
n=int(input())
num=[int(input()) for i in range(n)]

maxv=num[1]-num[0]
minv=num[0]

for j,n in enumerate(num[1:]):
    maxv=max(maxv,n-minv)
    minv=min(minv,num[j+1])

print(maxv)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
nowmin = a[0]
nowmax = max(a[1:])
ans = nowmax - nowmin
for i in range(n-1):
  if a[i] < nowmin:
    k = nowmax - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]
  if a[i] == nowmax:
    nowmax = max(a[i+1:])

print(ans)



Failing test case input:
3
4
0
-5

Expected output:
-4


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
nowmin = a[0]
nowmax = max(a[1:])
ans = nowmax - nowmin
for i in range(n-1):
  if a[i] == nowmax:
    nowmax = max(a[i+1:])
  if a[i] < nowmin:
    k = nowmax - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]


print(ans)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

b = a[1] - a[0]
for i in range(n):
    for j in range(i , n):
        if b < a[j] - a[i]:
            b = a[j] - a[i]

print(b)



Failing test case input:
3
4
3
2

Expected output:
-1

Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

mini = a[0]
b = -10000000000
del a[0]
for i in a:
    if b < i - mini:
        b = i - mini
    if mini > i:
        mini = i

print(b)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):

import sys
lines = sys.stdin.readlines()
a = [int(i) for i in lines]

num = len(a)
minv = a[0]
maxv = -2000000000

for i in range(1, num):
    maxv = max(maxv, a[i] - minv)
    minv = min(minv, a[i])

print(maxv)



Failing test case input:
3
5
1
-1

Expected output:
-2


Actual output:
2


Fixed submission (verdict: Accepted):


nums = int(input())
a = [int(input()) for i in range(nums)]

minv = a[0]
maxv = -2000000000

for i in range(1, nums):
    maxv = max(maxv, a[i] - minv)
    minv = min(minv, a[i])

print(maxv)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
ns = []
max_profit = -1000000000
min_value = 1000000000
for i in range(n):
    num = int(input())
    max_profit = max(max_profit, num-min_value)
    min_value = min(i, min_value)
print(max_profit)
    


Failing test case input:
6
7
3
-1
14
1
6

Expected output:
15


Actual output:
14


Fixed submission (verdict: Accepted):
n = int(input())
ns = []
max_profit = -1000000000
min_value = 1000000000
for i in range(n):
    num = int(input())
    if i > 0:
        max_profit = max(max_profit, num-min_value)
    min_value = min(num, min_value)
print(max_profit)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):


def main():
    n = int(input())
    t0 = int(input())
    t1 = int(input())
    tmpmin = t0
    tmpmax = t1 - t0

    for _ in range(2,n):
        t = int(input())
        if t - tmpmin > tmpmax:
            tmpmax = t - tmpmin 
        if t < tmpmin:
            tmpmin = t

    print(tmpmax)


if __name__ == '__main__':
    main()



Failing test case input:
3
1
-2
4

Expected output:
6


Actual output:
3


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    t0 = int(input())
    t1 = int(input())
    tmpmin = t0
    tmpmax = t1 - t0
    tmpmin = min(t0, t1)

    for _ in range(2,n):
        t = int(input())
        if t - tmpmin > tmpmax:
            tmpmax = t - tmpmin 
        if t < tmpmin:
            tmpmin = t
    print(tmpmax)


if __name__ == '__main__':
    main()

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
R = [int(input()) for i in range(n)]
profit= R[1] - R[0]
mn = min(R[0],R[1])
for i in R:
    if profit < i - mn:
        profit = i - mn
        if 0 < i - mn:
            mn = i
    elif mn > i:
        mn = i

print(profit)

Failing test case input:
3
5
2
3

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
R = [int(input()) for i in range(n)]
profit= R[1] - R[0]
mn = R[0]
R.pop(0)
for i in R:
    if profit < i - mn:
        profit = i - mn
        if 0 > i - mn:
            mn = i
    elif mn > i:
        mn = i

print(profit)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
import sys
numbers = []
for line in sys.stdin:
	numbers.append(int(line))

answer = numbers[2] - numbers[1]
tmp_min = numbers[1]

for target in range(1, len(numbers)):
	answer =  max(numbers[target] - tmp_min ,answer)
	tmp_min = min(numbers[target] , tmp_min)
print(answer)


Failing test case input:
3
4
3
2

Expected output:
-1

Actual output:
0


Fixed submission (verdict: Accepted):
import sys
numbers = []
for line in sys.stdin:
	numbers.append(int(line))

answer = numbers[2] - numbers[1]
tmp_min = numbers[1]
for target in range(2, len(numbers)):
	answer =  max(numbers[target] - tmp_min ,answer)
	tmp_min = min(numbers[target] , tmp_min)

print(answer)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())

R = []

for i in range(0,n):
    R.insert(i, int(input()))

m = min(R[0:2])
MAX = R[1] - R[0]
for r in range(1, n):
    if(R[r-1] < m):
        m = R[r-1]
    MAX2 = R[r] - m
    if(MAX2 > MAX):
        MAX = MAX2

print(MAX)

Failing test case input:
3
4
0
-5

Expected output:
-4


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())

R = []

for i in range(0,n):
    R.insert(i, int(input()))

m = min(R[0:2])
MAX = R[1] - R[0]
for r in range(2, n):
    if(R[r-1] < m):
        m = R[r-1]
    MAX2 = R[r] - m
    if(MAX2 > MAX):
        MAX = MAX2

print(MAX)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = []
nowmin = -1
for i in range(n):
  a.append(int(input()))
ans = a[1]-a[0]
for i in range(n-1):
  if a[i] < nowmin:
    k = max(a[i+1:]) - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]
    
print(ans)



Failing test case input:
6
7
3
-1
5
1
6

Expected output:
7


Actual output:
-4


Fixed submission (verdict: Accepted):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
nowmin = a[0]
nowmax = max(a[1:])
ans = nowmax - nowmin
for i in range(n-1):
  if a[i] == nowmax:
    nowmax = max(a[i+1:])
  if a[i] < nowmin:
    k = nowmax - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]


print(ans)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):


N = int(input())
datas = [int(input()) for _ in range(N)]

now_max = max(datas[1:])
diff = now_max - datas[0]

for i in range(1,N-1):
    new_diff = now_max - datas[i]
    if new_diff == 0:
        now_max = max(datas[i+1:])
    elif diff < new_diff:
        diff = new_diff

print(diff)



Failing test case input:
3
2
0
0

Expected output:
0


Actual output:
-2


Fixed submission (verdict: Accepted):


N = int(input())
datas = [int(input()) for _ in range(N)]

now_max = max(datas[1:])
max_index = datas.index(now_max)
diff = now_max - datas[0]

for i in range(1,N-1):
    if i == max_index:
        d = datas[i+1:]
        now_max = max(d)
        max_index = d.index(now_max)+i+1
    new_diff = now_max - datas[i]
    if diff < new_diff:
        diff = new_diff

print(diff)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):



def main():
  times = int(input())
  min_rate = 10 ** 9
  maxv = - min_rate
  for _ in range(0, times):
    rate = int(input())
    if rate < min_rate:
      min_rate = rate
    if rate - min_rate > maxv:
      maxv = rate - min_rate
  print(maxv)
  return 0


if __name__ == '__main__':
  main()

Failing test case input:
3
5
1
-1

Expected output:
-2


Actual output:
0


Fixed submission (verdict: Accepted):



def main():
  times = int(input())
  min_rate = int(input())
  maxv = - 10 ** 9
  for _ in range(1, times):
    rate = int(input())

    if rate - min_rate > maxv:
      maxv = rate - min_rate

    if rate < min_rate:
      min_rate = rate

  print(maxv)
  return 0


if __name__ == '__main__':
  main()

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
data = [int(input()) for i in range(n)]

min_value = data.pop(0)
max_value = -100000000
for d in data:
    max_value = max(d, max_value)
    min_value = min(d, min_value) 
print(max_value - min_value)

Failing test case input:
3
4
0
-5

Expected output:
-4


Actual output:
5


Fixed submission (verdict: Accepted):
n = int(input())
data = [int(input()) for i in range(n)]

min_value = data.pop(0)
earn_value = -1000000000000
for d in data:
    earn_value = max(d - min_value, earn_value)
    min_value = min(d, min_value) 
print(earn_value)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
inputs = []
while True:
    try:
        inputs.append(int(input()))
    except(EOFError):
        break

inputs.pop(0)

minv = inputs[0]
maxv = inputs[1] - inputs[0]

for i in range(1, len(inputs) - 1):
    maxv = max([maxv, inputs[i] - minv])
    minv = min([minv, inputs[i]])

print(maxv)



Failing test case input:
3
-68
-2
-1

Expected output:
67


Actual output:
66


Fixed submission (verdict: Accepted):
inputs = []
while True:
    try:
        inputs.append(int(input()))
    except(EOFError):
        break

inputs.pop(0)

minv = inputs[0]
maxv = inputs[1] - inputs[0]

for i in range(1, len(inputs)):
    maxv = max([maxv, inputs[i] - minv])
    minv = min([minv, inputs[i]])

print(maxv)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = [int(input()) for i in range(n)]
ma = a[1]-a[0]
mi = a[0]
for i in range(n):
    mi = min(mi, a[i])
    ma = max(ma, a[i] - mi)
print(ma)
        


Failing test case input:
3
4
3
2

Expected output:
-1

Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(input()) for i in range(n)]
ma = a[1]-a[0]
mi = a[0]
for i in range(1,n):
    ma = max(ma, a[i] - mi)
    mi = min(mi, a[i])
    
print(ma)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):



n = int(input())
R = [int(input()) for i in range(n)]

maximum_profit = R[-1]-R[-2]
min_i = R[0]
for i in range(n-2):
    if R[i] >= min_i: continue
    max_profit_i = R[i+1]-R[i]
    for j in range(i+2, n):
        tmp = R[j]-R[i]
        if max_profit_i < tmp:
            max_profit_i = tmp
    if maximum_profit < max_profit_i:
        maximum_profit = max_profit_i
print(maximum_profit)


Failing test case input:
3
-52
4
-1

Expected output:
56


Actual output:
-5


Fixed submission (verdict: Accepted):



n = int(input())
R = [int(input()) for i in range(n)]

min_i = 0
max_val = R[1]-R[0]
max_j = -1
for i in range(n-1):
    if R[min_i] < R[i]:
        continue
    elif R[min_i] > R[i]:
        min_i = i

    if max_j <= i:
        max_j = i+1
        for j in range(i+1, n):
            if R[max_j] < R[j]:
                max_j = j

    if max_val < R[max_j] - R[min_i]:
        max_val = R[max_j] - R[min_i]

print(max_val)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
R = []
for _ in range(n):
    R.append(int(input()))

maxv = R[1] - R[0]
minv = R[0]
for j in range(1, n):
    maxv = max(R[j] - minv, maxv)
    minv = min(R[j-1],minv)
print(maxv)

Failing test case input:
3
5
2
3

Expected output:
1


Actual output:
-2


Fixed submission (verdict: Accepted):
n = int(input())
R = []
for _ in range(n):
    R.append(int(input()))

maxv = R[1] - R[0]
minv = R[0]
for j in range(1, n):
    maxv = max(R[j] - minv, maxv)
    minv = min(R[j],minv)
print(maxv)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())

l = [ int(input()) for _ in range(N) ]

mini = l[0]
maxi = l[1] - l[0]

for num in l[1:]:
    mini = min(mini, num)
    maxi = max(maxi, num  - mini)

print(maxi)

Failing test case input:
3
2
1
-1

Expected output:
-1


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())

l = [ int(input()) for _ in range(N) ]

mini = l[0]
maxi = l[1] - l[0]

for num in l[1:]:
    maxi = max(maxi, num  - mini)
    mini = min(mini, num)

print(maxi)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
import sys
numbers = []
for line in sys.stdin:
	numbers.append(int(line))

max = numbers[2] - numbers[1]


for i in range(1, len(numbers) - 1):
	for j in range(i + 1, len(numbers)):
		if numbers[j - 1] - numbers[i] > max :
			max = numbers[j] - numbers[i]
print(max)


Failing test case input:
6
18
0
-1
6
2
6

Expected output:
7


Actual output:
3


Fixed submission (verdict: Accepted):
import sys
numbers = []
for line in sys.stdin:
	numbers.append(int(line))

answer = numbers[2] - numbers[1]
tmp_min = numbers[1]
for target in range(2, len(numbers)):
	answer =  max(numbers[target] - tmp_min ,answer)
	tmp_min = min(numbers[target] , tmp_min)

print(answer)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
R = list()

for _ in range(n):
    R.append(int(input()))

ans = R[1] - R[0]
min_R = R[0]

for r in R:
    min_R = min(min_R, r)
    ans   = max(ans, r - min_R)
print(ans)

Failing test case input:
3
4
3
2

Expected output:
-1

Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
R = list()

for _ in range(n):
    R.append(int(input()))

ans = R[1] - R[0]
min_R = R[0]

for i in range(1, n):
    ans   = max(ans, R[i] - min_R)
    min_R = min(min_R, R[i])
print(ans)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
if __name__ == '__main__':
	n = int(input())
	lists = list()

	for i in range(n):
		a = int(input())
		lists.append(a)

	S = None
	while lists:
		mini = min(lists)
		mini_ind = lists.index(mini)
		maxi = max(lists[mini_ind : len(lists)])

		T = maxi - mini
		if S is None or S < T:
			S = T
			lists = lists[0 : mini_ind]
			continue
		else:
			break

	print(S)


Failing test case input:
3
1
-5
-43

Expected output:
-6


Actual output:
0


Fixed submission (verdict: Accepted):
if __name__ == '__main__':
	n = int(input())
	lists = list()

	for i in range(n):
		a = int(input())
		lists.append(a)

	S = None
	while len(lists) > 1:
		mini = min(lists)
		mini_ind = lists.index(mini)
		l = len(lists)

		if mini_ind + 1 == l:
			if S is None or S < lists[mini_ind] - lists[mini_ind - 1]:
				S = lists[mini_ind] - lists[mini_ind - 1]
			lists.pop(mini_ind)
			continue


		maxi = max(lists[mini_ind : l])
		T = maxi - mini

		if S is None or S < T:
			S = T

		lists = lists[0 : mini_ind]
		continue

	print(S)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
import sys

def get_maximum_profit():
    element_number = int(input())
    v0 = int(input())
    v1 = int(input())

    min_v = min(v0, v1)
    max_profit = v1-v0

    for i in range(element_number-2):
        v = int(input())
        min_v = min(min_v, v)
        max_profit = max(max_profit, v-min_v)
        print(min_v, max_profit)

    print(max_profit)

if __name__ == '__main__':
    get_maximum_profit()

Failing test case input:
3
1
19
0

Expected output:
18


Actual output:
0 18
18


Fixed submission (verdict: Accepted):
import sys

def get_maximum_profit():
    element_number = int(input())
    v0 = int(input())
    v1 = int(input())

    min_v = min(v0, v1)
    max_profit = v1-v0

    for i in range(element_number-2):
        v = int(input())
        max_profit = max(max_profit, v-min_v)
        min_v = min(min_v, v)

    print(max_profit)

if __name__ == '__main__':
    get_maximum_profit()
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = [int(input()) for i in range(n)]
maximum = a[1]-a[0]
minimum = min(a[0], a[1])
for i in range(n):
    minimum = min(minimum, a[i])
    maximum = max(maximum, a[i] - minimum)
print(maximum)
        


Failing test case input:
3
5
1
-1

Expected output:
-2


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(input()) for i in range(n)]
ma = a[1]-a[0]
mi = a[0]
for i in range(1,n):
    ma = max(ma, a[i] - mi)
    mi = min(mi, a[i])
    
print(ma)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
import sys
numbers = []
for line in sys.stdin:
	numbers.append(int(line))

answer = numbers[2] - numbers[1]
tmp_min = numbers[1]
print("answer0 : "+ str(answer))


for target in range(2, len(numbers)):
	answer =  max(numbers[target] - tmp_min ,answer)
	tmp_min = min(numbers[target] , tmp_min)

print(answer)


Failing test case input:
6
-10
12
0
4
0
8

Expected output:
22


Actual output:
answer0 : 22
22


Fixed submission (verdict: Accepted):
import sys
numbers = []
for line in sys.stdin:
	numbers.append(int(line))

answer = numbers[2] - numbers[1]
tmp_min = numbers[1]
for target in range(2, len(numbers)):
	answer =  max(numbers[target] - tmp_min ,answer)
	tmp_min = min(numbers[target] , tmp_min)

print(answer)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
row_num = int(input())
nums = []
for row in range(row_num):
    nums.append(int(input()))

max_diff = 0
for i in range(len(nums)):
    for j in range(i+1, len(nums)):
        diff = nums[j] - nums[i]
        if max_diff > abs(diff):
            continue
        else:
            max_diff = diff

print(max_diff)



Failing test case input:
6
-1
37
1
0
-2
0

Expected output:
38


Actual output:
2


Fixed submission (verdict: Accepted):
row_num = int(input())
nums = []
for row in range(row_num):
    nums.append(int(input()))

min_diff = nums[0]
max_diff = nums[1] - nums[0]
for i in range(1, len(nums)):
    if max_diff < nums[i] - min_diff:
        max_diff = nums[i] - min_diff
    if min_diff > nums[i]:
        min_diff = nums[i]

print(max_diff)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
import sys
numbers = []
for line in sys.stdin:
	numbers.append(int(line))

answer = numbers[2] - numbers[1]

count = 1
while count < len(numbers) - 1:
	target = max(numbers[count : ])
	if target -  numbers[count] > answer :
		answer = target -  numbers[count]
	count += count

print(answer)


Failing test case input:
6
5
2
0
4
1
3

Expected output:
4


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
numbers = []
for line in sys.stdin:
	numbers.append(int(line))

answer = numbers[2] - numbers[1]
tmp_min = numbers[1]
for target in range(2, len(numbers)):
	answer =  max(numbers[target] - tmp_min ,answer)
	tmp_min = min(numbers[target] , tmp_min)

print(answer)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
minR = int(input())
maxR = int(input())-minR
for i in range(n-2):
    po = int(input())
    maxR = max(maxR,po-minR)
    minR = min(minR,po)
print(maxR)


Failing test case input:
3
4
2
3

Expected output:
1


Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
minR = int(input())
maxVal = -10**9-1
for i in range(n-1):
    po = int(input())
    maxVal = max(maxVal, po - minR)
    minR = min(minR, po)
print(maxVal)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
intMax = -100000000
inputData = int(input())
inputList = list()
for i in range(inputData):
    inputList.append(int(input()))

inputDataMax = intMax
inputDataMin = inputList[0]
for i in range(inputData):
    inputDataMax = max(inputDataMax,  inputList[i] - inputDataMin)
    inputDataMin = min(inputDataMin, inputList[i])

print(inputDataMax)



Failing test case input:
3
2
1
-1

Expected output:
-1


Actual output:
0


Fixed submission (verdict: Accepted):
intMax = -10000000000
inputData = int(input())
inputList = list()
for i in range(inputData):
    inputList.append(int(input()))

inputDataMax = intMax
inputDataMin = inputList[0]
for i in range(inputData - 1):
    inputDataMax = max(inputDataMax,  inputList[i + 1] - inputDataMin)
    inputDataMin = min(inputDataMin, inputList[i + 1])

print(inputDataMax)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
def main():
    N = int(input())
    price = [int(input()) for i in range(N)]
    minv = price[0]
    maxv = -1
    for p in price:
        minv = min(minv, p)
        maxv = max(maxv, p-minv)
    print(maxv)



if __name__ == "__main__":
    import os
    import sys
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            fd = os.open("input.txt", os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main()

Failing test case input:
3
2
1
-1

Expected output:
-1


Actual output:
0


Fixed submission (verdict: Accepted):
def main():
    N = int(input())
    price = [int(input()) for i in range(N)]
    minv = float("inf")
    maxv = -float("inf")
    for p in price:
        maxv = max(maxv, p-minv)
        minv = min(minv, p)
    print(maxv)



if __name__ == "__main__":
    import os
    import sys
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            fd = os.open("input.txt", os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main()

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
r = []
for i in range(n):
    r.append(int(input()))

min = r[0]
max = -10000000000

for j in r[1:]:
    if j - min > max:
        max = j - min
    if min > j:
        min = j

Failing test case input:
6
-1
37
1
0
-2
0

Expected output:
38


Actual output:

Fixed submission (verdict: Accepted):
n = int(input())
r = []
for i in range(n):
    r.append(int(input()))

min = r[0]
max = -10 ** 12

for j in r[1:]:
    if j - min > max:
        max = j - min
    if min > j:
        min = j

print(max)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = [int(input()) for i in range(n)]
ma = a[1]-a[0]
mi = min(a[0], a[1])
for i in range(n):
    mi = min(mi, a[i])
    ma = max(ma, a[i] - mi)
print(ma)
        


Failing test case input:
3
1
-2
-24

Expected output:
-3


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(input()) for i in range(n)]
ma = a[1]-a[0]
mi = a[0]
for i in range(1,n):
    ma = max(ma, a[i] - mi)
    mi = min(mi, a[i])
    
print(ma)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())

max = a[1]-a[0]
for i in range(2,n):
    for j in range(0,i-1):
        tmp = a[i]-a[j]
        if max<tmp:
            max = tmp

print(max)


Failing test case input:
3
1
-3
4

Expected output:
7


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())

max = a[1]-a[0]
min = a[0]
for i in range(1,n):
    if max < (a[i]-min):
        max = (a[i]-min)
    if min > a[i]:
        min = a[i]
        
print(max)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
def main():
    n = int(input())
    t0 = int(input())
    t1 = int(input())
    tmpmin = t0
    tmpmax = t1 - t0

    for _ in range(n-2):
        t = int(input())
        if tmpmax < t - tmpmin:
            tmpmax = t - tmpmin 
        if t < tmpmin:
            tmpmax = t

    print(tmpmax)


if __name__ == '__main__':
    main()



Failing test case input:
6
-1
37
1
0
-2
0

Expected output:
38


Actual output:
1


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    t0 = int(input())
    t1 = int(input())
    tmpmin = t0
    tmpmax = t1 - t0
    tmpmin = min(t0, t1)

    for _ in range(2,n):
        t = int(input())
        if t - tmpmin > tmpmax:
            tmpmax = t - tmpmin 
        if t < tmpmin:
            tmpmin = t
    print(tmpmax)


if __name__ == '__main__':
    main()

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):



if __name__ == "__main__":
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))
    max = a[1] - a[0]
    for i in range(2, len(a)):
        for j in range(1, i):
            diff = a[i] - a[j]
            if diff > max:
                max = diff
    print(max)

Failing test case input:
3
-25
-1
0

Expected output:
25


Actual output:
24


Fixed submission (verdict: Accepted):



if __name__ == "__main__":
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))
    max = a[1] - a[0]
    mini = a[0]
    for i in range(1, len(a)):
        diff = a[i] - mini
        if diff > max:
            max = diff
        if mini > a[i]:
            mini = a[i]
    print(max)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
max = -1000000000
min = int(input())
for i in range(1, n):
  r = int(input())
  if max < (r - min):
    max = r - min
  if min > r:
    max = min
print(max)

Failing test case input:
3
1
-3
9

Expected output:
12


Actual output:
8


Fixed submission (verdict: Accepted):
n = int(input())
max = -1000000000
min = int(input())
for i in range(1, n):
  r = int(input())
  if max < (r - min):
    max = r - min
  if min > r:
    min = r
print(max)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())

min_rate = 10**9
max_prof = -1
for i in range(n):
    rate = int(input())
    prof = rate - min_rate
    if prof > max_prof:
        max_prof = prof
    if min_rate > rate:
        min_rate = rate

print(max_prof)


Failing test case input:
3
4
0
-5

Expected output:
-4


Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())

min_rate = 10**15
max_prof = -10**15
for i in range(n):
    rate = int(input())
    prof = rate - min_rate
    if prof > max_prof:
        max_prof = prof
    if min_rate > rate:
        min_rate = rate

print(max_prof)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
if __name__ == '__main__':
	n = int(input())
	lists = list()

	for i in range(n):
		a = int(input())
		lists.append(a)

	S = None
	while lists:
		mini = min(lists)
		mini_ind = lists.index(mini)
		maxi = max(lists[mini_ind : len(lists)])

		T = maxi - mini
		if S is None or S < T:
			S = T
		lists = lists[0 : mini_ind]
		continue

	print(S)


Failing test case input:
3
4
3
2

Expected output:
-1

Actual output:
0


Fixed submission (verdict: Accepted):
if __name__ == '__main__':
	n = int(input())
	lists = list()

	for i in range(n):
		a = int(input())
		lists.append(a)

	S = None
	while len(lists) > 1:
		mini = min(lists)
		mini_ind = lists.index(mini)
		l = len(lists)

		if mini_ind + 1 == l:
			if S is None or S < lists[mini_ind] - lists[mini_ind - 1]:
				S = lists[mini_ind] - lists[mini_ind - 1]
			lists.pop(mini_ind)
			continue


		maxi = max(lists[mini_ind : l])
		T = maxi - mini

		if S is None or S < T:
			S = T

		lists = lists[0 : mini_ind]
		continue

	print(S)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):



import math


n = int(input().strip())
a = []
for i in range(n):
    a.append(int(input().strip()))

min = 10000000000
cnt = -1000000000
for j in range(0,n):
    if min > a[j]:
        min = a[j]
    x = a[j] - min
    if cnt < x:
        cnt = x

print(cnt)

Failing test case input:
3
1
-2
-24

Expected output:
-3


Actual output:
0


Fixed submission (verdict: Accepted):



import math


n = int(input().strip())
a = []
for i in range(n):
    a.append(int(input().strip()))

min = a[0]
cnt = -1000000000
for j in range(1,n):
    x = a[j] - min
    if cnt < x:
        cnt = x

    if min > a[j]:
        min = a[j]
print(cnt)