ZhenlongDai/ACPR huggingface dataset:
Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n = int(input())
a = list(map(int,input().split()))
cnt = 0
first = True
up = False
down = False
for i in range(n):
    if first:
        cnt += 1
        now = a[i]
        if i < n-1:
            
            if a[i+1] > now:
                up = True
                down = False
                first = False
            elif a[i+1] < now:
                down = True
                up = False
                first = False
            else:
                up = False
                down = False
                first = False
    else:
        now = a[i]
        if i < n-1:
            if up:
                if now > a[i+1]:
                    first = True

            elif down:
                if now < a[i+1]:
                    first = True


print(cnt)


Failing test case input:
7
-1 -1 1 0 1 31150610 0000000101

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):

n = int(input())
a = list(map(int,input().split()))
cnt = 0
first = True
up = False
down = False
for i in range(n):
    
    if first:
        cnt += 1
        now = a[i]
        if i < n-1:
            
            if a[i+1] > now:
                
                up = True
                down = False
                first = False
            elif a[i+1] < now:
                
                down = True
                up = False
                first = False
            else:
                
                up = False
                down = False
                first = True
                cnt -= 1

            
    else:
        now = a[i]
        if i < n-1:
            if up:
                if now > a[i+1]:
                    first = True

            elif down:
                if now < a[i+1]:
                    first = True

print(cnt)

Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
ans=1
temp=0
cnt=0
for i in range(1,n-1):
  cnt=cnt+1
  if a[i-1]<a[i] and temp==0:
    temp=1
  elif a[i-1]>a[i] and temp==0:
    temp=2
  elif a[i-1]>a[i] and temp==1:
    temp=2
    if cnt>1:
      ans=ans+1
      cnt=0
  elif a[i-1]<a[i] and temp==2:
    temp=1
    if cnt>1:
      ans=ans+1
      cnt=0
if cnt==1:
  print(ans+1)
else:
  print(ans)

Failing test case input:
7
1 3 3 4 0 31150610 1000000100

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
ans=1
temp=0
for i in range(1,n):
  if a[i-1]<a[i] and temp==0:
    temp=1
  elif a[i-1]>a[i] and temp==0:
    temp=2
  elif a[i-1]>a[i] and temp==1:
    temp=0
    ans=ans+1
  elif a[i-1]<a[i] and temp==2:
    temp=0
    ans=ans+1
print(ans)
Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split(' ')))

ret = 1

i = 0
while i < n-2:
    if (a[i] > a[i+1] and a[i+1] < a[i+2]) or (a[i] < a[i+1] and a[i+1] > a[i+2]):
        ret += 1
        i += 2
    else:
        i += 1
        
print(ret)

Failing test case input:
9
1 2 1 2 2 2 1 2 1

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):

n = int(input())
a_ = list(map(int, input().split(' ')))
a = [-1]
i = 0
while  i < n:
    if a[-1] != a_[i]:
        a.append(a_[i])
    i += 1
a = a[1:]
n = len(a)

ret = 1

i = 0
while i < n-2:
    if (a[i] > a[i+1] and a[i+1] < a[i+2]) or (a[i] < a[i+1] and a[i+1] > a[i+2]):
        ret += 1
        i += 2
    else:
        i += 1
        
print(ret)

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

prev = 0
status = 1 
cnt = 1

for a in As:
    if status == 0: 
        if prev > a:
            status = -1
        elif prev < a:
            status = 1
    elif status == 1 : 
        if prev > a:
            status = 0
            cnt += 1
    else:
        if prev < a:
            status = 0
            cnt += 1
    prev = a

print(cnt)


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

Expected output:
3


Actual output:
4


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

prev = As[0]
status = 0 
cnt = 1

for a in As[1:]:
    if status == 0: 
        if prev > a:
            status = -1
        elif prev < a:
            status = 1
    elif status == 1 :  
        if prev > a:
            status = 0
            cnt += 1
    else:               
        if prev < a:
            status = 0
            cnt += 1
    prev = a

print(cnt)
Problem: p03745
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))
flag=0
answer=1
if N==1:
    print(1)
else:
    if A[0] < A[1]:
        flag = 1
    else:
        flag = -1
    for n in range(N - 1):
        if flag == 1:
            if A[n] <= A[n + 1]:
                pass
            else:
                flag = 0
                answer += 1
        elif flag == -1:
            if A[n] >= A[n + 1]:
                pass
            else:
                flag = 0
                answer += 1
        else:
            if A[n] == A[n + 1]:
                pass
            elif A[n] < A[n + 1]:
                flag = 1
            else:
                flag = -1
    print(answer)


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

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))
flag=0
answer=1
if N==1:
    print(1)
else:
    if A[0] < A[1]:
        flag = 1
    elif A[0]>A[1]:
        flag = -1
    for n in range(N - 1):
        if flag == 1:
            if A[n] <= A[n + 1]:
                pass
            else:
                flag = 0
                answer += 1
        elif flag == -1:
            if A[n] >= A[n + 1]:
                pass
            else:
                flag = 0
                answer += 1
        else:
            if A[n] == A[n + 1]:
                pass
            elif A[n] < A[n + 1]:
                flag = 1
            else:
                flag = -1
    print(answer)

Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
l=list(map(int,input().split()))
c=1
i=2

while i<n:
  if (l[i-2]<l[i-1] and l[i-1]>l[i]) or (l[i-2]>l[i-1] and l[i-1]<l[i]):
    c+=1
    i+=1
  i+=1

print(c)

Failing test case input:
9
1 2 1 2 2 2 1 2 1

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
*m,=map(int,input().split())
l=[]
l=[m[0]]+[m[i] for i in range(1,n) if m[i]!=m[i-1]]

c=1
i=2

while i<len(l):
  if (l[i-2]<l[i-1] and l[i-1]>l[i]) or (l[i-2]>l[i-1] and l[i-1]<l[i]):
    c+=1
    i+=1
  i+=1

print(c)
Problem: p03745
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))
if N==1:
    print(1)
    exit()

B=[A[i]-A[i-1] for i in range(1,N)]
ans=0
flag=False
for i in range(N-1):
    if B[i]!=0:
        first=B[i]
        flag=True
    if flag:
        break
for i in range(N-1):
    if first*B[i]>=0:
        pass
    else:
        ans+=1
        if i+1<=N-2:
            first=B[i+1]

print(ans+1)

Failing test case input:
7
0 -1 0 0 1 31150610 0000000101

Expected output:
3


Actual output:
2


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

B=[A[i]-A[i-1] for i in range(1,N)]
ans=0
flag=False
for i in range(N-1):
    if B[i]!=0:
        first=B[i]
        flag=True
    if flag:
        break
for i in range(N-1):
    if first*B[i]>=0:
        pass
    else:
        ans+=1
        j=i+1
        while j<=N-2:
            if B[j]!=0:
                first=B[j]
                break
            else:
                j+=1

print(ans+1)

Problem: p03745
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
num_list = list(map(int, input().split()))
ans = 1
cnt_list = [0] * n
a = int()

for i in range(1,n):
    if num_list[i-1] > num_list[i]:
        cnt_list[i] = -1
    if num_list[i-1] < num_list[i]:
        cnt_list[i] = 1

while 1 in cnt_list and -1 in cnt_list:
    del cnt_list[:max(cnt_list.index(1),cnt_list.index(-1))]
    ans += 1

print(ans)

Failing test case input:
9
0 0 1 -2 2 5 3 -3 0

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
n = int(input())
num_list = list(map(int, input().split()))
ans = 1
cnt_list = [0] * n
a = int()

for i in range(1,n):
    if num_list[i-1] > num_list[i]:
        cnt_list[i] = -1
    if num_list[i-1] < num_list[i]:
        cnt_list[i] = 1

while 1 in cnt_list and -1 in cnt_list:
    del cnt_list[:max(cnt_list.index(1),cnt_list.index(-1))]
    cnt_list[0] = 0
    ans += 1

print(ans)

Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
ans=1
temp=0
cnt=0
for i in range(1,n):
  cnt=cnt+1
  if a[i-1]<a[i] and temp==0:
    temp=1
  elif a[i-1]>a[i] and temp==0:
    temp=2
  elif a[i-1]>a[i] and temp==1:
    temp=2
    if cnt>1:
      ans=ans+1
      cnt=0
  elif a[i-1]<a[i] and temp==2:
    temp=1
    if cnt>1:
      ans=ans+1
      cnt=0
print(ans)

Failing test case input:
9
2 0 -1 -1 4 4 2 0 1

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
ans=1
temp=0
for i in range(1,n):
  if a[i-1]<a[i] and temp==0:
    temp=1
  elif a[i-1]>a[i] and temp==0:
    temp=2
  elif a[i-1]>a[i] and temp==1:
    temp=0
    ans=ans+1
  elif a[i-1]<a[i] and temp==2:
    temp=0
    ans=ans+1
print(ans)
Problem: p03745
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

cnt = 0

if n == 0:
    print(0)
else:
    jug = 2
    for i in range(n - 1):
        if jug == 2:
            if a[i] < a[i+1]:
                jug = 0
            elif a[i] > a[i+1]:
                jug = 1 
        elif jug == 0:
            if a[i] > a[i+1]:
                jug = 2
                cnt += 1
        elif jug == 2:
            if a[i] < a[i+1]:
                jug = 0
                cnt +=1
    print(cnt+1)


Failing test case input:
9
0 1 1 -1 2 13 3 -1 0

Expected output:
4


Actual output:
3


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

cnt = 0

jug = 2
for i in range(n - 1):
    if jug == 2:
        if a[i] < a[i+1]:
            jug = 0
        elif a[i] > a[i+1]:
            jug = 1 
    elif jug == 0:
        if a[i] > a[i+1]:
            jug = 2
            cnt += 1
    elif jug == 1:
        if a[i] < a[i+1]:
            jug = 2
            cnt +=1
print(cnt+1)

Problem: p03745
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

ans = 1
i = 0
while i < N - 2:
    if (A[i + 1] - A[i]) * (A[i + 2] - A[i + 1]) < 0:
        ans += 1
        i += 2
    else:
        i += 1
print(ans)


Failing test case input:
9
1 2 1 2 2 2 2 2 1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
B = []
i = 0
while i < N - 1:
    if A[i] != A[i+1]:
        B.append(A[i])
    i += 1
B.append(A[-1])

ans = 1
i = 0
while i < len(B) - 2:
    if (B[i + 1] - B[i]) * (B[i + 2] - B[i + 1]) < 0:
        ans += 1
        i += 2
    else:
        i += 1
print(ans)

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

ans = 1
mode = 0
for i in range(N-1):
    check = A[i+1] - A[i]
    if check >= 0:
        
        if mode == check == 0:
            pass
        elif mode >= 0 and check > 0:
            pass
            mode = check
        else:
            ans += 1
            
            mode = 0
    else:
        
        if mode <= 0 and check < 0:
            pass
            mode = check
        else:
            ans += 1
            
            mode = 0

print(ans)



Failing test case input:
7
0 3 3 4 0 31150610 1000000100

Expected output:
2


Actual output:
3


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

ans = 1
mode = 0
prev = A[0]

for i in A:
    check = i - prev

    if check == 0:
        pass
    elif check > 0:
        if mode >= 0:
            mode = check
        else:
            ans += 1
            mode = 0
    else:
        
        if mode <= 0:
            mode = check
        else:
            ans += 1
            mode = 0

    prev = i

print(ans)
Problem: p03745
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N  = int(input())
A = list(map(int, input().split()))
status = 0 
cnt = 1
for i in range(1,N):
    if A[i-1] < A[i]: 
        if status == 0:
            status = 1
        elif status == 2:
            status = 0
            cnt += 1
    elif A[i-1] > A[i]:
        if status == 0:
            status = 2
        elif status:
            status = 0
            cnt += 1
print(cnt)

Failing test case input:
9
2 0 -1 -1 4 4 2 0 1

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
N  = int(input())
A = list(map(int, input().split()))
status = 0 
cnt = 1
for i in range(1,N):
    if A[i-1] < A[i]: 
        if status == 0 or status == 1:
            status = 1
        else:
            status = 0
            cnt += 1
    elif A[i-1] > A[i]:
        if status == 0 or status == 2:
            status = 2
        else:
            status = 0
            cnt += 1
    else:
        continue
print(cnt)

Problem: p03745
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N  = int(input())
A = list(map(int, input().split()))
status = 0 
cnt = 0
pre = A[0]
for i in range(1,N):
    if pre < A[i]: 
        if status == 0:
            status = 1
        elif status == 2:
            status = 0
            cnt += 1
    elif pre > A[i]:
        if status == 0:
            status = 2
        elif status:
            status = 0
            cnt += 1
    pre = A[i]
print(cnt+1)

Failing test case input:
9
2 1 -1 -2 3 4 2 0 2

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
N  = int(input())
A = list(map(int, input().split()))
status = 0 
cnt = 1
for i in range(1,N):
    if A[i-1] < A[i]: 
        if status == 0 or status == 1:
            status = 1
        else:
            status = 0
            cnt += 1
    elif A[i-1] > A[i]:
        if status == 0 or status == 2:
            status = 2
        else:
            status = 0
            cnt += 1
    else:
        continue
print(cnt)
Problem: p03745
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import deque
def main():
    n, *a = map(int, read().split())
    a = deque(a)
    r = 1
    flag = False
    muki = 0
    n1 = a.popleft()
    while a:
        n2 = a.popleft()
        if flag:
            if n1 < n2 and muki:
                n1 = n2
            elif n1 > n2 and not muki:
                n1 = n2
            else:
                r += 1
                flag = False
                n1 = n2
        else:
            if n1 < n2:
                flag = True
                muki = 1
                n1 = n2
            elif n1 > n2:
                flag = True
                muki = 0
                n1 = n2
    print(r)

if __name__ == '__main__':
    main()

Failing test case input:
9
1 1 0 -2 4 8 8 -6 1

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import deque
def main():
    n, *a = map(int, read().split())
    a = deque(a)
    r = 1
    flag = False
    muki = 0
    n1 = a.popleft()
    while a:
        n2 = a.popleft()
        if flag:
            if n1 < n2 and muki:
                n1 = n2
            elif n1 > n2 and not muki:
                n1 = n2
            elif n1 == n2:
                pass
            else:
                r += 1
                flag = False
                n1 = n2
        else:
            if n1 < n2:
                flag = True
                muki = 1
                n1 = n2
            elif n1 > n2:
                flag = True
                muki = 0
                n1 = n2
    print(r)

if __name__ == '__main__':
    main()

Problem: p03745
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = [int(i) for i in input().split()]
nb = 0
da = 0
for i in range(len(A)-1):
    if A[i] > A[i+1] and da > 0:
        nb += 1
        da = 0
    elif A[i] < A[i+1] and da < 0:
        nb += 1
        da = 0
    else:
        da = A[i+1] - A[i]
print(nb + 1)

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

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(i) for i in input().split()]
nb = 0
da = 0
for i in range(len(A)-1):
    if A[i] > A[i+1] and da > 0:
        nb += 1
        da = 0
    elif A[i] < A[i+1] and da < 0:
        nb += 1
        da = 0
    else:
        if A[i+1] - A[i] != 0:
            da = A[i+1] - A[i]
print(nb + 1)
Problem: p03745
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
num_list = list(map(int, input().split()))
ans = 1
cnt_list = [0] * n

for i in range(1,n):
    if num_list[i-1] > num_list[i]:
        cnt_list[i] = -1
    if num_list[i-1] < num_list[i]:
        cnt_list[i] = 1

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

print(ans)

Failing test case input:
9
2 0 -1 -2 3 4 2 0 2

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
num_list = list(map(int, input().split()))
ans = 1
cnt_list = [0] * n
a = int()

for i in range(1,n):
    if num_list[i-1] > num_list[i]:
        cnt_list[i] = -1
    if num_list[i-1] < num_list[i]:
        cnt_list[i] = 1

while 1 in cnt_list and -1 in cnt_list:
    del cnt_list[:max(cnt_list.index(1),cnt_list.index(-1))]
    cnt_list[0] = 0
    ans += 1

print(ans)

Problem: p03745
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
alist = list(map(int, input().split()))

last = alist[0]
count = 1
status = 0  
for a in alist[1:]:
    if abs(last - a) > 1 or (status == 1 and last > a) or (status == 2 and last < a):
        count += 1
        status = 0
    elif status == 0 and last > a:
        status = 2
    elif status == 0 and last < a:
        status = 1
    last = a
print(count)


Failing test case input:
9
0 1 1 -1 2 10 2 -1 0

Expected output:
4


Actual output:
6


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

last = alist[0]
count = 1
status = 0  
for a in alist[1:]:
    if (status == 1 and last > a) or (status == 2 and last < a):
        count += 1
        status = 0
    elif status == 0 and last > a:
        status = 2
    elif status == 0 and last < a:
        status = 1
    last = a
print(count)

Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def solve(A, inc):

    ans = 1
    N = len(A)
    l = [0]*N
    for i in range(1, N):
        l[i] = A[i] - A[i-1]
    for i in range(1, N):
        if l[i]*l[i-1] < 0:
            l[i] = 0
            ans += 1
    return ans


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

print(solve(A, True))


Failing test case input:
9
1 2 0 2 2 2 2 1 1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
def solve(A, inc):

    ans = 1
    N = len(A)
    l = []
    for i in range(1, N):
        if A[i] > A[i-1]:
            l.append(1)
        elif A[i] < A[i-1]:
            l.append(-1)

    for i in range(1, len(l)):
        if l[i]*l[i-1] < 0:
            l[i] = 0
            ans += 1
    return ans


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

print(solve(A, True))
Problem: p03745
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):

n=int(input())
if n==1:
    print(1)
    exit()
*a,=map(int, input().split())
pre=a[1]-a[0]
ans=1
for i in range(2,n):
    if pre*(a[i]-a[i-1])<0:
        pre=0
        ans+=1
    else:
        pre=a[i]-a[i-1]
print(ans)


Failing test case input:
9
1 2 0 2 2 2 2 1 1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
def f(n,a):
    if n==1:
        print(1)
        exit()
    pre=a[1]-a[0]
    ans=1
    for i in range(2,n):
        if pre*(a[i]-a[i-1])<0:
            pre=0
            ans+=1
        else:
            if a[i]-a[i-1]:
                pre=a[i]-a[i-1]
    return ans

n=int(input())
*a,=map(int,input().split())
print(f(n,a))

Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
src = list(map(int,input().split()))
asc = None
ans=1
for i in range(N-1):
    
    d = src[i+1]-src[i]
    
    if asc==None:
        asc = d > 0
        continue
    
    if d==0:
        continue
    
        
    if (asc and d<0) or (not asc and d>0):
        asc = None
        ans+=1
print(ans)

Failing test case input:
9
0 0 1 -2 2 5 3 -3 0

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
N = int(input())
src = list(map(int,input().split()))
asc = None
ans=1
for i in range(N-1):
    
    d = src[i+1]-src[i]
        
    if d==0:
        continue
    
    if asc==None:
        asc = d > 0
        continue
    
        
    if (asc and d<0) or (not asc and d>0):
        asc = None
        ans+=1
print(ans)

Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = input().split()

c = 1
i = 1
while i <= N-2:
	if int(A[i])-int(A[i-1]) > 0:
		if int(A[i+1])-int(A[i]) < 0:
			c += 1
			i += 2
		else:
			i += 1
	elif int(A[i])-int(A[i-1]) < 0:
		if int(A[i+1])-int(A[i]) > 0:
			c += 1
			i += 2
		else:
			i += 1
	else:
		c += 1
		i += 2

print(c)

Failing test case input:
7
0 3 3 4 0 31150610 1000000100

Expected output:
2


Actual output:
3


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

c = 1
i = 1

while i <= N-1:
	if int(A[i])-int(A[i-1]) == 0:
		del A[i-1]
		N -= 1
	else:
		i += 1

i = 1

while i <= N-2:
	if int(A[i])-int(A[i-1]) > 0:
		if int(A[i+1])-int(A[i]) < 0:
			c += 1
			i += 2
		else:
			i += 1
	else:
		if int(A[i+1])-int(A[i]) > 0:
			c += 1
			i += 2
		else:
			i += 1
 
print(c)
Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def solve():
  n = int(input())
  a = list(map(int, input().split()))
  state, cut = -1, 0
  for i in range(n-1):
    
    if a[i] < a[i+1]:
      if state != 1:
        cut += 1
      state = 1
    else:
      if state != 0:
        cut += 1
      state = 0
  return 0
 
if __name__ == "__main__":
  solve()


Failing test case input:
9
1 2 -1 2 2 2 2 1 1

Expected output:
3


Actual output:

Fixed submission (verdict: Accepted):
def solve():
  n = int(input())
  a = list(map(int, input().split()))
  g, z = 0, 0
  cut = 1
  for i in range(n-1):
    if a[i+1] > a[i]:
      g += 1
    elif a[i+1] < a[i]:
      z += 1
    if g != 0 and z != 0:
      cut += 1
      g, z = 0, 0
  print(cut)
  return 0
 
if __name__ == "__main__":
  solve()

Problem: p03745
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

cnt = 0

if n == 0:
    print(1)
else:
    jug = 2
    for i in range(n - 1):
        if jug == 2:
            if a[i] < a[i+1]:
                jug = 0
            elif a[i] > a[i+1]:
                jug = 1 
        elif jug == 0:
            if a[i] > a[i+1]:
                jug = 2
                cnt += 1
        elif jug == 2:
            if a[i] < a[i+1]:
                jug = 0
                cnt +=1
    print(cnt+1)



Failing test case input:
9
2 1 -1 1 7 4 3 1 0

Expected output:
3


Actual output:
1


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

cnt = 0

jug = 2
for i in range(n - 1):
    if jug == 2:
        if a[i] < a[i+1]:
            jug = 0
        elif a[i] > a[i+1]:
            jug = 1 
    elif jug == 0:
        if a[i] > a[i+1]:
            jug = 2
            cnt += 1
    elif jug == 1:
        if a[i] < a[i+1]:
            jug = 2
            cnt +=1
print(cnt+1)

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

n, *a = map(int, open(0).read().split())
c = 1
d = [1] * n
for i in range(2, n):
    if (a[i] - a[i - 1]) * (a[i - 1] - a[i - 2]) < 0 and d[i - 1]:
        c += 1
        d[i] = 0
print(c)


Failing test case input:
9
2 0 -2 -1 4 4 2 0 0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):

n, *a = map(int, open(0).read().split())
c = 1
d = [1] * n
a = [a[0]] + [a[i] for i in range(1, n) if a[i - 1] != a[i]]
for i in range(2, len(a)):
    if (a[i] - a[i - 1]) * (a[i - 1] - a[i - 2]) < 0 and d[i - 1]:
        c += 1
        d[i] = 0
print(c)
Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(_) for _ in input().split()]

def solve(N, A):
    if N <= 2:
        return 1
    s = 0
    result = 1
    i = 0
    while i < N-1:
        r = A[i+1] - A[i]
        if (r > 0 and s < 0) or (r < 0 and s > 0):
            result += 1
            s = 0
        else:
            s = r
        i += 1
    return result

print(solve(N, A))


Failing test case input:
9
2 0 -1 -1 4 4 2 0 1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(_) for _ in input().split()]

def solve(N, A):
    if N <= 2:
        return 1
    s = 0
    result = 1
    i = 0
    while i < N-1:
        r = A[i+1] - A[i]
        if (r > 0 and s < 0) or (r < 0 and s > 0):
            result += 1
            s = 0
        elif r != 0:
            s = r
        i += 1
    return result

print(solve(N, A))

Problem: p03745
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

cnt = 0

jug = 2

for i in range(n - 1):
    if jug == 2:
        if a[i] < a[i+1]:
            jug = 0
        elif a[i] > a[i+1]:
            jug = 1 
    elif jug == 0:
        if a[i] > a[i+1]:
            jug = 2
            cnt += 1
    elif jug == 2:
        if a[i] < a[i+1]:
            jug = 0
            cnt +=1

print(cnt+1)


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

Expected output:
4


Actual output:
1


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

cnt = 0

jug = 2
for i in range(n - 1):
    if jug == 2:
        if a[i] < a[i+1]:
            jug = 0
        elif a[i] > a[i+1]:
            jug = 1 
    elif jug == 0:
        if a[i] > a[i+1]:
            jug = 2
            cnt += 1
    elif jug == 1:
        if a[i] < a[i+1]:
            jug = 2
            cnt +=1
print(cnt+1)
Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


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

trend=0
ans=0
for i in range(N-1):
    temp=A[i+1]-A[i]
    if trend==0:
        if temp>0:
            trend=1
            ans+=1
        elif temp<0:
            trend=-1
            ans+=1
        else:
            pass
    elif trend==1:
        if temp>0:
            pass
        elif temp<0:
            trend=0
        else:
            pass
    elif trend==-1:
        if temp>0:
            trend=0
        elif temp<0:
            pass
        else:
            pass
print(trend)
print(ans if trend!=0 else ans+1)


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

Expected output:
3


Actual output:
0
3


Fixed submission (verdict: Accepted):


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

trend=0
ans=0
for i in range(N-1):
    temp=A[i+1]-A[i]
    if trend==0:
        if temp>0:
            trend=1
            ans+=1
        elif temp<0:
            trend=-1
            ans+=1
        else:
            pass
    elif trend==1:
        if temp>0:
            pass
        elif temp<0:
            trend=0
        else:
            pass
    elif trend==-1:
        if temp>0:
            trend=0
        elif temp<0:
            pass
        else:
            pass

print(ans if trend!=0 else ans+1)

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

import collections
import itertools as it
import math

 

n = int(input())

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




if n == 1:
    print(1)
else:
    ans = 1
    state = lambda n1, n2: 0 if n1 == n2 else (1 if n2 > n1 else -1)
    diff = [state(a1, a2) for a1, a2 in zip(a[:-1], a[1:])]

    p = 1
    while p < len(diff):
        if abs(diff[p] - diff[p-1]) == 2:
            ans += 1
            p += 1

        p += 1

    print(ans)


Failing test case input:
9
2 1 -1 -1 4 4 2 0 0

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):

import collections
import itertools as it
import math

 

n = int(input())

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




if n == 1:
    print(1)
else:
    ans = 1
    state = lambda n1, n2: 0 if n1 == n2 else (1 if n2 > n1 else -1)
    diff = [state(a1, a2) for a1, a2 in zip(a[:-1], a[1:]) if state(a1, a2) != 0]

    p = 1
    while p < len(diff):
        if abs(diff[p] - diff[p-1]) == 2:
            ans += 1
            p += 1

        p += 1

    print(ans)
Problem: p03745
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    prev='ryouhou'
    cnt=0
    for i in range(n-1):
        if l[i+1]-l[i]>0:
            if prev=='-':
                cnt+=1
                prev='ryouhou'
            else:
                prev='+'
        elif l[i+1]-l[i]<0:
            if prev=='+':
                cnt+=1
                prev='ryouhou'
            else:
                prev='-'
        else:
            prev='ryouhou'
    print(cnt+1)
resolve()

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

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    prev='ryouhou'
    cnt=0
    for i in range(n-1):
        if l[i+1]-l[i]>0:
            if prev=='-':
                cnt+=1
                prev='ryouhou'
            else:
                prev='+'
        elif l[i+1]-l[i]<0:
            if prev=='+':
                cnt+=1
                prev='ryouhou'
            else:
                prev='-'
    print(cnt+1)
resolve()

Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
line = list(map(int,input().split()))
count = 0
up = False
down =False
for i in range(n - 1):
  if line[i] < line[i + 1]:
    up = True
  elif line[i] > line[i + 1]:
    down = True
  if up == down == True:
    count += 1
    up =False
    down =False
print(count)

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

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
line = list(map(int,input().split()))
count = 1
up = False
down =False
for i in range(n - 1):
  if line[i] < line[i + 1]:
    up = True
  elif line[i] > line[i + 1]:
    down = True
  if up == down == True:
    count += 1
    up =False
    down =False
print(count)

Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
A=list(map(int,input().split()))
def C(n,A):
    if n==1 or n==2:
        return 1
    else:
        cnt=1
        tmp=A[1]-A[0]
        for i in range(2,n):
            if (A[i]-A[i-1])*tmp<0:
                cnt+=1
                tmp=0
            else:
                tmp=A[i]-A[i-1]
        return cnt
print(C(n,A))

Failing test case input:
9
1 2 1 2 2 2 1 2 1

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
A=list(map(int,input().split()))
def C(n,A):
    if n==1 or n==2:
        return 1
    else:
        cnt=1
        d=A[1]-A[0]
        for i in range(2,n):
            if d:
                if (A[i]-A[i-1])*d<0:
                    cnt+=1
                    d=0
            else:
                d=A[i]-A[i-1]
        return cnt
print(C(n,A))
Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
cnt = 0
ans = 1
i = 1
while i < n - 1:
    if a[i - 1] < a[i] > a[i + 1] or a[i - 1] > a[i] < a[i + 1]:
        ans += 1
        i += 1
    i += 1
print(ans)

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

Expected output:
4


Actual output:
3


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

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

count = 0
a = 0
b = 0
for i in range(len(N)-1):
    if N[i+1] - N[i] > 0:
        b = 1
    elif N[i+1] - N[i] < 0:
        b = -1
    else:
        b = 0
        
    if a == 0:
        a = b  
    elif a == b:
        pass
    elif a == b * (-1):
        count += 1
    else:
        pass

print(count+1)

Failing test case input:
7
1 0 3 1 0 31150610 1000000101

Expected output:
3


Actual output:
4


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

count = 0
a = 0
b = 0
for i in range(len(N)-1):
    if N[i+1] - N[i] > 0:
        b = 1
    elif N[i+1] - N[i] < 0:
        b = -1
    else:
        b = 0
        
    if a == 0:
        a = b  
    elif a == b:
        pass
    elif a == b * (-1):
        count += 1
        a = 0
    else:
        pass

print(count+1)

Problem: p03745
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

cnt = 0

plus = 0
minus = 1
equal = 2

jug = equal

for i in range(n - 1):
    if jug == equal:
        if a[i] < a[i+1]:
            jug = plus
        elif a[i] > a[i+1]:
            jug = minus 
    elif jug == plus:
        if a[i] > a[i+1]:
            jug = minus
            cnt += 1
    elif jug == minus:
        if a[i] < a[i+1]:
            jug = plus
            cnt +=1

print(cnt+1)


Failing test case input:
7
1 4 3 4 1 999999999 1000000100

Expected output:
3


Actual output:
5


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

cnt = 0

jug = 2
for i in range(n - 1):
    if jug == 2:
        if a[i] < a[i+1]:
            jug = 0
        elif a[i] > a[i+1]:
            jug = 1 
    elif jug == 0:
        if a[i] > a[i+1]:
            jug = 2
            cnt += 1
    elif jug == 1:
        if a[i] < a[i+1]:
            jug = 2
            cnt +=1
print(cnt+1)
Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))

prev = A[0]
isUp = True
isDown = True

ans = 0
for a in A[1:]:
  if prev == a:
    pass
  elif prev < a:
    isDown = False
    if not isUp:
      isUp = True
      ans += 1
  elif a < prev:
    isUp = False
    if not isDown:
      isDown = True
      ans += 1
      
  prev = a
  
print(ans+1)

  
  


Failing test case input:
7
0 0 2 1 1 31150610 1000000101

Expected output:
2


Actual output:
3


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

prev = A[0]
isUp = True
isDown = True

ans = 0
for a in A[1:]:
  if prev == a:
    pass
  elif prev < a:
    isDown = False
    if not isUp:
      isUp = True
      isDown = True
      ans += 1
  elif a < prev:
    isUp = False
    if not isDown:
      isUp = True
      isDown = True
      ans += 1
      
  prev = a
  
print(ans+1)

Problem: p03745
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import deque
 
n = int(input())
a = list(map(int,input().split()))
d = deque(a)
 
tmp = []
cnt = 0
while d:
  v = d.popleft()
  if len(tmp)<=1:
    pass
  else:
    if not (v >= tmp[-1] >= tmp[-2] or v <= tmp[-1] <= tmp[-2]):
      tmp = []
      cnt += 1
  tmp.append(v)

if tmp:
  cnt+=1
print(cnt)

Failing test case input:
9
1 2 1 2 2 2 2 2 1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from collections import deque
 
n = int(input())
a = list(map(int,input().split()))
d = deque(a)
 
tmp = []
cnt = 0
while d:
  v = d.popleft()
  if len(tmp)<=1:
    pass
  else:
    if not (v >= tmp[-1] >= tmp[-2] >= tmp[0] or v <= tmp[-1] <= tmp[-2] <= tmp[0]):
      tmp = []
      cnt += 1
  tmp.append(v)

if tmp:
  cnt+=1
print(cnt)
Problem: p03745
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
a = l()
i = 1
while i < n-1:
    if ((a[i-1]<a[i]) and (a[i]>a[i+1])) or ((a[i-1]>a[i]) and (a[i]<a[i+1])):
        cnt += 1
        i += 1
    i += 1

print(cnt+1) 

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

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

N = k()
A = l()
p = 0
ans = 1
for i in range(1, N):
    if p*(A[i]-A[i-1])<0:
        ans += 1
        p = 0
    elif A[i]-A[i-1] != 0:
        p = A[i]-A[i-1]
print(ans)
Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import pdb


def main():
    num = int(input())
    array = []
    tmp = input()
    for i in range(num):
        array.append(int(tmp.split()[i]))
        
    ans = 1
    div = 0
    prev = 0
    count = 0
    
    for tmp in array:
        count += 1
        if(count == 1):
            prev = tmp
            continue

        if div == 0:
            if prev < tmp:
                div = 1
            elif prev > tmp:
                div = -1
            else:
                if prev < tmp and div == -1:
                    ans += 1
                    div = 0
                elif prev > tmp and div == 1:
                    ans += 1
                    div = 0


        prev = tmp
        
    print(ans)

        
if __name__ == '__main__':
    main()


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

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
import pdb


def main():
    num = int(input())
    array = []
    tmp = input()
    tmp = tmp.split()
    for i in range(num):
        array.append(int(tmp[i]))
        
    ans = 1
    div = 0
    prev = 0
    count = 0
    
    for tmp in array:
        count += 1
        if count == 1:
            prev = tmp
            continue

        if div == 0:
            if prev < tmp:
                div = 1
            elif prev > tmp:
                div = -1
        else:
            if prev < tmp and div == -1:
                ans += 1
                div = 0
            elif prev > tmp and div == 1:
                ans += 1
                div = 0
                
        prev = tmp
        
    print(ans)

        
if __name__ == '__main__':
    main()

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

list = []
sim=0
for i in range(N-1):
  if A[i]<A[i+1]:
    list.append(1)
  if A[i]>A[i+1]:
    list.append(0)
  if A[i]==A[i+1]:
    sim+=1

print(list)

i = 0
count = 0

while i<N-2-sim:
  if list[i] != list[i+1]:
    count += 1
    i+=1
  i+=1

print(count + 1)

Failing test case input:
9
2 1 -1 -2 3 4 2 0 0

Expected output:
3


Actual output:
[0, 0, 0, 1, 1, 0, 0]
3


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

list = []
sim=0
for i in range(N-1):
  if A[i]<A[i+1]:
    list.append(1)
  if A[i]>A[i+1]:
    list.append(0)
  if A[i]==A[i+1]:
    sim+=1
    
i = 0
count = 0

while i<N-2-sim:
  if list[i] != list[i+1]:
    count += 1
    i+=1
  i+=1

print(count + 1)
Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
b = 0
c = True
cnt = 1
for i in range(len(a)):
    if b == 0:
        b += 1
    else:
        if b == 1:
            if a[i] > a[i-1]:
                c = True
                b += 1
            else:
                c = False
                b += 1
        else:
            if c:
                if a[i] <= a[i-1]:
                    cnt += 1
                    b = 1
            else:
                if a[i] > a[i-1]:
                    cnt += 1
                    b = 1
print(cnt)


Failing test case input:
9
0 1 1 -1 2 13 2 -1 0

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
b = 0
c = True
cnt = 1
for i in range(len(a)):
    if b == 0:
        b += 1
    else:
        if b == 1:
            if a[i] > a[i-1]:
                c = True
                b += 1
            elif a[i] < a[i-1]:
                c = False
                b += 1
        else:
            if c:
                if a[i] < a[i-1]:
                    cnt += 1
                    b = 1
            else:
                if a[i] > a[i-1]:
                    cnt += 1
                    b = 1
print(cnt)

Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input()
state = 0
max = 0
min = 0
prev = 0
len = 0
ANS = 1
S = input()
A = list(map(int,S.split()))
 
for i in range(0,int(N)):

  len = len + 1
  if state in {0}:	
      state = 1
  elif state in {1}: 
    if A[i] > prev:
      state = 2

    elif A[i] < prev:
      state = 3

  elif state in {2}: 
    if A[i] < prev:
      state = 3
      if len > 1:
        ANS = ANS + 1
        len = 0

  elif state in {3}: 
    if A[i] > prev:
      state = 2
      if len > 1:
        ANS = ANS + 1
        len = 0

  prev = A[i]
if len == 1:
  ANS = ANS + 1
print(ANS)

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

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
N = input()
state = 0
max = 0
min = 0
prev = 0
len = 0
ANS = 1
S = input()
A = list(map(int,S.split()))
 
for i in range(0,int(N)):
  len = len + 1
  if state in {0}:	
      prev = A[i]
      state = 1
  elif state in {1}: 
    if A[i] > prev:
      state = 2
    elif A[i] < prev:
      state = 3
  elif state in {2}: 
    if A[i] < prev:
      state = 1
      ANS = ANS + 1
      len = 0
  elif state in {3}: 
    if A[i] > prev:
      state = 1
      ANS = ANS + 1
      len = 0
  prev = A[i]

print(ANS)
Problem: p03745
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())

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

B = []
C = []
for i in range(n):
    if len(C) == 0 or len(C) == 1:
        C.append(A[i])
    else:
        if C[-2] <= C[-1] and C[-1] <= A[i]:
            C.append(A[i])
        elif C[-2] >= C[-1] and C[-1] >= A[i]:
            C.append(A[i])
        else:
            B.append(C)
            C = []
            C.append(A[i])
if len(C) >= 1:
    B.append(C)
print(len(B))

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

Expected output:
4


Actual output:
3


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

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

B = []
C = []
for i in range(n):
    if len(C) == 0 or len(C) == 1:
        C.append(A[i])
    else:
        if C[-2] <= C[-1] and C[-1] < A[i]:
            C.append(A[i])
        elif C[-2] >= C[-1] and C[-1] > A[i]:
            C.append(A[i])
        elif (C[-2] <= C[-1] and C[-1] > A[i]) or (C[-2] >= C[-1] and C[-1] < A[i]):
            B.append(C)
            C = []
            C.append(A[i])
if len(C) >= 1:
    B.append(C)
print(len(B))

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




def solveProblem(allNumber,aSequence):
	flag="Flat"
	count = 1
	for i in range(allNumber-1):
		diff = aSequence[i+1]-aSequence[i]
		if flag == "Plus":
			if diff < 0:
				flag=="Flat"
				count=count+1
		elif flag == "Minus":
			if diff > 0:
				flag="Flat"
				count = count+1
		else:
			if diff > 0 :
				flag="Plus"
			else:
				flag="Minus"

	answer = count
	return answer


if __name__ == '__main__':
	N = int(input().strip())
	As = list(map(int,input().strip().split(' ')))
	solution = solveProblem(N,As)
	print("{}".format(solution))


Failing test case input:
7
0 0 3 4 0 31150610 1000000101

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):





def solveProblem(allNumber,aList):
	flag = "Flat"
	count = 1
	for i in range(allNumber - 1):
		b = aList[i + 1] - aList[i]
		if flag == "Plus":
			if b < 0:
				flag = "Flat"
				count = count+1
		elif flag == "Minus":
			if b > 0:
				flag = "Flag"
				count = count+1
		else:
			if b > 0:
				flag = "Plus"
			elif b < 0:
				flag = "Minus"
	answer = count
	return answer

if __name__ == '__main__':
	N = int(input().strip())
	As = list(map(int,input().split()))
	solution = solveProblem(N,As)
	print("{}".format(solution))

Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(i) for i in input().split()]
ret = 1
up, down = False, False
for i in range(N - 1):
    if A[i] < A[i + 1]:
        up = True
    elif A[i] > A[i + 1]:
        down = True
    if up and down:
        ret += 1
        up, false = False, False
print(ret)


Failing test case input:
9
1 1 0 -2 4 8 8 -6 1

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(i) for i in input().split()]
ret = 1
up, down = False, False
for i in range(N - 1):
    if A[i] < A[i + 1]:
        up = True
    elif A[i] > A[i + 1]:
        down = True
    if up == down == True:
        ret += 1
        up, down = False, False
print(ret)
Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
count = 0
up = 0
down = 0
before = A[0]
tmp = 0
for i in range(1,N):
  tmp = A[i]
  if (up == 0) and (down == 0):
    if tmp > before:
      up = 1
      before = tmp
    elif tmp < before:
      down = 1
      before = tmp
    else:
      continue
  elif up == 1:
    if tmp < before:
      count += 1
      up = 0
      before = tmp
  elif down == 1:
    if tmp > before:
      count += 1
      down = 0
      before = tmp
count += 1
print(count)
      


Failing test case input:
9
0 0 1 -2 2 5 3 -3 0

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
count = 0
up = 0
down = 0
before = A[0]
tmp = 0
for i in range(1,N):
  tmp = A[i]
  if (up == 0) and (down == 0):
    if tmp > before:
      up = 1
      before = tmp
    elif tmp < before:
      down = 1
      before = tmp
    else:
      continue
  elif up == 1:
    if tmp < before:
      count += 1
      up = 0
      before = tmp
    else:
      before = tmp
  elif down == 1:
    if tmp > before:
      count += 1
      down = 0
      before = tmp
    else:
      before = tmp
count += 1
print(count)

Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
ans = 1
temp = a[0]
st = 0
if n == 1:
    print(ans)
else:
    for i in a[1:]:
        if st == 1:
            if i < temp:
                st = 0
                ans += 1
        elif st == -1:
            print(111)
            if i > temp:
                st = 0
                ans += 1
        else:
            if temp > i:
                st = -1
            elif temp < i:
                st = 1
        temp = i
print(ans)

Failing test case input:
7
1 0 3 1 0 31150610 1000000101

Expected output:
3


Actual output:
111
111
111
3


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
ans = 1
temp = a[0]
st = 0
if n == 1:
    print(ans)
else:
    for i in a[1:]:
        if st == 1:
            if i < temp:
                st = 0
                ans += 1
        elif st == -1:
            if i > temp:
                st = 0
                ans += 1
        else:
            if temp > i:
                st = -1
            elif temp < i:
                st = 1
        temp = i
    print(ans)