Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

if N == 1:
    print(1)
elif N == 2:
    print(1)
else:
    cnt = 0
    for i in range(N - 1):
        if A[i] == A[i + 1]:
            A[i] = 0
            cnt += 1

    for _ in range(cnt):
        A.remove(0)
    #print(A)

    i = 1
    ans = 1
    n = len(A)
    while i < n - 1:
        if A[i-1] < A[i] < A[i+1] or A[i-1] > A[i] > A[i+1]:
            pass
        else:
            i += 1
            ans += 1
        i += 1
    print(ans)



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

if N == 1:
    print(1)
elif N == 2:
    print(1)
else:
    A = [B[0]]
    cnt = 0
    for i in range(N - 1):
        if B[i] == B[i + 1]:
            pass
        else:
            A.append(B[i+1])

    i = 1
    ans = 1
    n = len(A)
    while i < n - 1:
        if A[i-1] < A[i] < A[i+1] or A[i-1] > A[i] > A[i+1]:
            pass
        else:
            i += 1
            ans += 1
        i += 1
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

if N == 1:
    print(1)
elif N == 2:
    print(1)
else:
    cnt = 0
    for i in range(N - 1):
        if A[i] == A[i + 1]:
            A[i] = 0
            cnt += 1

    for _ in range(cnt):
        A.remove(0)
    #print(A)

    i = 1
    ans = 1
    while i < len(A) - 1:
        if A[i-1] < A[i] < A[i+1] or A[i-1] > A[i] > A[i+1]:
            pass
        else:
            i += 1
            ans += 1
        i += 1
    print(ans)



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

if N == 1:
    print(1)
elif N == 2:
    print(1)
else:
    A = [B[0]]
    cnt = 0
    for i in range(N - 1):
        if B[i] == B[i + 1]:
            pass
        else:
            A.append(B[i+1])

    i = 1
    ans = 1
    n = len(A)
    while i < n - 1:
        if A[i-1] < A[i] < A[i+1] or A[i-1] > A[i] > A[i+1]:
            pass
        else:
            i += 1
            ans += 1
        i += 1
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

if N == 1:
    print(1)
elif N == 2:
    print(1)
else:
    cnt = 0
    for i in range(N - 1):
        if A[i] == A[i + 1]:
            A[i] = '#'
            cnt += 1

    for _ in range(cnt):
        A.remove('#')
    #print(A)

    i = 1
    ans = 1
    while i < len(A) - 1:
        if A[i-1] < A[i] < A[i+1] or A[i-1] > A[i] > A[i+1]:
            pass
        else:
            i += 1
            ans += 1
        i += 1
    print(ans)



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

if N == 1:
    print(1)
elif N == 2:
    print(1)
else:
    A = [B[0]]
    cnt = 0
    for i in range(N - 1):
        if B[i] == B[i + 1]:
            pass
        else:
            A.append(B[i+1])

    i = 1
    ans = 1
    n = len(A)
    while i < n - 1:
        if A[i-1] < A[i] < A[i+1] or A[i-1] > A[i] > A[i+1]:
            pass
        else:
            i += 1
            ans += 1
        i += 1
    print(ans)

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


cnt = 0
for i in range(N - 1):
    if A[i] == A[i + 1]:
        A[i] = '#'
        cnt += 1

for _ in range(cnt):
    A.remove('#')
#print(A)

if A[0] < A[1]:
    plus = 1
else:
    plus = -1

i = 1
ans = 1
while i < len(A) - 1:
    if A[i-1] < A[i] < A[i+1] or A[i-1] > A[i] > A[i+1]:
        pass
    else:
        i += 1
        ans += 1
    i += 1
print(ans)



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

if N == 1:
    print(1)
elif N == 2:
    print(1)
else:
    A = [B[0]]
    cnt = 0
    for i in range(N - 1):
        if B[i] == B[i + 1]:
            pass
        else:
            A.append(B[i+1])

    i = 1
    ans = 1
    n = len(A)
    while i < n - 1:
        if A[i-1] < A[i] < A[i+1] or A[i-1] > A[i] > A[i+1]:
            pass
        else:
            i += 1
            ans += 1
        i += 1
    print(ans)

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


cnt = 0
for i in range(N - 1):
    if A[i] == A[i + 1]:
        A[i] = '#'
        cnt += 1

for _ in range(cnt):
    A.remove('#')
print(A)

if A[0] < A[1]:
    plus = 1
else:
    plus = -1

i = 1
ans = 1
while i < len(A) - 1:
    if A[i-1] < A[i] < A[i+1] or A[i-1] > A[i] > A[i+1]:
        pass
    else:
        i += 1
        ans += 1
    i += 1
print(ans)



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

if N == 1:
    print(1)
elif N == 2:
    print(1)
else:
    A = [B[0]]
    cnt = 0
    for i in range(N - 1):
        if B[i] == B[i + 1]:
            pass
        else:
            A.append(B[i+1])

    i = 1
    ans = 1
    n = len(A)
    while i < n - 1:
        if A[i-1] < A[i] < A[i+1] or A[i-1] > A[i] > A[i+1]:
            pass
        else:
            i += 1
            ans += 1
        i += 1
    print(ans)