ZhenlongDai/ACPR huggingface dataset:
Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
ans = 0
tgt = A[0]
for i in range(1, N):
    if A[i-1] < A[i]:
        tgt = A[i]
    elif A[i-1] > A[i]:
        ans += tgt - A[i]

print(ans)

Failing test case input:
5
49 10 2 -4 -1

Expected output:
189


Actual output:
139


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
ans = 0
tgt = A[0]
for i in range(1, N):
    if tgt < A[i]:
        tgt = A[i]
    elif tgt > A[i]:
        ans += tgt - A[i]

print(ans)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

ans = 0
t = a[0]
for i in range(1, n):
    ans += max(a[i] - a[i-1], 0)

print(ans)

Failing test case input:
5
0 -1 0 36 2

Expected output:
35


Actual output:
37


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))

ans = 0
m = a[0]
for i in range(1, n):
    ans += max(m - a[i], 0)
    m = max(m, a[i])

print(ans)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = input()
A = []
A = input().split()
j = 0
t = A[0]
for i in A:
    if t>i:
        j += int(t)-int(i)
    if t<=i:
        t = i
print(j)

Failing test case input:
5
19 0 5 11 4

Expected output:
56


Actual output:
14


Fixed submission (verdict: Accepted):
N = input()
A = []
A = input().split()
j = 0
t = A[0]
for i in A:
    if int(i)<int(t):
        j += int(t)-int(i)
    if int(t)<int(i):
        t = i
print(j)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
maxi = a[0]
ans = 0

for i in range(1, n):
    if a[i - 1] > a[i]:
        ans += maxi - a[i]
    else:
        maxi = a[i]

print(ans)


Failing test case input:
5
16 2 5 11 4

Expected output:
42


Actual output:
21


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))

ans = 0
maxi = 0
for i in range(n):
    if a[i] < maxi:
        ans += (maxi - a[i])
        a[i] = maxi
    maxi = max(maxi, a[i])


print(ans)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
num = int(input())
item = input().split()
res = 0

for i in range(num):
  if i == 0:
    continue
  b = int(item[i - 1])
  t = int(item[i])
  
  if b > t:
    res += (b - t)
      
print(res)

Failing test case input:
5
16 2 5 11 4

Expected output:
42


Actual output:
21


Fixed submission (verdict: Accepted):
num = int(input())
item = input().split()
res = 0

for i in range(num):
  if i == 0:
    continue
  b = int(item[i - 1])
  t = int(item[i])
  
  if b > t:
    res += (b - t)
    item[i] = b
    
      
print(res)
Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a_list = list(map(int, input().split()))

h_list = [0]*(n+10)

for i in range(1,n):
    if a_list[i] < a_list[i-1]:
        h_list[i] = a_list[i-1] + h_list[i-1] - a_list[i] 
    elif a_list[i] >= a_list[i-1]:
        h_list[i] = 0
        
print(sum(h_list))

Failing test case input:
5
2 0 1 31 2

Expected output:
32


Actual output:
31


Fixed submission (verdict: Accepted):
n = int(input())
a_list = list(map(int, input().split()))
 
h_list = [0]*(n+10)
 
for i in range(1,len(a_list)):
    if a_list[i]  < a_list[i-1] + h_list[i-1]:
        h_list[i] = a_list[i-1] + h_list[i-1] - a_list[i] 
    elif a_list[i] >= a_list[i-1] + h_list[i-1]:
        h_list[i] = 0
        
print(sum(h_list))

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
stool = 0
for i in range(N):
    for j in range(i+1,i+2):
        if j >= N:
            break
        if A[i] > A[j]:
            stool += A[i] - A[j]
            A[j] += 1

print(stool)

Failing test case input:
5
4 -1 76 3 0

Expected output:
154


Actual output:
82


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
stool = 0
for i in range(N):
    for j in range(i+1,i+2):
        if j >= N:
            break
        if A[i] > A[j]:
            stool += A[i] - A[j]
            A[j] += A[i] - A[j]

print(stool)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(1, N):
  ans += max(0, A[i] - A[i-1])
print(ans)

Failing test case input:
5
4 0 0 96 -1

Expected output:
105


Actual output:
96


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
highest = A[0]
ans = 0
for i in range(1, N):
  highest = max(highest, A[i])
  ans += max(0, highest - A[i])
print(ans)

Problem: p02578
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(1,n):
    if a[i]>a[i-1]:
        ans+=a[i]-a[i-1]
print(ans)

Failing test case input:
5
1 -1 4 58 0

Expected output:
60


Actual output:
59


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
ans=0
ma=a[0]
for i in range(1,n):
    if a[i]<ma:
        ans+=(ma-a[i])
    ma=max(ma,a[i])
print(ans)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
s = 0

for i in range(0, n - 1):
    h = a[i] - a[i+1]
    if h > 0:
        s += h
        a[i] += h

print(str(s))


Failing test case input:
5
10 1 5 2 3

Expected output:
29


Actual output:
12


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
s = 0

for i in range(0, n - 1):
    h = a[i] - a[i+1]
    if h > 0:
        s += h
        a[i+1] = a[i]

print(str(s))
Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    for i in range(0, n-1):
        if a[i] < a[i+1]:
            step = a[i+1] - a[i]
            a[i] = a[i] + step
            cnt = cnt+step

    print(cnt)
main()

Failing test case input:
5
4 0 0 96 -1

Expected output:
105


Actual output:
96


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    for i in range(0, n-1):
        if a[i] > a[i+1]:
            step = a[i] - a[i+1]
            a[i+1] = a[i+1] + step
            cnt = cnt + step

    print(cnt)
main()

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
s = 0
for i in range(n-1):
  e = a[i+1]-a[i]
  if e > 0:
    s += e
  else:
    continue

print(s)

Failing test case input:
5
1 1 0 26 -1

Expected output:
28


Actual output:
26


Fixed submission (verdict: Accepted):

n = int(input())

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

p = 0

q = 0

for i in range(n-1):
  
  e = a[i+1]-a[i]
  if e > 0:
    if e > q:
      q = 0
    else:
      q = q-e
  else:
    q = q-e
  p += q
  
print(p)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
ans = 0
gap = 0

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

print(ans)


Failing test case input:
5
21 -1 1 14 6

Expected output:
64


Actual output:
30


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
ans = 0
maxi = A[0]

for i in range(1, N):
    if maxi > A[i]:
        ans += maxi-A[i]
    else:
        maxi = A[i]

print(ans)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
ans = 0

for i in range(1, n):
    if a[i] > a[i - 1]:
        ans += a[i] - a[i - 1]

print(ans)


Failing test case input:
5
1 3 3 3 3

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))

ans = 0
maxi = 0
for i in range(n):
    if a[i] < maxi:
        ans += (maxi - a[i])
        a[i] = maxi
    maxi = max(maxi, a[i])


print(ans)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
l=[int(i) for i in input().split()]
c=0
for i in range(1,n):
    c=max(c,max(l[i-1]-l[i],0))
    l[i]+=max(l[i-1]-l[i],0)
print(c)

Failing test case input:
5
2 1 0 8 2

Expected output:
9


Actual output:
6


Fixed submission (verdict: Accepted):
n=int(input())
l=[int(i) for i in input().split()]
c=0
for i in range(1,n):
    c+=max(l[i-1]-l[i],0)
    l[i]+=max(l[i-1]-l[i],0)
print(c)
Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
Alist=list(map(int,input().split()))
sum=0
if N==1:
  print(0)
else:
  for i in range(1,N):
    if Alist[i]<max(Alist[:i]):
      sum=sum+max(Alist[:i])-Alist[i]
      Alist[i]=max(Alist)
print(sum)

Failing test case input:
5
1 0 -6 36 3

Expected output:
41


Actual output:
76


Fixed submission (verdict: Accepted):
N=int(input())
Alist=list(map(int,input().split()))
sum=0
if N==1:
  print(0)
else:
  for i in range(1,N):
    if Alist[i]<=Alist[i-1]:
      sum=sum+Alist[i-1]-Alist[i]
      Alist[i]=Alist[i-1]
  print(sum)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))
fum=0
for i in range(N):
  if (A[i]<A[i-1]):
    B=A[i-1]-A[i]
    fum = fum+B
  else:
    fum=fum
print(fum)

Failing test case input:
5
0 1 2 8 4

Expected output:
4


Actual output:
8


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))
fum=0
for i in range(1,N):
  if (A[i]<A[i-1]):
    B=A[i-1]-A[i]
    A[i]=A[i]+B
    fum = fum+B
  else:
    fum=fum
print(fum)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
heights = list(map(int, input().split()))
steps = [0] * N
for i in range(1, N):
    if heights[i-1] + steps[i-1] > heights[i]:
        steps[i] = 0
    else:
        steps[i] = heights[i] - heights[i-1]
print (sum(steps))

Failing test case input:
5
4 -1 107 3 0

Expected output:
216


Actual output:
108


Fixed submission (verdict: Accepted):
N = int(input())
heights = list(map(int, input().split()))
steps = [0] * N
for i in range(1, N):
    if heights[i-1] + steps[i-1] > heights[i]:
        steps[i] = (heights[i-1] + steps[i-1]) - heights[i]
    else:
        steps[i] = 0
        
print (sum(steps))

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
ans = 0
d = 0

for i in range(1,n):
  if a[i-1]+d > a[i]:
    d = abs(a[i-1]-a[i])+d
    ans += d
    
  else:
    d = 0

print(ans)

Failing test case input:
5
16 2 5 11 4

Expected output:
42


Actual output:
84


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
ans = 0

for i in range(1,n):
  if a[i-1] > a[i]:
    ans += a[i-1]-a[i]
    a[i] = a[i] +  a[i-1] -a[i]
    
print(ans)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
l=[int(i) for i in input().split()]
m=l[0]
c=0
for i in range(1,n):
    if(l[i]<m):
        c=max(c,m-l[i])
    m=max(l[i],m)
print(c)

Failing test case input:
5
4 1 0 96 -1

Expected output:
104


Actual output:
97


Fixed submission (verdict: Accepted):
n=int(input())
l=[int(i) for i in input().split()]
c=0
for i in range(1,n):
    c+=max(l[i-1]-l[i],0)
    l[i]+=max(l[i-1]-l[i],0)
print(c)
Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = [int(i) for i in input().split()]
s = [0]*N

for i,n in enumerate(A[1:]):
    s[i] = max(0, A[i] - A[i-1])

print(sum(s))

Failing test case input:
5
16 2 5 6 2

Expected output:
49


Actual output:
18


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(i) for i in input().split()]
s = [0]*N
for i,n in enumerate(A):
    if i == 0:
        continue
    s[i] = max(0, A[i-1] + s[i-1] - A[i])

print(sum(s))

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
vals = list(map(int, input().split()))

ma = vals[0]
res = [0 for _ in range(n)]
for i, val in enumerate(vals):
    if val < ma: 
        res[i] = ma - val
    if ma < val:
        ma = val

print(max(res))

Failing test case input:
5
5 -1 175 1 0

Expected output:
355


Actual output:
175


Fixed submission (verdict: Accepted):
n = int(input())
vals = list(map(int, input().split()))

ma = vals[0]
res = [0 for _ in range(n)]
for i, val in enumerate(vals):
    if val < ma: 
        res[i] = ma - val
    if ma < val:
        ma = val

print(sum(res))

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

before = 0
d = [0] * N
for i in range(N):
    if i == 0:
        before = i
        continue

    if A[before] > A[i]:
        d[i] = (A[before] + d[before]) - A[i]
        before = i
    else:
        before = i

print(sum(d))


Failing test case input:
5
13 1 5 0 2

Expected output:
44


Actual output:
17


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

before = 0
d = [0] * N
for i in range(N):
    if i == 0:
        before = i
        continue

    if (A[before] + d[before]) > A[i]:
        d[i] = (A[before] + d[before]) - A[i]
        before = i
    else:
        before = i

print(sum(d))

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = sorted(map(int,input().split()))
b = []
for i in range(n-1):
    c = a[i+1]-a[i]
    if c >= 0:
        b.append(c)
print(sum(b))

Failing test case input:
5
16 2 5 11 4

Expected output:
42


Actual output:
14


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
b = []
c = 0
for i in range(1,n):
    c = max(c,a[i-1])
    s = c-a[i]
    if s >= 0:
        b.append(s) 
print(sum(b))

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

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

ans = 0
max_val = A[0]

for i in range(1, N):
    if max_val > A[i]:
        ans = max_val - A[i]
    else:
        max_val = A[i]
print(ans)

Failing test case input:
5
4 4 3 7 6

Expected output:
2


Actual output:
1


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

ans = 0
max_val = A[0]

for i in range(1, N):
    if max_val > A[i]:
        ans += max_val - A[i]
    else:
        max_val = A[i]
print(ans)
Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
array = list(map(int,input().split()))
new_array = [0] * N


for i in range(N-1):
    if array[i] > array[i+1]:
        new_array[i+1] = array[i]
print(sum(array) - sum(new_array))

Failing test case input:
5
0 0 1 41 11

Expected output:
30


Actual output:
12


Fixed submission (verdict: Accepted):
N = int(input())
array = list(map(int,input().split()))
new_array = array
t = sum(array)

for i in range(N-1):
    if array[i] > array[i+1]:
        array[i+1] = array[i]
print(sum(array) - t)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
ans = 0
maxh = 0
for i in range(len(a)-1):
    if a[i] > a[i+1]:
        if maxh < a[i]:
            maxh = a[i]
        ans += maxh - a[i+1]


print(ans)


Failing test case input:
5
22 10 1 -3 0

Expected output:
80


Actual output:
58


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
ans = 0
maxh = 0
for i in range(len(a)-1):
    if maxh < a[i]:
        maxh = a[i]
    if maxh > a[i+1]:
        ans += maxh - a[i+1]


print(ans)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
inputs = input().split()
As = []
sum = 0
step =0
for i in inputs:
    As.append(int(i))
try:
    for i in range(len(As)):
        if As[i] < As[i + 1]:
            step = As[i + 1] - As[i]
            sum += step 
except:
    pass

print(sum)

Failing test case input:
5
4 0 19 3 -1

Expected output:
40


Actual output:
19


Fixed submission (verdict: Accepted):
n = int(input())
As =list(map(int,input().split()))

sum = 0
step =0


for i in range(n):
    try:
        if As[i] > As[i + 1]:
            step = As[i] - As[i + 1]
            As[i + 1] += step
            sum += step 
    except IndexError:
        continue



print(sum)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
ans = 0
tmp = 0
for i in range(1,n):
    if a[i-1] > a[i]:
        tmp = max(a[i-1], tmp)
        ans += tmp - a[i]
print(ans)

Failing test case input:
5
13 1 5 1 2

Expected output:
43


Actual output:
24


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
ans = 0
tmp = a[0]
for i in range(1,n):
    tmp = max(a[i], tmp)
    ans += tmp - a[i]
print(ans)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N):
  if(i == 0):
    pass
  else:
    if(A[i] - A[i-1] <= 0):
      pass
    else:
      ans += A[i] - A[i-1]
print(ans)

Failing test case input:
5
21 -1 1 14 6

Expected output:
64


Actual output:
15


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N):
  if(i == 0):
    pass
  else:
    if(A[i] - A[i-1] >= 0):
      pass
    else:
      tmp = A[i-1] - A[i]
      ans += tmp
      A[i] += tmp
print(ans)
Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def solve():
    n = int(input())
    a = list(map(int, input().split()))
    mi = 0
    le = len(a)
    cost = 0
    for i in range(le-1):
        if a[i] > a[i+1]:
            mi = max(a[i], mi)
            cost += mi - a[i+1]
            print(mi - a[i+1], mi)
    cost += max(0, mi - a[-1])
    print(cost)
    return 0

if __name__ == "__main__":
    solve()

Failing test case input:
5
2 1 5 8 3

Expected output:
6


Actual output:
1 2
5 8
11


Fixed submission (verdict: Accepted):
def solve():
    n = int(input())
    a = list(map(int, input().split()))
    mi = 0
    le = len(a)
    cost = 0
    for i in range(le-1):
        if mi > a[i+1] or a[i] > a[i+1]:
            mi = max(a[i], mi)
            cost += mi - a[i+1]
    print(cost)
    return 0

if __name__ == "__main__":
    solve()

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = [0]*N
A = list(map(int, input().split()))
 
sum_step = 0
 
for n in range(0, N):
  if A[n] >= A[n-1]:
    pass
  else:
    sum_step += A[n-1] - A[n]
    A[n] = A[n-1]
  
print(sum_step)

Failing test case input:
5
2 1 1 16 6

Expected output:
12


Actual output:
24


Fixed submission (verdict: Accepted):
N = int(input())
A = [0]*N
A = list(map(int, input().split()))
 
sum_step = 0
 
for n in range(1,N):
  if A[n] < A[n-1]:
    sum_step += A[n-1] - A[n]
    A[n] = A[n-1]

print(sum_step)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))
B=0
Mi=A[0]

for i in range(1,N):
    if A[i] > A[i-1]:
        Mi = A[i]
    B += Mi - A[i]
print(B)

Failing test case input:
5
2 0 1 31 2

Expected output:
32


Actual output:
31


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))
B=0
Mi=A[0]

for i in range(1,N):
    if A[i] > Mi:
        Mi = A[i]
    B += Mi - A[i]
print(B)
Problem: p02578
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = list(map(int, input().split()))
    idx_start = 0
    sum_a = 0
    ans = 0
    len_a = len(a)

    for i in range(1, len_a):
        if a[idx_start] < a[i]:
            ans += ((i - idx_start) * a[idx_start]) - sum_a
            idx_start = i
            sum_a = 0
        else:
            sum_a += a[i]
            if i == len_a - 1:
                ans += ((i - idx_start) * a[idx_start]) - sum_a
    print(ans)
if __name__ == '__main__':
    main()


Failing test case input:
5
1 1 2 96 2

Expected output:
94


Actual output:
97


Fixed submission (verdict: Accepted):
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = list(map(int, input().split()))
    idx_start = 0
    sum_a = 0
    ans = 0
    cnt = 0
    len_a = len(a)

    for i in range(1, len_a):
        if a[idx_start] < a[i]:
            ans += (cnt * a[idx_start]) - sum_a
            idx_start = i
            sum_a = 0
            cnt = 0
        else:
            sum_a += a[i]
            cnt += 1
            if i == len_a - 1:
                ans += (cnt * a[idx_start]) - sum_a
    print(ans)
if __name__ == '__main__':
    main()

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
num = int(input())
height = list(map(int,input().split()))
count = 0

for i in range(len(height) - 1):
    while height[i] < height[i + 1]:
        height[i] += 1
        count += 1
print(count)

Failing test case input:
5
2 17 -14 -7 1

Expected output:
71


Actual output:
30


Fixed submission (verdict: Accepted):
num = input()
height = list(map(int,input().split()))
count = 0

for i in range(len(height) - 1):
    if height[i] > height[i+1]:
        count = count + (height[i]-height[i+1])
        height[i+1] = height[i]

print(count)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
l = list(map(int,input().split()))


ans=0
l2=[l[0]]


for i in range(1,n):
    if l[i-1] <= l[i]:
        l2+=[l[i]]
        continue
    else:
        l2+=[l2[i-1]]
        ans+=(l2[i]-l[i])

print(ans)

Failing test case input:
5
13 1 5 1 2

Expected output:
43


Actual output:
16


Fixed submission (verdict: Accepted):
n = int(input())
l = list(map(int,input().split()))

ans=0
l2=[l[0]]


for i in range(1,n):
    if l2[i-1] <= l[i]:
        l2+=[l[i]]
        continue
    else:
        l2+=[l2[i-1]]
        ans+=(l2[i]-l[i])

print(ans)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))

tmp = [0]*N
s = 0

for i in range(1,N):
    if A[i] >= A[i-1]+s:
        s = A[i] - A[i-1] - s
        tmp[i] = s
ans = sum(tmp)

print(ans)


Failing test case input:
5
16 2 5 11 4

Expected output:
42


Actual output:
6


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

tmp = [0]*N

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

ans = sum(tmp)

print(ans)
Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
ans,k=0,a[0]
for i in range(1,n):
    if a[i]>k:
        ans+=a[i]-k
    k=a[i]
print(ans)
    


Failing test case input:
5
19 0 5 11 4

Expected output:
56


Actual output:
11


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
ans,k=0,a[0]
for i in range(1,n):
    if a[i]<k:
        ans+=k-a[i]
    k=max(k,a[i])
print(ans)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
A = list(map(int, input().split()))

count=0
count2=0
for i in range(len(A)-1):
    if A[i]>A[i+1]:
        count=A[i]-A[i+1]
        print('count',count)
        A[i+1]=A[i]
        count2+=count
print(count2)

Failing test case input:
5
0 -1 1 19 4

Expected output:
16


Actual output:
count 1
count 15
16


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

count=0
count2=0

for i in range(len(A)-1):
    
    if A[i]>A[i+1]:
        count=A[i]-A[i+1]
        
        A[i+1]=A[i]
        count2+=count

print(count2)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = [0]*N
A = list(map(int, input().split()))
 
sum_step = 0
 
for n in range(1,N):
  if A[n] < A[n-1]:
    sum_step += A[n-1] - A[n]
    A[n] = A[n-1]
  print(sum_step)

Failing test case input:
5
0 0 1 10 2

Expected output:
8


Actual output:
0
0
0
8


Fixed submission (verdict: Accepted):
N = int(input())
A = [0]*N
A = list(map(int, input().split()))
 
sum_step = 0
 
for n in range(1,N):
  if A[n] < A[n-1]:
    sum_step += A[n-1] - A[n]
    A[n] = A[n-1]

print(sum_step)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
max_tool=0
n=int(input())
arr=list(map(int,input().split()))
maxi=arr[0]
for i in range(1,len(arr)):
  if arr[i]<maxi:
    max_tool=max(max_tool,maxi-arr[i])
  else:
    maxi=arr[i]
print (max_tool)

Failing test case input:
5
8 -1 107 2 0

Expected output:
221


Actual output:
107


Fixed submission (verdict: Accepted):
tool=0
n=int(input())
arr=list(map(int,input().split()))
maxi=arr[0]
for i in range(1,len(arr)):
  if arr[i]<maxi:
    tool+=(maxi-arr[i])
  else:
    maxi=arr[i]
print (tool)

Problem: p02578
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n=int(input())
a=get_array()
print(max(a)-min(a))

Failing test case input:
5
13 0 0 -1 0

Expected output:
53


Actual output:
14


Fixed submission (verdict: Accepted):
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n=int(input())
a=get_array()
arr=a[0]
ans=0
for i in range(n-1):
    if a[i+1]<arr:
        ans+=(arr-a[i+1])
    else:
        arr=a[i+1]
print(ans)
Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def abc176_c():
    n = int(input())
    a = list(map(int, input().split(' ')))
    ans = 0
    current_h = 0

    
    for i in range(1, len(a)):
        if i == 1:
            current_h = a[i]

        if a[i - 1] > a[i]:
            current_h = max(a[i - 1], current_h)
            ans += current_h - a[i]

    print(ans)

if __name__ == '__main__':
    abc176_c()


Failing test case input:
5
10 1 8 8 3

Expected output:
20


Actual output:
16


Fixed submission (verdict: Accepted):
def abc176_c():
    n = int(input())
    a = list(map(int, input().split(' ')))
    ans = 0
    most_h = 0

    for i in range(1, len(a)):
        if i == 1:
            most_h = max(a[i - 1], a[i])
            if a[i - 1] > a[i]:
                ans += a[i - 1] - a[i]
        else:
            if most_h > a[i]:
                ans += most_h - a[i]

        most_h = max(most_h, a[i])

    print(ans)

if __name__ == '__main__':
    abc176_c()

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
As =list(map(int,input().split()))

sum = 0
step =0


for i in range(n):
    try:
        if As[i] > As[i + 1]:
            step = As[i] - As[i + 1]
            As[i + 1] += step
            sum += step 
    except IndexError:
        continue


for i in range(len(As)):
    print(As[i],end=" ")
else:
    print("")
print(sum)

Failing test case input:
5
1 3 3 3 3

Expected output:
0


Actual output:
1 3 3 3 3 
0


Fixed submission (verdict: Accepted):
n = int(input())
As =list(map(int,input().split()))

sum = 0
step =0


for i in range(n):
    try:
        if As[i] > As[i + 1]:
            step = As[i] - As[i + 1]
            As[i + 1] += step
            sum += step 
    except IndexError:
        continue



print(sum)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
H = list(map(int, input().split()))
mh = 0
cnt = 0
for i in range(n - 1):
    mh = max(mh, H[i])
    if H[i] <= H[i + 1]:
        continue
    else:
        if H[i + 1] < H[i]:
            cnt += max(cnt, mh - H[i + 1])
print(cnt)

Failing test case input:
5
16 2 5 8 2

Expected output:
47


Actual output:
28


Fixed submission (verdict: Accepted):
n = int(input())
H = list(map(int, input().split()))
mh = 0
cnt = 0
for i in range(n - 1):
    mh = max(mh, H[i])
    if H[i] <= H[i + 1] and mh < H[i + 1]:
        continue
    else:
        cnt += mh - H[i + 1]
print(cnt)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))

ans=0
high=A[0]

for i in range(1,N):
    if A[i]>A[i-1]:
        high=A[i]
    else:
        ans+=high-A[i]

print(ans)

Failing test case input:
5
21 -2 1 14 6

Expected output:
65


Actual output:
31


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

ans=0
high=A[0]

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

print(ans)
Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
inputs = list(map(int,input().split()))
As = []
sum = 0
step =0
for i in inputs:
    As.append(int(i))
try:
    for i in range(len(As)):
        if As[i] < As[i + 1]:
            step = As[i + 1] - As[i]
            sum += step 
except:
    pass

print(sum)

Failing test case input:
5
1 1 -1 96 2

Expected output:
96


Actual output:
97


Fixed submission (verdict: Accepted):
n = int(input())
As =list(map(int,input().split()))

sum = 0
step =0


for i in range(n):
    try:
        if As[i] > As[i + 1]:
            step = As[i] - As[i + 1]
            As[i + 1] += step
            sum += step 
    except IndexError:
        continue



print(sum)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = map(int, input().split())

curr = 0
ans = 0
for a in A:
  if curr < a:
    curr = a
    ans += a-curr
print(ans)

Failing test case input:
5
2 1 2 8 4

Expected output:
5


Actual output:
0


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

curr = 0
ans = 0
for a in A:
  if curr > a:
    ans += curr - a
  else:
    curr = a
print(ans)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
l=list(map(int,input().split()))
tmp=l[0]
ans=0
for i in range(n-1):
    if l[i+1]<l[i]:
        ans+=(tmp-l[i+1])
    else:
        tmp=l[i+1]
print(ans)

Failing test case input:
5
13 1 5 0 2

Expected output:
44


Actual output:
17


Fixed submission (verdict: Accepted):
n=int(input())
l=list(map(int,input().split()))
tmp=l[0]
ans=0
for i in range(n):
    if tmp>=l[i]:
        ans+=(tmp-l[i])
    else:
        tmp=l[i]
print(ans)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())

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

t=0
x=0

for i in range(n):
  if t>l[i]:
    x+=t-l[i]
    t=l[i]
    
print(x)

Failing test case input:
5
0 1 1 16 6

Expected output:
10


Actual output:
0


Fixed submission (verdict: Accepted):
n=int(input())
 
l=list(map(int,input().split()))
 
t=l[0]
x=0
 
for i in range(n):
    if t>l[i]:
        x+=t-l[i]
    else:
        t=l[i]
    
print(x)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

ans = 0

for i in range(N - 1):
  ans += max(0, A[i - 1] - A[i])
  A[i] += max(0, A[i - 1] - A[i])
  
print(ans)

Failing test case input:
5
3 17 0 -7 1

Expected output:
57


Actual output:
41


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

ans = 0

for i in range(N - 1):
  ans += max(0, A[i] - A[i + 1])
  A[i + 1] += max(0, A[i] - A[i + 1])
  
print(ans)
Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
c = 0
for i in range(1,n):
    if a[i-1]>a[i]:
        c += (a[i-1]-a[i])
print(c)

Failing test case input:
5
21 -1 1 14 6

Expected output:
64


Actual output:
30


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
c = 0
for i in range(1,n):
    if a[i-1]>a[i]:
        q = (a[i-1]-a[i])
        c += q
        a[i] = a[i]+q
print(c)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
ans = 0

for i in range(1,n):
  if(a[i-1] > a[i]):
    while(a[i-1] == a[i]):
      a[i] += 1
      ans += 1
    
print(ans)

Failing test case input:
5
16 2 5 8 2

Expected output:
47


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
ans = 0
diff = 0

for i in range(1,n):
  if(a[i-1] > a[i]):
    diff = a[i-1] - a[i]
    a[i] += diff
    ans += diff
    
print(ans)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
l=list(map(int,input().split()))
mx=l[0]
an=0
for i in range(1,n):
  if l[i]<mx:
    an+=mx-l[i]
  else:
    l[i]=mx
print(an)

Failing test case input:
5
4 -1 38 3 0

Expected output:
78


Actual output:
10


Fixed submission (verdict: Accepted):
n=int(input())
l=list(map(int,input().split()))
mx=l[0]
an=0
for i in range(1,n):
  if l[i]<mx:
    an+=mx-l[i]
  else:
    mx=l[i]
print(an)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
input()
A=list(map(int,input().split()))
print(sum(A[i] - A[i-1] for i in range(1,len(A)) if A[i] > A[i-1]))


Failing test case input:
5
1 1 2 96 12

Expected output:
84


Actual output:
95


Fixed submission (verdict: Accepted):
input()
A=list(map(int,input().split()))
sum=0
for i in range(1,len(A)):
     if A[i] < A[i-1]:
         sum+=A[i-1] - A[i]
         A[i]=A[i-1]
print(sum)

Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
if __name__ == "__main__":
    n = int(input())
    x =list((int(x) for x in input().split()))
    print(x)
    
    tmp1 = 0
    tmp2 = x[0]
    for i in range(1,n):
        if tmp2 > x[i]:
            tmp3 = tmp2 - x[i]
            tmp1 += tmp3

            x[i] = x[i] + tmp3

    print(tmp1)


Failing test case input:
5
2 1 2 16 6

Expected output:
11


Actual output:
[2, 1, 2, 16, 6]
1


Fixed submission (verdict: Accepted):


if __name__ == "__main__":
    n = int(input())
    x =list((int(x) for x in input().split()))
    
    
    tmp1 = 0
    tmp2 = x[0]
    for i in range(1,n):
        if tmp2 > x[i]:
            tmp3 = tmp2 - x[i]
            tmp1 += tmp3

            x[i] = x[i] + tmp3
            tmp2 = x[i]
        else:
            tmp1 += 0
            tmp2 = x[i]

    print(tmp1)
Problem: p02578
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))
a=0
s=[]
for i in A:
  if i<a:
    s.append(i-a)
    a=i
  else:
    a=i
print(sum(s))

Failing test case input:
5
5 -1 175 0 0

Expected output:
356


Actual output:
-181


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))
a=0
s=[]
for i in A:
  if i<a:
    s.append(a-i)
    
  else:
    a=i
print(sum(s))
Problem: p02989
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
d = list(map(int,input().split()))
count = 0

d.sort()
m = int(n / 2)
i = d[m-2] + 1

while i<= d[m-1]:
  count +=1
  i +=1
  
print(count)

Failing test case input:
8
0 1 26 5 3 4 4 14

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
d = list(map(int,input().split()))
count = 0

d.sort()
m = int(n / 2)
i = d[m-2] + 1
if (d[m-1] != d[m]):
  print(d[m] - d[m-1])

elif (d[m-1] == d[m]):
  print(0)

Problem: p02989
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
d = list(map(int, input().split()))



prob = []
cnt = 0
for i in d:
    prob.append([cnt, i])
    cnt += 1


sorted_d = sorted(prob, key=lambda x: x[1])




cnt += sorted_d[int(N/2)][1] - sorted_d[int(N/2-1)][1]

print(cnt)


Failing test case input:
14
8817 479 146 2255 20 1313 2665 7051 2537 457 13 1296 001100 0

Expected output:
196


Actual output:
210


Fixed submission (verdict: Accepted):
N = int(input())
d = list(map(int, input().split()))



prob = []
cnt = 0
for i in d:
    prob.append([cnt, i])
    cnt += 1


sorted_d = sorted(prob, key=lambda x: x[1])


cnt = 0

cnt += sorted_d[int(N/2)][1] - sorted_d[int(N/2-1)][1]

print(cnt)

Problem: p02989
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
d=list(map(int,input().split()))
d.sort()
a=int(n/2)
i=int(n/2-1)
print(d)
if d[a]!=d[i]:
    num=d[a]-d[i]
    print(num)
else:
    print(0)

Failing test case input:
14
86113 3566 306 11668 74746 8478 23677 84052 60113 19737 660 11858 000011 -2

Expected output:
190


Actual output:
[-2, 11, 306, 660, 3566, 8478, 11668, 11858, 19737, 23677, 60113, 74746, 84052, 86113]
190


Fixed submission (verdict: Accepted):
n=int(input())
d=list(map(int,input().split()))
d.sort()
a=int(n/2)
i=int(n/2-1)
if d[a]!=d[i]:
    num=d[a]-d[i]
    print(num)
else:
    print(0)

Problem: p02989
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
L=list(map(int,input().split()))
L.sort
d=L[int(n/2)]-L[int(n/2)-1]


print(d)





Failing test case input:
14
8817 57 150 395 65 6701 1341 12407 163 47 10 257 011110 0

Expected output:
94


Actual output:
11066


Fixed submission (verdict: Accepted):
n=int(input())
L=list(map(int,input().split()))
L.sort()
d=L[n

print(d)
Problem: p02989
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False

def is_odd(num):
    if num % 2 == 1:
        return True
    else:
        return False


n=int(input())


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

d=sorted(d)
LEN=int(len(d)/2)
if is_even(LEN):
    if d[LEN]==d[LEN-1]:
        print(0)

    else:
        print(d[LEN]-d[LEN-1]+1)

elif is_odd(LEN):
    print(d[LEN]-d[LEN-1])



Failing test case input:
8
0 1 24 3 0 8 0 0

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False

def is_odd(num):
    if num % 2 == 1:
        return True
    else:
        return False


n=int(input())


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

d=sorted(d)
LEN=int(len(d)/2)
if is_even(LEN):
    if d[LEN]==d[LEN-1]:
        print(0)

    else:
        print(d[LEN]-d[LEN-1])

elif is_odd(LEN):
    if d[LEN]==d[LEN-1]:
        print(0)

    else:
        print(d[LEN]-d[LEN-1])

Problem: p02989
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
N=int(input())
d=list(map(int,input().split()))
d=sorted(d)
num=len(d)
ans=0
for i in range(N+1):
  tmp=bisect.bisect_left(d,i)
  if tmp==num-tmp:
    ans+=1
print(ans)
  


Failing test case input:
14
86113 15108 306 11668 74746 4722 57149 84052 60113 67320 11912 7406 001011 -1

Expected output:
3196


Actual output:
0


Fixed submission (verdict: Accepted):
import bisect
N=int(input())
d=list(map(int,input().split()))
d=sorted(d)
num=len(d)
ans=0
val=max(d)
for i in range(val+1):
  tmp=bisect.bisect_left(d,i)
  if tmp==num-tmp:
    ans+=1
print(ans)

Problem: p02989
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
d = list(map(int,input().split()))
d.sort()
while len(d) > 0:
        x = d.pop()
        y = d.pop(0)
print(y - x)


Failing test case input:
14
26445 151 347 37 65 3898 493 12407 227 5 10 257 011100 0

Expected output:
30


Actual output:
-30


Fixed submission (verdict: Accepted):
n = int(input())
d = list(map(int,input().split()))
d.sort()
while len(d) > 0:
        x = d.pop()
        y = d.pop(0)
print(x - y)

Problem: p02989
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
L=list(map(int,input().split()))
L.sort
d=L[int(n/2)]-L[int(n/2)]


print(d)




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

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n=int(input())
L=list(map(int,input().split()))
L.sort()
d=L[n

print(d)

Problem: p02989
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
d = sorted([int(x) for x in input().split(' ')])
if d[int(n/2)-1] == d[int(n/2)]:
    print(0)
else:
    print(d[int(n/2)] - d[int(n/2)-1]+1)

Failing test case input:
14
8817 485 150 2530 50 6701 1016 6261 163 93 10 164 001110 0

Expected output:
321


Actual output:
322


Fixed submission (verdict: Accepted):
n = int(input())
d = sorted([int(x) for x in input().split(' ')])
if d[int(n/2)-1] == d[int(n/2)]:
    print(0)
else:
    print(d[int(n/2)] - d[int(n/2)-1])
Problem: p02989
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from statistics import mean
import sys
N = int(input())
d = list(map(int,input().split()))

d.sort()
avg = mean(d) 

d1 = [i for i in d if i <= avg]
d2 = [i for i in d if i > avg]

if len(d1) == len(d2):
    a = d2[0] - d1[-1]
    print(a)
    sys.exit()
print(0)


Failing test case input:
14
86113 3566 306 11668 9814 8478 45073 31789 60113 19737 660 11858 000011 -2

Expected output:
1854


Actual output:
0


Fixed submission (verdict: Accepted):
from statistics import mean
import sys
N = int(input())
d = list(map(int,input().split()))

d.sort()

d1 = [d[i] for i in range(N
d2 = [d[i] for i in range(N

a = d2[0] - d1[-1]

if len(d1) == len(d2):
    print(a)
    sys.exit()
print(0)

Problem: p02989
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K=int(input())
D=[int(x) for x in input().split()]
D.sort()
M=K/2
m=M-1
ans=D[int(M)]-D[int(m)]
if ans==0:
  ans=1
print(ans)



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

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
K=int(input())
D=[int(x) for x in input().split()]
D.sort()
M=K/2
m=M-1
ans=D[int(M)]-D[int(m)]
print(ans)

Problem: p02989
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
value = list(map(int,input().split()))
value.sort()
print(value[(int(N/2))]-value[(int(N/2))-1]+1)

Failing test case input:
14
86113 15139 399 106285 83018 8967 57149 84052 60113 67320 51211 6176 101010 -1

Expected output:
2964


Actual output:
2965


Fixed submission (verdict: Accepted):
N = int(input())
value = list(map(int,input().split()))
value.sort()
print(value[(int(N/2))]-value[(int(N/2))-1])

Problem: p02989
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
nums = list(map(int,input().split()))

nums.sort()
print(nums)

if n%2==1:
    print(0)
else:
    x=int((n/2)-1)
    y=int(n/2)
    a=nums[x]
    b=nums[y]
    s=b-a
    print(s)


Failing test case input:
14
3728 87 455 12 0 714 447 12092 70 0 -1 562 011110 1

Expected output:
360


Actual output:
[-1, 0, 0, 1, 12, 70, 87, 447, 455, 562, 714, 3728, 11110, 12092]
360


Fixed submission (verdict: Accepted):
n = int(input())
nums = list(map(int,input().split()))

nums.sort()

if n%2==1:
    print(0)
else:
    x=int((n/2)-1)
    y=int(n/2)
    a=nums[x]
    b=nums[y]
    s=b-a
    print(s)

Problem: p02989
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
d = list(map(int,input().split()))

arc_list = list()
abc_list = list()

harf_num = int(n/2)

d.sort()
abc_list = d[:harf_num]
arc_list = d[harf_num:]

abc_max = max(abc_list)
arc_min = min(arc_list)

print(abc_max - arc_min)

Failing test case input:
14
99592 10342 4240 78532 83018 11639 57149 127350 30914 39830 51211 93284 101000 -1

Expected output:
5938


Actual output:
-5938


Fixed submission (verdict: Accepted):
n = int(input())
d = list(map(int,input().split()))

arc_list = list()
abc_list = list()

harf_num = int(n/2)

d.sort()
abc_list = d[:harf_num]
arc_list = d[harf_num:]

abc_max = max(abc_list)
arc_min = min(arc_list)

print(arc_min - abc_max)
Problem: p02989
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
D = sorted(list(map(int, input().split())))
check = []
half = int(len(D)/2)
D_lead = D[:half]
D_tail = D[half:]
if max(D_lead) != min(D_tail):
    check = [num for num in range(max(D_lead), min(D_tail)+1)]
    print(len(check))
else:
    print(0)

Failing test case input:
14
82925 3566 68 11668 2291 8478 42819 39244 16829 25786 333 885 000011 -2

Expected output:
4912


Actual output:
4913


Fixed submission (verdict: Accepted):
N = int(input())
D = sorted(list(map(int, input().split())))
check = []
half = int(len(D)/2)
D_lead = D[:half]
D_tail = D[half:]
if max(D_lead) != min(D_tail):
    check = [num for num in range(max(D_lead), min(D_tail))]
    print(len(check))
else:
    print(0)

Problem: p02989
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
d = list(map(int,input().split()))
d.sort()
print(d)
half = int(N/2)
dis = d[half] - d[half - 1]
print(dis)


Failing test case input:
14
99592 15139 4240 78532 83018 5810 57149 127350 30914 39830 51211 93284 101000 -1

Expected output:
5938


Actual output:
[-1, 4240, 5810, 15139, 30914, 39830, 51211, 57149, 78532, 83018, 93284, 99592, 101000, 127350]
5938


Fixed submission (verdict: Accepted):
N = int(input())
d = list(map(int,input().split()))
d.sort()

half = int(N/2)
dis = d[half] - d[half - 1]
print(dis)

Problem: p02989
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False

def is_odd(num):
    if num % 2 == 1:
        return True
    else:
        return False


n=int(input())


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

d=sorted(d)
LEN=int(len(d)/2)
if is_even(LEN):
    if d[LEN]==d[LEN-1]:
        print(0)

    else:
        print(d[LEN]-d[LEN-1]+1)

elif is_odd(LEN):
    if d[LEN]==d[LEN-1]:
        print(0)

    else:
        print(d[LEN]-d[LEN-1])



Failing test case input:
8
0 1 9 3 0 8 0 0

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False

def is_odd(num):
    if num % 2 == 1:
        return True
    else:
        return False


n=int(input())


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

d=sorted(d)
LEN=int(len(d)/2)
if is_even(LEN):
    if d[LEN]==d[LEN-1]:
        print(0)

    else:
        print(d[LEN]-d[LEN-1])

elif is_odd(LEN):
    if d[LEN]==d[LEN-1]:
        print(0)

    else:
        print(d[LEN]-d[LEN-1])

Problem: p02989
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N = int(input())

data = list(map(int, sorted(input().split())))
median = int(N / 2)

print(data[median] - data[median - 1])

Failing test case input:
14
26445 23 347 37 65 3898 493 12407 197 5 10 257 011100 0

Expected output:
60


Actual output:
26188


Fixed submission (verdict: Accepted):

N = int(input())

data = sorted(list(map(int, input().split())))
median = int(N / 2)

print(data[median] - data[median - 1])