ZhenlongDai/ACPR huggingface dataset:
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
m = int(input())
n = [int(input())for i in range(m)]

minv = n[0]
maxv = -99999999999

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

print(maxv)

Failing test case input:
3
1
-4
-24

Expected output:
-5


Actual output:
0


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

minv = n[0]
maxv = -99999999999

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

print(maxv)

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
s = []
for i in range(n):
    s.append(int(input()))
max_s = -10**9
min_s = s[0]
for i in range(1, n-1):
    max_s = max(max_s, s[i] - min_s)
    min_s = min(min_s, s[i])

print(max_s)


Failing test case input:
6
9
21
1
2
-27
-1

Expected output:
26


Actual output:
12


Fixed submission (verdict: Accepted):
n = int(input())
s = []
for i in range(n):
    s.append(int(input()))
max_s = -10**9
min_s = s[0]
for i in range(1, n):
    max_s = max(max_s, s[i] - min_s)
    min_s = min(min_s, s[i])

print(max_s)

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

before = int(input())
current = int(input())
diffMax = current - before
for i in range(n - 2):
  number = int(input())
  diff = number - current
  diffMax = max(diff, diffMax)
  current = min(current, number)
print(diffMax)



Failing test case input:
3
-78
0
2

Expected output:
80


Actual output:
78


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

before = int(input())
current = int(input())
diffMax = current - before
current = min(current, before)
for i in range(n - 2):
  number = int(input())
  diff = number - current
  diffMax = max(diff, diffMax)
  current = min(current, number)
print(diffMax)

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 = v0
    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
5
0
6

Expected output:
6


Actual output:
1


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 = []
for i in range(n):
    a.append(int(input()))

mini = a[0]
b = -100000

for i in a:
    if mini > i:
        mini = i
        print(mini)
    if b < i - mini:
        b = i - mini





Failing test case input:
3
-133
1
0

Expected output:
134


Actual output:

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):
n = int(input())
maxv = -2 * 10 ** 9
minv = 2 * 10 ** 9
for i in range(1, n):
    v = int(input())
    maxv = max(maxv, v - minv)
    minv = min(minv, v)
print(maxv)

Failing test case input:
3
5
0
6

Expected output:
6


Actual output:
-5


Fixed submission (verdict: Accepted):
n = int(input())
maxv = -2 * 10 ** 9
minv = 2 * 10 ** 9
for i in range(n):
    v = int(input())
    maxv = max(maxv, v - minv)
    minv = min(minv, v)
print(maxv)

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



def get_maximum_profit(value_list):
    minv = pow(10,9)
    profit = -minv
    for i in range(1, len(value_list)):
        profit = max(profit, value_list[i] - minv) 
        minv = min(minv, value_list[i])
    return profit

def main():
    n_list = int(input())
    target_list = [int(input()) for i in range(n_list)]
    print(get_maximum_profit(target_list))
    
if __name__ == "__main__":
    main()

Failing test case input:
3
-133
1
0

Expected output:
134


Actual output:
-1


Fixed submission (verdict: Accepted):



def get_maximum_profit(value_list, n_list):
    minv = pow(10,10) + 1
    profit = -minv
    for v in value_list:
        profit = max(profit, v - minv) 
        minv = min(minv, v)
    return profit

def main():
    n_list = int(input())
    target_list = [int(input()) for i in range(n_list)]
    print(get_maximum_profit(target_list, n_list))
    
if __name__ == "__main__":
    main()

Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
N=int(input())
R=[int(input()) for i in range(N)]
S=[0 for i in range(N)]
S[0]=R[0]
for i in range(1,N):
    S[i]=min(S[i-1],R[i])
print(max([R[i]-S[i] for i in range(N)]))



Failing test case input:
3
4
3
2

Expected output:
-1

Actual output:
0


Fixed submission (verdict: Accepted):
N=int(input())
R=[int(input()) for i in range(N)]
S=[0 for i in range(N)]
S[0]=R[0]
for i in range(1,N):
    S[i]=min(S[i-1],R[i])
T=[R[i+1]-S[i] for i in range(N-1)]
print(max(T))
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
nums = []
ns = []

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

for p in range(n):
    a = nums[p]
    for q in range(p+1,n-1):
        b = nums[q]
        ns.append(b-a)
        
print(max(ns))


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

Expected output:
3


Actual output:
2


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())
R = [int(input()) for i in range(n)]
profit= R[1] - R[0]
mn = R[0]
R.pop(0)
R.pop(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
2
0
0

Expected output:
0


Actual output:
-2


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
if False:

    fh=open('ALDS1_1_D2.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]
    for k in range(1, n-1):
        p=max(a[k+1:])-a[k] 
        if p > pmax:
            pmax=p

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



Failing test case input:
3
-78
0
2

Expected output:
80


Actual output:
78


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):
n = int(input())

t = []

for i in range(n):
    t.append(int(input()))

buy = t[0]
sell = max(t[1:])
val = sell - buy

for i in range(n-1):
    m = max(t[i+1:])
    val2 = m - t[i]
    if val2 > val:
        buy = t[i]
        sell = m
        val = val2

print(val2)



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

Expected output:
65


Actual output:
-1


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

t = []

for i in range(n):
    t.append(int(input()))

buy = t[0]
val = t[-1] - buy

for i in range(1, n):
    if t[i] - buy > val:
        val = t[i] - buy
    if t[i] < buy:
        buy = t[i]

print(val)
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(0, len(inputs)):
    maxv = max([maxv, inputs[i] - minv])
    minv = min([minv, inputs[i]])

print(maxv)




Failing test case input:
3
1
-4
-24

Expected output:
-5


Actual output:
0


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)]
max = A[1]-A[0]
min = A[0]

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


Failing test case input:
3
-129
0
4

Expected output:
133


Actual output:
129


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):
n = int(input())
buy = 1000000000
sell = 0
max_profit = -1000000000
for _ in range(n):
    r = int(input())
    if r < buy:
        buy = r
        max_profit = max(max_profit, sell - buy)
        sell = r
    else:
        sell = r
        max_profit = max(max_profit, sell - buy)

print(max_profit)
    


Failing test case input:
3
-66
-2
-2

Expected output:
64


Actual output:
66


Fixed submission (verdict: Accepted):
n = int(input())
buy = 2000000001
sell = 0
max_profit = -1000000001
for _ in range(n):
    r = int(input())
    if r < buy:
        max_profit = max(max_profit, r - buy)
        buy = r
    else:
        sell = r
        max_profit = max(max_profit, sell - buy)

print(max_profit)

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

maxv = 10**18
minv = 10**18

for i in range(n):
    r= int(input())
    maxv = max(maxv, r - minv)
    minv = min(minv, r)

print(maxv)



Failing test case input:
3
1
-2
4

Expected output:
6


Actual output:
1000000000000000000


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

maxv = -10**18
minv = 10**18

for i in range(n):
    r= int(input())
    maxv = max(maxv, r - minv)
    minv = min(minv, r)

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

min = float('inf')

max_diff = -float('inf')

for _ in range(n-1):
    i = int(input())

    if max_diff < i - min:
        max_diff = i - min

    if i < min:
        min = i

print(max_diff)

Failing test case input:
6
2
0
-11
0
-2
2

Expected output:
13


Actual output:
11


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

min = float('inf')
max_diff = -float('inf')

for _ in range(n):
    i = int(input())

    if max_diff < i - min:
        max_diff = i - min

    if i < min:
        min = i

print(max_diff)

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

for i in range(N):
	a.append(int(input()))

maxv = -10e10
minv = a[0]

for i in range(1, N-1):
	maxv = a[i] - minv if maxv < a[i] - minv else maxv
	minv = a[i] if minv > a[i] else minv

print(maxv)


Failing test case input:
3
3
0
9

Expected output:
9


Actual output:
-3


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

for i in range(N):
	a.append(int(input()))

maxv = -10e10
minv = a[0]

for i in range(1, N):
	maxv = a[i] - minv if maxv < a[i] - minv else maxv
	minv = a[i] if minv > a[i] else minv

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 = a[1]-a[0]
for i in range(1,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
-78
0
4

Expected output:
82


Actual output:
78


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):


def Maximum_Profit(n,A):
    Max=A[1]-A[0]
    Min=A[0]
    for j in range(1,n-1):
        Max=max(Max,A[j]-Min)
        Min=min(Min,A[j])
    return Max

if __name__ == "__main__":
    n=int(input())
    A=[]
    for i in range(n):
        A.append(int(input()))
    Max=Maximum_Profit(n,A)
    print(Max)



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

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):


def Maximum_Profit(n,A):
    Max=A[1]-A[0]
    Min=A[0]
    for j in range(1,n):
        Max=max(Max,A[j]-Min)
        Min=min(Min,A[j])
    return Max

if __name__ == "__main__":
    n=int(input())
    A=[]
    for i in range(n):
        A.append(int(input()))
    Max=Maximum_Profit(n,A)
    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]
nowmax = max(a[1:])
ans = nowmax - nowmin
for i in range(1,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
5
1
-1

Expected output:
-2


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
input()
mx = int(input())
res = -float('inf')
mn = float('inf')
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:
6
-10
12
0
4
0
8

Expected output:
22


Actual output:
8


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())
R = [int(input()) for i in range(n)]
maxv = R[1] - R[0]

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

print(maxv)

Failing test case input:
6
4
0
-2
25
-2
2

Expected output:
27


Actual output:
25


Fixed submission (verdict: Accepted):
n = int(input())
R = [int(input()) for i in range(n)]
maxv = R[1] - R[0]
minv = R[0]

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

print(maxv)

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

std = int(input())
val = []
for i in range(n-1):
    a = int(input())
    if i == n-2:
        val.append(a-std)
    else:
        if std > a:
            std = a
        else:
            val.append(a-std)

print(max(val))

Failing test case input:
3
4
0
-5

Expected output:
-4


Actual output:
-5


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

std = int(input())
val = []
alldiff = []
for i in range(n-1):
    a = int(input())
    alldiff.append(a-std)
    if i == n-2:
        val.append(a-std)
    else:
        if std > a:
            std = a
        else:
            val.append(a-std)

print(max(max(val),max(alldiff)))
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
q = int(input())
ary = []
for i in range(q):
    ary.append(int(input()))

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

for j in ary:
    minv= min(minv,j)
    maxv= max(maxv,j-minv)

print(maxv)

Failing test case input:
3
2
1
-1

Expected output:
-1


Actual output:
0


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

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

for j in ary[1:]:
    maxv= max(maxv,j-minv)
    minv= min(minv,j)

print(maxv)

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

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

print(maxv)

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

Expected output:
67


Actual output:
-1000000000


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, Rmin, R2 = [int(input()) for i in  range(3)]
Pmax = R2 - Rmin
for i in range(n-2):
    v = int(input())
    Pmax, Rmin = max(Pmax, v-Rmin), min(Rmin, v)
print(Pmax)

Failing test case input:
3
5
0
10

Expected output:
10


Actual output:
5


Fixed submission (verdict: Accepted):
n, Pmax, Rmin  = int(input()), float('-inf'), float('inf')
for i in range(n):
    v = int(input())
    Pmax, Rmin = max(Pmax, v-Rmin), min(Rmin, v)
print(Pmax)

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

minv = ary[0]
maxv = ary[1] - ary[0]
for i in range(2, n):
    maxv = max(maxv, ary[i] - minv)
    minv = min(minv, ary[i])

print(maxv)



Failing test case input:
3
1
-1
3

Expected output:
4


Actual output:
2


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

minv = min(ary[0], ary[1])
maxv = ary[1] - ary[0]
for i in range(2, n):
    maxv = max(maxv, ary[i] - minv)
    minv = min(minv, ary[i])

print(maxv)

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

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

maxv =  int(-20000000)
minv = int(r[0])

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

print(maxv)



Failing test case input:
3
1
-2
-24

Expected output:
-3


Actual output:
0


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

maxv = -10**18
minv = 10**18

for i in range(n):
    r= int(input())
    maxv = max(maxv, r - minv)
    minv = min(minv, r)

print(maxv)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
x = int(input())
l=[]
for i in range(x):
    l.append(int(input()))
MIN = 999999999999999999999999999999999999999
MAX = -9999999999999999999999999999999999999
for i in l:
    if i < MIN:
        MIN = i
        continue
    if i - MIN > MAX:
        MAX = i - MIN
print(MAX)

Failing test case input:
3
4
0
-5

Expected output:
-4


Actual output:
-9999999999999999999999999999999999999


Fixed submission (verdict: Accepted):
x = int(input())
l=[]
for i in range(x):
    l.append(int(input()))
MIN = 999999999999999999999999999999999999999
MAX = -9999999999999999999999999999999999999
for i in l:
    if i - MIN > MAX:
        MAX = i - MIN
    if i < MIN:
        MIN = i
print(MAX)

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 = -float("inf")
    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
1
-2
-24

Expected output:
-3


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())
min_n = 0
max_n = -2 * 10**9
for i in range(n):
    x = int(input())
    min_n = min(x,min_n)
    max_n = max(max_n,x - min_n)
print (max_n)

Failing test case input:
3
2
0
0

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
min_n = 2 * 10**9
max_n = -2 * 10**9
for i in range(n):
    x = int(input())
    max_n = max(max_n,x - min_n)
    min_n = min(x,min_n)
print (max_n)

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

a = list(map(int, input().split()))

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

for i in range(num):
    if minv > a[i]:
        minv = a[i]
    if a[i] - minv > maxv:
        maxv = a[i] - minv

print(maxv)


Failing test case input:
3
-42
0
2

Expected output:
44


Actual output:
-2000000000


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):


prof = 0
d = int(input())
li =[int(input()) for i in range(d)]
max = 0
while len(li)>1:
    for i in range(len(li)):
        if li[i]-li[0]>max:
            max= li[i]-li[0]
    li=li[1:]
print(max)

Failing test case input:
3
1
-5
-43

Expected output:
-6


Actual output:
0


Fixed submission (verdict: Accepted):


import math
prof = 0
d = int(input())
li =[int(input()) for i in range(d)]
max=float("-inf")
min=li[0]
for j in range(1,d):
    if li[j]-min>max:
        max=li[j]-min
    if li[j]<min:
        min=li[j]

print(max)

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

for i in range(times):
    element.append(int(input()))

maxv = element[1]-element[0]
minv = element[0]
for j in range(1,len(element)-1):
    maxv = max(element[j]-minv,maxv)
    minv = min(minv,element[j])

print(maxv)

Failing test case input:
3
5
0
10

Expected output:
10


Actual output:
-5


Fixed submission (verdict: Accepted):
times = int(input())
element = []

for i in range(times):
    element.append(int(input()))

maxv = element[1]-element[0]
minv = element[0]
for j in range(1,len(element)):
    maxv = max(element[j]-minv,maxv)
    minv = min(minv,element[j])

print(maxv)

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:
6
10
0
-1
6
2
6

Expected output:
7


Actual output:
10


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=[int(input()) for _ in range(N)]
mp=A[1]-A[0]
mn=min(A[0],A[1])
for i in range(1,N):
    if mp < (A[i]-mn):
        mp=A[i]-mn
    if A[i]<mn:
        mn=A[i]
print(mp)

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 _ in range(N)]
mp=A[1]-A[0]
mn=A[0]
for i in range(1,N):
    if mp < (A[i]-mn):
        mp=A[i]-mn
    if A[i]<mn:
        mn=A[i]
print(mp)
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
    p=a[j]-a[i]
    for k in range(2, n):
        if a[k]>a[j]:
            j=k
            p=max(p,a[j]-a[i])
        else:
            i=k
            j=k
    print(p)
    
if __name__ == "__main__":
    main()



Failing test case input:
3
1
-3
4

Expected output:
7


Actual output:
3


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())
        maxv = max(maxv, (r-minv))
        minv = min(minv, r)
    print(100)



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

Expected output:
23


Actual output:
100


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):
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-1):
    if(max < A[i]-min):
        max = A[i]-min
    if(min > A[i]):
        min = A[i]

print(max)



Failing test case input:
3
-178
0
2

Expected output:
180


Actual output:
178


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):
n = int(input())
ps = [int(input()) for _ in range(n)]
maxpro = 0
for i, p in enumerate(ps[:-1]):
  pro = max(ps[i + 1:]) - p
  maxpro = max(pro, maxpro)
print(maxpro)

Failing test case input:
3
4
0
-5

Expected output:
-4


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
ps = [int(input()) for _ in range(n)]
maxpro = -999999999
minp = 1000000000
for i, p in enumerate(ps[:-1]):
  if p >= minp: continue
  pro = max(ps[i + 1:]) - p
  maxpro = max(pro, maxpro)
  minp = p
print(maxpro)
Problem: p02258
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
R=[int(input()) for i in range(n)]
mini=10**9
maxi=0
for r in R:
    if r<mini:
        mini=r
    if r-mini>maxi:
        maxi=r-mini
print(maxi)


Failing test case input:
3
2
1
-1

Expected output:
-1


Actual output:
0


Fixed submission (verdict: Accepted):
n=int(input())
R=[int(input()) for i in range(n)]
mini=10**10
maxi=-10**10
for r in R:
    maxi=max([maxi,r-mini])
    mini=min([mini,r])
print(maxi)

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

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

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

print(maxv)


Failing test case input:
3
1
-2
-24

Expected output:
-3


Actual output:
0


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

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

maxv = R[1] - R[0]
minv = R[0]
for j in range(1, n):
    maxv = max(maxv, R[j]-minv)
    minv = min(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):
    maxv=max(maxv,n-minv)
    minv=min(minv,num[j])

print(maxv)

Failing test case input:
3
1
40
0

Expected output:
39


Actual output:
40


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())

minv = int(input())
maxv = int(input()) - minv

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

print(maxv)

Failing test case input:
3
5
1
-1

Expected output:
-2


Actual output:
-4


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):

def Maximum(R,n):
	Max=R[1]-R[0]
	Min=R[1]
	for i in range(2,n):
		tmp=R[i]-Min
		if Max<tmp:
			Max=tmp
		if Min>R[i]:
			Min=R[i]
	
	return Max

R=[]
n=int(input())
for i in range(n):
	R.append(int(input()))
	
Max=Maximum(R,n)	

print(Max)



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

Expected output:
67


Actual output:
66


Fixed submission (verdict: Accepted):

def Maximum(R,n):
	Max=-10**9
	Min=R[0]
	for i in range(1,n):
		tmp=R[i]-Min
		if Max<tmp:
			Max=tmp
		if Min>R[i]:
			Min=R[i]
	
	return Max

R=[]
n=int(input())
for i in range(n):
	R.append(int(input()))
	
Max=Maximum(R,n)	

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

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

print(maxv)

Failing test case input:
3
0
-2
9

Expected output:
11


Actual output:
9


Fixed submission (verdict: Accepted):
import math

n = int(input())
minv = int(input())
maxv = -math.pow(10, 9)

for _ in range(n-1):
    rt = int(input())
    maxv = max(maxv, rt - minv)
    minv = min(minv, rt)

print(maxv)

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

for _ in range(n - 2):
    r_t = int(input())
    g_max = max(r_t, r_min)
    r_min = min(r_t, r_min)
print(g_max)

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

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):
n = int(input())
r_min = int(input())
r_t = int(input())
g_max = r_t - r_min
r_min = min(r_t, r_min)

for _ in range(n - 2):
    r_t = int(input())
    g_max = max(g_max, r_t -r_min)
    r_min = min(r_t, r_min)
print(g_max)

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

A=[int(input()) for _ in range(N)]
mp=A[1]-A[0]
mn=min(A[0],A[1])
for i in range(N):
    if mp < (A[i]-mn):
        mp=A[i]-mn
    if A[i]<mn:
        mn=A[i]
print(mp)

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

Expected output:
7


Actual output:
18


Fixed submission (verdict: Accepted):
N=int(input())
A=[int(input()) for _ in range(N)]
mp=A[1]-A[0]
mn=A[0]
for i in range(1,N):
    if mp < (A[i]-mn):
        mp=A[i]-mn
    if A[i]<mn:
        mn=A[i]
print(mp)

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])

print(maxv)

Failing test case input:
3
5
0
3

Expected output:
3


Actual output:
-2


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())
Rt=[0 for i in range(n)]
for i in range(n):
    Rt[i]=int(input())
maxv=0
minv=Rt[0]
for j in range(1,n):
    maxv=max(maxv,Rt[j]-minv)
    minv=min(minv,Rt[j])
print(maxv)


Failing test case input:
3
2
1
-1

Expected output:
-1


Actual output:
0


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



def main():
  times = int(input())
  min_rate = None
  maxv = None
  for _ in range(0, times):
    rate = int(input())

    if min_rate is None:
      min_rate = rate
    elif maxv is None:
      maxv = rate - min_rate
    elif rate < min_rate:
      min_rate = rate
    elif rate - min_rate > maxv:
      maxv = rate - min_rate
  print(maxv)
  return 0


if __name__ == '__main__':
  main()

Failing test case input:
3
5
2
3

Expected output:
1


Actual output:
-3


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):
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)

		if mini_ind + 1 == len(lists):
			if S is None:
				for i in range(n - 1):
					T = lists[i + 1] - lists[i]
					if S is None or T > S:
						S = T
				break

			else:
				break

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

		if S is None or S < T:
			print(T,S)
			S = T

		lists = lists[0 : mini_ind]
		continue

	print(S)


Failing test case input:
3
4
1
3

Expected output:
2


Actual output:
2 None
2


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 solve():
    
    max_profit = -1
    min_stock = prices[0]
    for price in prices[1:]:
        max_profit = max(max_profit, price - min_stock)
        min_stock = min(min_stock, price)
    return max_profit


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    p_num = int(_input[0])
    prices = list(map(int, _input[1:]))
    print(solve())

Failing test case input:
3
1
-5
-43

Expected output:
-6


Actual output:
-1


Fixed submission (verdict: Accepted):





import sys


def solve():
    
    max_profit = -1 * float('inf')
    min_stock = prices[0]
    for price in prices[1:]:
        max_profit = max(max_profit, price - min_stock)
        min_stock = min(min_stock, price)
    return max_profit


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    p_num = int(_input[0])
    prices = list(map(int, _input[1:]))
    print(solve())
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(1,n):
    mi = min(mi, a[i])
    ma = max(ma, a[i] - mi)
print(ma)
        


Failing test case input:
3
5
1
-1

Expected output:
-2


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):

import sys
if False:

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

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

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



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

Expected output:
3


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):
N = int(input())
A = [int(input()) for i in range(N)]
max_v = A[1] - A[0]

l = 0
r = 1
while True:
    if A[l] > A[r]:
        l = r
        r += 1
    elif A[r + 1] < A[r]:
        max_v = max(max_v, A[r] - A[l])
        if A[l] > A[r + 1]:
            l = r + 1
            r += 2
        else:
            r += 1
    else:
        r += 1
    if r >= N - 1:
        print(max_v)
        exit()

Failing test case input:
3
3
0
9

Expected output:
9


Actual output:
-3


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

l = 0
r = 1
while r + 1 < N:
    if A[l] > A[r]:
        l = r
    elif A[r] > A[r + 1]:
        max_v = max(max_v, A[r] - A[l])
        if A[l] > A[r + 1]:
            l = r + 1
            r = l
    r += 1
if r<N:
    max_v = max(max_v, A[r] - A[l])
print(max_v)

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

mx = int(input())
res = -float('inf')
mn = float('inf')
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:
6
5
2
-1
4
1
3

Expected output:
5


Actual output:
6


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):
x = int(input())
l=[]
for i in range(x):
    l.append(int(input()))
MIN = 999999999999999999999999999999999999999
MAX = -9999999999999999999999999999999999999
for i in l:
    if i < MIN:
        MIN = i
    if i - MIN > MAX:
        MAX = i - MIN
print(MAX)

Failing test case input:
3
5
1
-1

Expected output:
-2


Actual output:
0


Fixed submission (verdict: Accepted):
x = int(input())
l=[]
for i in range(x):
    l.append(int(input()))
MIN = 999999999999999999999999999999999999999
MAX = -9999999999999999999999999999999999999
for i in l:
    if i - MIN > MAX:
        MAX = i - MIN
    if i < MIN:
        MIN = i
print(MAX)
Problem: p02317
Buggy submission (Python3, verdict: Wrong Answer):



n = int(input())
a = [int(input()) for j in range(n)]

dp = [1] * n
for i in range(n):
    ans = 0
    dp[i] = 1
    for j in range(i):
        if a[j] < a[i]:
            dp[i] = max(dp[i], dp[j]+1)

    ans = max(ans,dp[i])

print(ans)

Failing test case input:
3
1
2
0

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):


import bisect

n = int(input())
a = [int(input()) for j in range(n)]

dp = [a[0]]
for i in range(1,n):
    if dp[-1] < a[i]:
        dp.append(a[i])
        

    else:
        dp[bisect.bisect_left(dp, a[i])] = a[i]
        
print(len(dp))

Problem: p02317
Buggy submission (Python3, verdict: Wrong Answer):
import bisect
n = int(input())
A = [0]
for i in range(n):
    num  = int(input())
    if num>A[-1]:
        A.append(num)
    else:
        j = bisect.bisect_left(A, num)
        A[j] = num
print(len(A) - 1)

Failing test case input:
5
5
1
0
1
6

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
n = int(input())
A = []
for i in range(n):
    num  = int(input())
    if A == []:
        A.append(num)
    elif num > A[-1]:
        A.append(num)
    else:
        j = bisect.bisect_left(A, num)
        A[j] = num
print(len(A))

Problem: p02317
Buggy submission (Python3, verdict: Wrong Answer):
import bisect
n = int(input())
A = []
for i in range(n):
    num  = int(input())
    if A == []:
        A.append(num)
    elif num > A[-1]:
        A.append(num)
    else:
        j = bisect.bisect_left(A, num)
        A[j] = num
print(len(A) - 1)

Failing test case input:
5
0
2
1
0
11

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
n = int(input())
A = []
for i in range(n):
    num  = int(input())
    if A == []:
        A.append(num)
    elif num > A[-1]:
        A.append(num)
    else:
        j = bisect.bisect_left(A, num)
        A[j] = num
print(len(A))

Problem: p02317
Buggy submission (Python3, verdict: Wrong Answer):
import bisect
n = int(input())
A = [0]
for i in range(n):
    num  = int(input())
    if num>A[-1]:
        A.append(num)
    else:
        j = bisect.bisect_left(A, num)
        A[j] = num
print(len(A))

Failing test case input:
5
2
1
1
0
11

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
import bisect
n = int(input())
A = []
for i in range(n):
    num  = int(input())
    if A == []:
        A.append(num)
    elif num > A[-1]:
        A.append(num)
    else:
        j = bisect.bisect_left(A, num)
        A[j] = num
print(len(A))
Problem: p02317
Buggy submission (Python3, verdict: Wrong Answer):
import bisect

INF = 1 << 20


def main():
    n = int(input())
    a = [int(input()) for i in range(n)]

    dp = [INF for i in range(n+1)]
    dp[0] = 0
    for i in range(1, n+1):
        idx = bisect.bisect_left(dp, a[i-1])
        dp[idx] = a[i-1]

    ans = bisect.bisect_left(dp, INF) - 1
    print(ans)


if __name__ == '__main__':
    main()



Failing test case input:
5
14
1
0
1
11

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect

INF = 1 << 30


def main():
    n = int(input())
    a = [int(input()) for i in range(n)]

    dp = [INF for i in range(n+1)]
    for i in range(1, n+1):
        idx = bisect.bisect_left(dp, a[i-1])
        dp[idx] = a[i-1]

    ans = bisect.bisect_left(dp, INF)
    print(ans)


if __name__ == '__main__':
    main()

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



n = int(input())
a = [int(input()) for j in range(n)]

dp = [1] * n
for i in range(n):
    ans = 0
    for j in range(i):
        if a[j] < a[i]:
            dp[i] = max(dp[i], dp[j]+1)

    ans = max(ans,dp[i])

print(ans)

Failing test case input:
3
1
2
0

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):


import bisect

n = int(input())
a = [int(input()) for j in range(n)]

dp = [a[0]]
for i in range(1,n):
    if dp[-1] < a[i]:
        dp.append(a[i])
        

    else:
        dp[bisect.bisect_left(dp, a[i])] = a[i]
        
print(len(dp))

Problem: p02317
Buggy submission (Python3, verdict: Wrong Answer):
from bisect import bisect_left
n = int(input())
dp = []
a=[int(input()) for i in range(n)]
length=-1
for i in range(n):
    k = bisect_left(dp, a[i])
    dp.append(a[i])
    if(length < k):
        dp.append(a[i])
        length += 1
    else:   
        dp[k] = a[i]
print(length+1)


Failing test case input:
5
0
2
1
0
11

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
from bisect import bisect_left
n = int(input())
dp = []
a=[int(input()) for i in range(n)]
length=-1
for i in range(n):
    k = bisect_left(dp, a[i])
    if(length < k):
        dp.append(a[i])
        length += 1
    else:   
        dp[k] = a[i]
print(length+1)
Problem: p02622
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S=input()
T=input()
S=list(S)
T=list(T)
for i in range(len(S)):
    if(S[i]!=T[i]):
        S[i]=T[i]
print(i+1)
    

Failing test case input:
ddc`a
afcbb

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
S=input()
T=input()
S=list(S)
T=list(T)
j=0
for i in range(len(S)):
    if(S[i]!=T[i]):
        S[i]=T[i]
        j +=1
print(j)

Problem: p02622
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()

x = len(s)

num = 0
for i in range(0, x):
    if s[i] == t[i]:
        num += 1

print(num)

Failing test case input:
ddc`b
afccb

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
s = input()
t = input()

x = len(s)

num = 0
for i in range(0, x):
    if s[i] != t[i]:
        num += 1

print(num)

Problem: p02622
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A=input()
B=input()

ans=0
for a,b in zip(A,B):
    if a==b:
        ans+=1
print(ans)

Failing test case input:
qloae
oagpk

Expected output:
5


Actual output:
0


Fixed submission (verdict: Accepted):
A=input()
B=input()

ans=0
for a,b in zip(A,B):
    if a!=b:
        ans+=1
print(ans)

Problem: p02622
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()
count = 0
for i in range(len(S)):
  if S[i] != T[i]:
    count += 1
  elif S == T:
    print(0)
  else:
    pass
print(count)

Failing test case input:
elppa
elppa

Expected output:
0


Actual output:
0
0
0
0
0
0


Fixed submission (verdict: Accepted):
S = input()
T = input()
count = 0
for i in range(len(S)):
  if S[i] != T[i]:
    count += 1
  else:
    pass
print(count)

Problem: p02622
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def minchange(s,t):
  m=len(s)
  n=len(t)
  if n!=m:
    return -1
  cnt=[0]*256
  for i in range(n):
    cnt[ord(t[i])]+=1
  for i in range(n):
    cnt[ord(s[i])]-=1
  for i in range(256):
    if cnt[i]:
      return -1
  res=0
  i=n-1
  j=n-1
  while i>=0:
    while i>=0 and s[i]!=t[i]:
      i-=1
      res+=1
    if i>=0:
      i-=1
      j-=1
  return res
s=input()
t=input()
print(str(minchange(s,t)))
      
  


Failing test case input:
b`cbd
bgccd

Expected output:
2


Actual output:
-1


Fixed submission (verdict: Accepted):
def minchange(s,t):
  m=len(s)
  n=len(t)
  if n!=m:
    return -1
  cnt=[0]*256
  for i in range(n):
    cnt[ord(t[i])]+=1
  for i in range(n):
    cnt[ord(s[i])]-=1
  res=0
  i=n-1
  j=n-1
  while i>=0:
    while i>=0 and s[i]!=t[i]:
      i-=1
      res+=1
    if i>=0:
      i-=1
      j-=1
  return res
s=input()
t=input()
print(str(minchange(s,t)))

Problem: p02622
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()
ans = 0
if S == T:
  print(0)
else:
  for i in range(len(S)):
    if S[i] != T[i]:
      ans = ans + 1
print(ans)

Failing test case input:
apple
apple

Expected output:
0

Actual output:
0
0


Fixed submission (verdict: Accepted):
S = input()
T = input()
ans = 0
if S == T:
  ans = 0
else:
  for i in range(len(S)):
    if S[i] != T[i]:
      ans = ans + 1
print(ans)