Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
if N == 1:
    print(1)
    exit()
d = [A[i+1] - A[i] for i in range(N-1)]
def judge(list_hoge = d,count = 1):
    if len(list_hoge) == 1:
        print(count)
        return
    for i in range(1,len(list_hoge)):
        if list_hoge[i] * list_hoge[0] < 0:
            if i == len(list_hoge) - 1:
                print(count + 1)
                return
            else:
                return judge(list_hoge[i+1:],count + 1)
    print(count)
    return
judge()

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
state = 0
count = 1
for i in range(1,N):
    note = state
    d = A[i] - A[i-1]
    if d > 0:
        state = 1
    elif d == 0:
        pass
    elif d < 0:
        state = -1
    if (state,note) == (1,-1) or (state,note) == (-1,1):
        count += 1
        state = 0
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
if N <= 2:
    print(1)
    exit()
d = [A[i+1] - A[i] for i in range(N-1)]
def judge(list_hoge = d,count = 1):
    for i in range(1,len(list_hoge)):
        if list_hoge[i] * list_hoge[0] < 0:
            return judge(list_hoge[i+1:],count + 1)
    print(count)
judge()

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
state = 0
count = 1
for i in range(1,N):
    note = state
    d = A[i] - A[i-1]
    if d > 0:
        state = 1
    elif d == 0:
        pass
    elif d < 0:
        state = -1
    if (state,note) == (1,-1) or (state,note) == (-1,1):
        count += 1
        state = 0
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
if N == 1:
    print(1)
    exit()
d = [A[i+1] - A[i] for i in range(N-1)]
def judge(list_hoge = d,count = 1):
    for i in range(1,len(list_hoge)):
        if list_hoge[i] * list_hoge[0] < 0:
            return judge(list_hoge[i+1:],count + 1)
    print(count)
judge()


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
state = 0
count = 1
for i in range(1,N):
    note = state
    d = A[i] - A[i-1]
    if d > 0:
        state = 1
    elif d == 0:
        pass
    elif d < 0:
        state = -1
    if (state,note) == (1,-1) or (state,note) == (-1,1):
        count += 1
        state = 0
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
d = [A[i+1] - A[i] for i in range(N-1)]
def judge(list_hoge = d,count = 1):
    for i in range(1,len(list_hoge)):
        if list_hoge[i] * list_hoge[0] < 0:
            return judge(list_hoge[i+1:],count + 1)
    print(count)
judge()

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
state = 0
count = 1
for i in range(1,N):
    note = state
    d = A[i] - A[i-1]
    if d > 0:
        state = 1
    elif d == 0:
        pass
    elif d < 0:
        state = -1
    if (state,note) == (1,-1) or (state,note) == (-1,1):
        count += 1
        state = 0
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
if N == 1 or len(list(set(A))) == 1:
    print(1)
    exit()
def rec(list1,t):
    for i in range(1,len(list1)):
        if list1[i] - list1[i-1] > 0:
            note = "not decrease"
            break
        elif list1[i] - list1[i-1] < 0:
            note = "not increase"
            break
    for i in range(1,len(list1)):
        if note == "not decrease" and  list1[i] - list1[i-1] < 0:
            return rec(list1[i:],t+1)
        elif note == "not increase" and list1[i] - list1[i-1] > 0:
            return rec(list1[i:],t+1)
    return t
ans = rec(A,1)
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
state = 0
count = 1
for i in range(1,N):
    note = state
    d = A[i] - A[i-1]
    if d > 0:
        state = 1
    elif d == 0:
        pass
    elif d < 0:
        state = -1
    if (state,note) == (1,-1) or (state,note) == (-1,1):
        count += 1
        state = 0
print(count)