Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
cnt = 0
id = 1
while a != []:
    if a[0] == a[1]:
        while a[id-1] == a[id] and id <= len(a)-1:
            id += 1
            if id == len(a):break
        del(a[:id-1])
        if id == n:
          cnt = 1
          break
        id = 1
    if a[0] > a[1]:
        while  a[id-1] >= a[id] and id <= len(a)-1:
            id += 1
            if id == len(a):break
    elif a[0] < a[1]:
        while a[id-1] <= a[id] and id <= len(a)-1:
            id += 1
            if id == len(a):break
    cnt += 1
    del(a[:id])
    id = 1

    if len(a)==1:
        cnt += 1
        break

print(cnt)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
cnt = 0
id = 1
while a != []:
    if len(a)==1:
        cnt += 1
        break
    if a[0] == a[1]:
        while a[id-1] == a[id] and id <= len(a)-1:
            id += 1
            if id == len(a):break
        if id == n:
            cnt = 1
            break
        del(a[:id-1])
        id = 1
    if a[0] > a[1]:
        while  a[id-1] >= a[id] and id <= len(a)-1:
            id += 1
            if id == len(a):break
    elif a[0] < a[1]:
        while a[id-1] <= a[id] and id <= len(a)-1:
            id += 1
            if id == len(a):break
    cnt += 1
    del(a[:id])
    id = 1


print(cnt)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
cnt = 0
id = 1
while a != []:
    if a[0] == a[1]:
        while a[id-1] == a[id] and id < len(a)-1:
            id += 1
        del(a[:id-1])
        id = 1
    if a[0] > a[1]:
        while  a[id-1] >= a[id] and id <= len(a)-1:
            id += 1
            if id == len(a):break
    elif a[0] < a[1]:
        while a[id-1] <= a[id] and id <= len(a)-1:
            id += 1
            if id == len(a):break
    cnt += 1
    del(a[:id])
    id = 1

    if len(a)==1:
        cnt += 1
        break

print(cnt)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
cnt = 0
id = 1
while a != []:
    if len(a)==1:
        cnt += 1
        break
    if a[0] == a[1]:
        while a[id-1] == a[id] and id <= len(a)-1:
            id += 1
            if id == len(a):break
        if id == n:
            cnt = 1
            break
        del(a[:id-1])
        id = 1
    if a[0] > a[1]:
        while  a[id-1] >= a[id] and id <= len(a)-1:
            id += 1
            if id == len(a):break
    elif a[0] < a[1]:
        while a[id-1] <= a[id] and id <= len(a)-1:
            id += 1
            if id == len(a):break
    cnt += 1
    del(a[:id])
    id = 1


print(cnt)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
cnt = 0
while a != []:
    id = 1
    if a[0] == a[1]:
        while a[id-1] == a[id]:
            id += 1
        del(a[:id-1])
        id = 1

    if a[0] > a[1]:
        while a[id-1] >= a[id] and id < len(a)-1:
            id += 1
    elif a[0] < a[1]:
        while a[id-1] <= a[id] and id < len(a)-1:
            id += 1
    cnt += 1
    if id ==len(a)-1:break 
    del(a[:id])

    if len(a)==1:
        cnt += 1
        break
print(cnt)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
cnt = 0
id = 1
while a != []:
    if len(a)==1:
        cnt += 1
        break
    if a[0] == a[1]:
        while a[id-1] == a[id] and id <= len(a)-1:
            id += 1
            if id == len(a):break
        if id == n:
            cnt = 1
            break
        del(a[:id-1])
        id = 1
    if a[0] > a[1]:
        while  a[id-1] >= a[id] and id <= len(a)-1:
            id += 1
            if id == len(a):break
    elif a[0] < a[1]:
        while a[id-1] <= a[id] and id <= len(a)-1:
            id += 1
            if id == len(a):break
    cnt += 1
    del(a[:id])
    id = 1


print(cnt)