ZhenlongDai/ACPR huggingface dataset:
Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))

ans = 1
i = 0

ls = [0]*(N-1)
for i in range(N-1):
  if A[i] > A[i+1]:
    ls[i] = 1
  elif A[i] < A[i+1]:
    ls[i] = -1
  else:
    if i == 0:
      ls[i] = 0
    else:
      ls[i] = ls[i-1]

print(ls)

j = 0
while j < N-2:
  if ls[j] == 1:
    if ls[j+1] == -1:
      ans += 1
      j += 1
  elif ls[j] == -1:
    if ls[j+1] == 1:
      ans += 1
      j += 1
  j += 1
print(ans)


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

Expected output:
3


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


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

Problem: p03745
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))
i,j,ans=0,0,0
while i<N:
    j=i
    while j<N and A[j]==A[i]: j+=1
    k=j
    while k<N and A[i]<A[j] and A[j]<A[k]: k+=1
    while k<N and A[i]>A[j] and A[j]>A[k]: k+=1
    ans+=1
    i=k
print(ans)

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

Expected output:
3


Actual output:
8


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))
i,j,ans=0,0,0
while i<N:
    j=i
    while j<N and A[j]==A[i]: j+=1
    k=j
    while k<N and A[i]<A[j] and A[k-1]<=A[k]: k+=1
    while k<N and A[i]>A[j] and A[k-1]>=A[k]: k+=1
    ans+=1
    i=k
print(ans)

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

count=1
flag=True
for i in range(n-1):
    if i==0:
        ans=a[i+1]-a[i]
    if not flag:
        ans=a[i+1]-a[i]
        flag=True
        continue

    if (ans<=0 and a[i+1]-a[i]<=0) or (ans>=0 and a[i+1]-a[i]>=0):
        ans=a[i+1]-a[i]
        continue

    else:
        count+=1
        flag=False

print(count)

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

Expected output:
3


Actual output:
2


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

count=1
flag=True
for i in range(n-1):
    if i==0:
        ans=a[i+1]-a[i]

    if not flag:
        ans=a[i+1]-a[i]
        flag=True

    if (ans<=0 and a[i+1]-a[i]<=0) or (ans>=0 and a[i+1]-a[i]>=0):
        if ans!=0:
            continue
        elif a[i+1]-a[i]!=0:
            ans=a[i+1]-a[i]
        else:
            continue
            


    else:
        count+=1
        flag=False

print(count)
Problem: p03745
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = lambda : sys.stdin.readline().rstrip()

n = int(input())
a = list(map(int, input().split()))
a_ = []
for i in a:
    if not a_:
        a_.append(i)
    elif i != a_[-1]:
        a_.append(i)
cnt = 0
flag = 0
if len(a_) == 1 or len(a_) == 2:
    print(1)
    sys.exit()
for i in range(n - 1):
    if flag == 0:
        if a[i + 1] - a[i] > 0:
            flag = 1
        else:
            flag = -1
        continue
    if flag == 1 and a[i + 1] - a[i] < 0:
        cnt += 1
        flag = 0
    elif flag == -1 and a[i + 1] - a[i] > 0:
        cnt += 1
        flag = 0
print(cnt + 1)

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

Expected output:
4


Actual output:
5


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

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

cnt = 0
flag = 0

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

Problem: p03745
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

import sys

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

if N <= 2:
    print(1)
    sys.exit(0)

count = 0
status = 0
for i in range(1,N):
    
    if A[i-1] == A[i]:
        new_status = 0
    if A[i-1] < A[i]:
        new_status = 1
    else:
        new_status = -1
    if status == 0:
        status = new_status
        continue
    if status == new_status:
        continue
    else:
        count += 1
        status = 0

print(count+1)


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

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):

import sys

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

if N <= 2:
    print(1)
    sys.exit(0)

count = 0
status = 0
for i in range(1,N):
    
    if A[i-1] == A[i]:
        new_status = 0
        continue
    elif A[i-1] < A[i]:
        new_status = 1
    elif A[i-1] > A[i]:
        new_status = -1
    if status == 0:
        status = new_status
        continue
    if status == new_status:
        continue
    else:
        count += 1
        
        status = 0

print(count+1)
Problem: p03745
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
aArray = [int(x) for x in input().split()]

incFrag = False
decFrag = False

ans = 1
for i in range(0,n - 1):
    if aArray[i + 1] > aArray[i]:
        if decFrag:
            ans += 1
            decFrag = False
        else:
            incFrag = True
    else:
        if incFrag:
            ans += 1
            incFrag = False
        else:
            decFrag = True
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())
aArray = [int(x) for x in input().split()]

incFrag = False
decFrag = False

ans = 1
for i in range(0, n - 1):
    if aArray[i + 1] > aArray[i]:
        if decFrag:
            ans += 1
            decFrag = False
        else:
            incFrag = True
    elif aArray[i + 1] < aArray[i]:
        if incFrag:
            ans += 1
            incFrag = False
        else:
            decFrag = True
print(ans)

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 == down:
        ret += 1
        up, down = False, False
print(ret)


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 = [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())
aa = list(map(int, input().split()))

if n==1:
    print(1)
else:
    mode = aa[0] < aa[1]
    ans = 1
    for i in range(n-1):
        if aa[i] != aa[i+1]:
            if (aa[i] < aa[i+1]) != mode:
                ans+=1
                mode = aa[i]<aa[i+1]
        
    print(ans)


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

Expected output:
4


Actual output:
5


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

if n==1:
    print(1)
else:
    mode = None
    ans = 1
    for i in range(n-1):
        if aa[i] != aa[i+1]:
            if mode == None:
                mode = aa[i]<aa[i+1]
            elif (aa[i] < aa[i+1]) != mode:
                ans+=1
                mode = None
        
    print(ans)
Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
if N == 1:
  print(1)
  exit()
A = [int(i) for i in input().split()]
ans = 1
if A[1] - A[0] > 0:
  pre = 1
elif A[1] - A[0] == 0:
  pre = 0
else:
  pre = -1

for i in range(2,N):
  if A[i] - A[i-1] > 0:
    now = 1
  elif A[i] - A[i-1] == 0:
    now = 0
  else:
    now = -1
  if now*pre < 0:
    ans += 1
    pre = 0
  else:
    pre = now
  
print(ans)
    

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

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
if N == 1:
  print(1)
  exit()
A = [int(i) for i in input().split()]
ans = 1
if A[1] - A[0] > 0:
  pre = 1
elif A[1] - A[0] == 0:
  pre = 0
else:
  pre = -1

for i in range(2,N):
  if A[i] - A[i-1] > 0:
    now = 1
  elif A[i] - A[i-1] == 0:
    now = pre
  else:
    now = -1
  if now*pre < 0:
    ans += 1
    pre = 0
  else:
    pre = now
  
print(ans)

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

ans = 0
flagu = 0
flagd = 0

for i in range(n):
	if i == 0:
		continue
	elif ls[i - 1] < ls[i] and flagu == 0:
		flagu = 1
	elif ls[i - 1] > ls[i] and  flagu == 1:
		ans += 1
		flagu = 0
		flagd = 0
	elif ls[i - 1] > ls[i] and flagd == 0:
		flagd = 1
	elif ls[i - 1] < ls[i] and flagd == 1:
		ans += 1
		flagu = 0
		flagd = 0
	
	if i == n - 1:
		ans += 1

print(ans)

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

Expected output:
3


Actual output:
2


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

ans = 0
flagu = 0
flagd = 0

for i in range(n):
	if i == 0:
		continue
	elif ls[i - 1] < ls[i]:
		if flagd == 1:
			ans += 1
			flagu = 0
			flagd = 0
		elif flagu == 0:
			flagu = 1
	elif ls[i - 1] > ls[i]:
		if flagu == 1:
			ans += 1
			flagu = 0
			flagd = 0
		elif flagd == 0:
			flagd = 1
	
	if i == n - 1:
		ans += 1

if n == 1:
	print(1)
else:
	print(ans)
Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

count = 0
ans = 1
bef = 0
buff = True
for i in A:
    if count == 0:
        count = 1
    elif count == 1:
        if bef < i:
            count += 1
        elif bef > i:
            count += 1
            buff = False
        else:
            pass
    else:
        if buff:
            if bef <= i:
                pass
            else:
                ans += 1
                count = 1
        else:
            if bef >= i:
                pass
            else:
                ans += 1
                count = 1
    bef = i
print(ans)


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

Expected output:
4


Actual output:
3


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

count = 0
ans = 1
bef = 0
buff = True
for i in A:
    if count == 0:
        count = 1
    elif count == 1:
        if bef < i:
            count += 1
            buff = True
        elif bef > i:
            count += 1
            buff = False
        else:
            pass
    else:
        if buff:
            if bef <= i:
                pass
            else:
                ans += 1
                count = 1
        else:
            if bef >= i:
                pass
            else:
                ans += 1
                count = 1
    bef = i
print(ans)

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



import sys

input_line = sys.stdin.readline()
n = int(input_line)
input_line = sys.stdin.readline()
a = [int(v) for v in input_line.split()]


i = 0
x = 1
diff = 0
bdiff = 1
border = False
for i in range(1, n):
	if border:
		border = False
		continue
	diff = a[i] - a[i - 1]
	if diff == 0:
		continue

	if diff * bdiff < 0:
		x += 1
		bdiff = diff
		border = True

if border:
	x += 1

print(str(x))


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

Expected output:
4


Actual output:
6


Fixed submission (verdict: Accepted):



import sys

input_line = sys.stdin.readline()
n = int(input_line)
input_line = sys.stdin.readline()
a = [int(v) for v in input_line.split()]

x = 1
bd = 0
skip = False
UP = 1
DOWN = -1
stat = 0
for i in range(1, n):
	diff = a[i] - a[i - 1]
	if diff == 0:
		continue

	if stat == 0:
		if diff > 0:
			stat = UP
		else :
			stat = DOWN

		continue

	if stat == UP and diff < 0:
		x += 1
		stat = 0
		continue

	if stat == DOWN and diff > 0:
		x += 1
		stat = 0

print(str(x))
Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))

d=False
u=False

cnt=0

for i in range(0,n-1):
  l=a[i];r=a[i+1]
  if l<r:u=True
  elif l>r:d=True
  else:pass  
  print((u,d))
  if u and d:
    cnt+=1
    u=False;d=False
print(cnt+1)
  

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

Expected output:
3


Actual output:
(True, False)
(True, True)
(True, False)
(True, False)
(True, False)
(True, False)
(True, True)
(False, False)
3


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

d=False
u=False

cnt=0

for i in range(0,n-1):
  l=a[i];r=a[i+1]
  if l<r:u=True
  elif l>r:d=True
    
  if u and d:
    cnt+=1
    u=False;d=False
print(cnt+1)

Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [int(i) for i in input().split()]

count = 1
state = 'none'
b = [a[0]]

for i in range(1,n):
    if state=='none':
        before=b.pop()
        now = a[i]
        if before<now:
            b.append(now)
            state='incr'
        elif before>now:
            b.append(now)
            state='decr'
        else:
            b.append(now)
    elif state=='incr':
        before=b.pop()
        now = a[i]
        if before<now:
            b.append(now)
        else:
            b=[now]
            state='none'
            count+=1
    elif state=='decr':
        before=b.pop()
        now = a[i]
        if before>now:
            b.append(now)
        else:
            b=[now]
            state='none'
            count+=1
print(count)

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

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(i) for i in input().split()]

count = 1
state = 'none'
b = [a[0]]

for i in range(1,n):
    if state=='none':
        before=b.pop()
        now = a[i]
        if before<now:
            b.append(now)
            state='incr'
        elif before>now:
            b.append(now)
            state='decr'
        else:
            b.append(now)
    elif state=='incr':
        before=b.pop()
        now = a[i]
        if before<=now:
            b.append(now)
        else:
            b=[now]
            state='none'
            count+=1
    elif state=='decr':
        before=b.pop()
        now = a[i]
        if before>=now:
            b.append(now)
        else:
            b=[now]
            state='none'
            count+=1
print(count)
Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin

def main():
	N = int(stdin.readline().strip())
	array = [int(x) for x in stdin.readline().strip().split()]
	ans,i= 0,0
	while i+1 < N:
		if array[i] < array[i+1]:
			ans+=1
			while i+1 < N and array[i] < array[i+1]:
				i+=1
			i+=1
		elif array[i] > array[i+1]:
			ans+=1
			while i+1 < N and array[i] > array[i+1]:
				i+=1
			i+=1
		else:
			i+=1
	if i+1 == N or ans == 0:
		ans+=1
	print(ans)
main()

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

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
from sys import stdin

def main():
	N = int(stdin.readline().strip())
	array = [int(x) for x in stdin.readline().strip().split()]
	ans,i= 0,0
	while i+1 < N:
		if array[i] < array[i+1]:
			ans+=1
			while i+1 < N and array[i] <= array[i+1]:
				i+=1
			i+=1
		elif array[i] > array[i+1]:
			ans+=1
			while i+1 < N and array[i] >= array[i+1]:
				i+=1
			i+=1
		else:
			i+=1
	if i+1 == N or ans == 0:
		ans+=1
	print(ans)
main()

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
    if n==1 or n==2:
        print(0)
    else:
        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
1 2 1 2 2 2 1 2 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())
a = list(map(int, input().split()))
ans = 1
m = 0
for i in range(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)

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

Expected output:
3


Actual output:
4


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):
n = int(input())
aa = list(map(int, input().split()))

if n==1:
    print(1)
else:
    mode = None
    ans = 1
    for i in range(n-1):
        if aa[i] != aa[i+1]:
            if mode == None:
                mode = aa[i]<aa[i+1]
            if (aa[i] < aa[i+1]) != mode:
                ans+=1
                if i<len(aa)-2:
                    mode = aa[+1]<aa[i+2]
        
    print(ans)


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

Expected output:
2


Actual output:
3


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

if n==1:
    print(1)
else:
    mode = None
    ans = 1
    for i in range(n-1):
        if aa[i] != aa[i+1]:
            if mode == None:
                mode = aa[i]<aa[i+1]
            elif (aa[i] < aa[i+1]) != mode:
                ans+=1
                mode = None
        
    print(ans)

Problem: p03745
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = input()
N =int(N)
nums= list(map(int,input().split(" ")))
ans = 1
tend = 0
before = nums[0]
for a in nums[1:]:
    if (before - a) * tend < 0:
        tend = 0
        ans += 1
    else:
        tend = 1 if before - a > 0  else -1 if before - a < 0 else 0

    before = a

print(ans)


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

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
N = input()
N =int(N)
nums= list(map(int,input().split(" ")))
ans = 1
tend = 0
before = nums[0]
for a in nums[1:]:
    if (before - a) * tend < 0:
        tend = 0
        ans += 1
    else:
        tend = 1 if before - a > 0  else -1 if before - a < 0 else tend

    before = a

print(ans)

Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
l = [int(x) for x in input().split()]

order = 0
subs = []
tmp = []

prev = 0
d = []
t = [l[0]]
for x in range(len(l)-1):
  a,b = l[x],l[x+1]
  c = a-b
  print(a,b,c, prev)
  if c == 0:
    t.append(b)
  elif prev == 0:
    t.append(b)
    prev = c
  elif (c < 0  and prev < 0) or (c > 0 and prev > 0):
    t.append(b)
  else:
    prev = 0
    d.append(t)
    t = [b]
d.append(t)


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

Expected output:
3


Actual output:
0 2 -2 0
2 3 -1 -2
3 -1 4 -2
-1 0 -1 0
0 -1 1 -1


Fixed submission (verdict: Accepted):
n = int(input())
l = [int(x) for x in input().split()]

order = 0
subs = []
tmp = []

prev = 0
d = []
t = [l[0]]
for x in range(len(l)-1):
  a,b = l[x],l[x+1]
  c = a-b
  
  if c == 0:
    t.append(b)
  elif prev == 0:
    t.append(b)
    prev = c
  elif (c < 0  and prev < 0) or (c > 0 and prev > 0):
    t.append(b)
  else:
    prev = 0
    d.append(t)
    t = [b]
d.append(t)

print(len(d))
Problem: p03745
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    i = 0
    while i < N:
        while i+1 < N and A[i] == A[i+1]:
            i += 1
        pos1, pos2 = i, i
        while pos1+1 < N and A[pos1] < A[pos1+1]:
            pos1 += 1
        while pos2+1 < N and A[pos2] > A[pos2+1]:
            pos2 += 1
        ans += 1
        i = max(pos1, pos2) + 1
    print(ans)


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):
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    i = 0
    while i < N:
        while i+1 < N and A[i] == A[i+1]:
            i += 1
        pos1, pos2 = i, i
        while pos1+1 < N and A[pos1] <= A[pos1+1]:
            pos1 += 1
        while pos2+1 < N and A[pos2] >= A[pos2+1]:
            pos2 += 1
        ans += 1
        i = max(pos1, pos2) + 1
    print(ans)


if __name__ == '__main__':
    main()

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

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

num_split = 1
diff = None
len_A_list = len(A_list)

for i in range(len_A_list-1):
    if diff == None:
        diff = A_list[i+1] - A_list[i]

    if A_list[i+1] - A_list[i] == diff:
        continue

    num_split += 1
    diff = None

print(num_split)


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

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
import math

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

num_split = 1
sign = None
len_A_list = len(A_list)

for i in range(len_A_list-1):
    if sign == None:
        if A_list[i+1] - A_list[i] == 0:
            continue
        sign = (A_list[i+1] - A_list[i]) / math.fabs(A_list[i+1] - A_list[i])

    if (A_list[i+1] - A_list[i]) *  sign >= 0:
        continue

    num_split += 1
    sign = None

print(num_split)

Problem: p03745
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input()); a = list(map(int, input().split())); b = -1; x = 1
for i in range(n-1):
    if b == 0:
        if a[i] > a[i+1]: b = -1; x += 1
    elif b == 1:
        if a[i] < a[i+1]: b = -1; x += 1
    else:
        b = 0 if a[i] < a[i+1] else 1
print(x)

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

Expected output:
2


Actual output:
3


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



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7


n = int(sys.stdin.readline())
a = list(map(int,sys.stdin.readline().split()))
ans = 1
x = 0
flg = 0
for i in range(n):
    if flg == 0:
        if x < a[i]:
            flg = 1
        elif x > a[i]:
            flg = -1
    if flg == 1:
        if x > a[i]:
            flg = 0
            ans += 1
        x = a[i]
    elif flg == -1:
        if x < a[i]:
            flg = 0
            ans += 1
        x = a[i]
print(ans)


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

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7


n = int(sys.stdin.readline())
a = list(map(int,sys.stdin.readline().split()))
ans = 1
x = a[0]
flg = 0
for i in range(1,n):
    if flg == 0:
        if x < a[i]:
            flg = 1
        elif x > a[i]:
            flg = -1
    if flg == 1:
        if x > a[i]:
            flg = 0
            ans += 1
    elif flg == -1:
        if x < a[i]:
            flg = 0
            ans += 1
    x = a[i]
print(ans)

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

count=0
flag=True
for i in range(n-1):
    if i==0:
        ans=a[i+1]-a[i]
    if not flag:
        ans=a[i+1]-a[i]
        flag=True

    if ans<=0 and a[i+1]-a[i]<=0 or ans>=0 and a[i+1]-a[i]>=0:
        continue

    else:
        if count==0:
            count+=1
        count+=1
        flag=False

print(count)

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

Expected output:
4


Actual output:
0


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

count=1
flag=True
for i in range(n-1):
    if i==0:
        ans=a[i+1]-a[i]

    if not flag:
        ans=a[i+1]-a[i]
        flag=True

    if (ans<=0 and a[i+1]-a[i]<=0) or (ans>=0 and a[i+1]-a[i]>=0):
        if ans!=0:
            continue
        elif a[i+1]-a[i]!=0:
            ans=a[i+1]-a[i]
        else:
            continue
            


    else:
        count+=1
        flag=False

print(count)
Problem: p03745
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

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


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

Expected output:
4


Actual output:
1


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

cnt = 0
flag = 0
for i in range(n - 1):
    if flag == 0:
        if a[i] < a[i + 1]:
            flag = 1
        elif a[i] > a[i + 1]:
            flag = -1
    elif flag == 1:
        if a[i] < a[i + 1]:
            flag = 1
        elif a[i] > a[i + 1]:
            flag = 0
            cnt += 1
    elif flag == -1:
        if a[i] > a[i + 1]:
            flag = -1
        if a[i] < a[i + 1]:
            flag = 0
            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()))

ans = 1

judge = 0
for i in range(n-1):
  if a[i] == a[i+1]:
    break
  elif a[i] < a[i+1]:
    if judge == -1:
      ans += 1
    else:
      judge = 1
  elif a[i] > a[i+1]:
    if judge == 1:
      ans += 1
    else:
      judge = 1      
print(ans)

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

Expected output:
3


Actual output:
1


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

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

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
  print(cut)
  return 0
 
if __name__ == "__main__":
  solve()

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

Expected output:
2


Actual output:
3


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 (Python (3.4.3), verdict: Wrong Answer):
N,*A=map(int,open(0).read().split());h=a=0
for i,j in zip(A,A[1:]):
 if(0<h<i)&(i>j)|(h>i)&(i<j):a+=1;h=0
 else:h=i
print(a+1)

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

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
N,*A=map(int,open(0).read().split());f=a=0
for i,j in zip(A,A[1:]):
 if f<0:
  if i<j:a+=1;f=0
 elif f<1:f=(i<j)-(i>j)
 else:
  if i>j:a+=1;f=0
print(a+1)

Problem: p03745
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
result = 1
if n > 2:
    h = a[0]<a[1]
    for i in range(n-1):
        if a[i]!=a[i+1]:
            c = a[i]<a[i+1]
            if h<0:
                h = c
            else:
                if h==c:
                    continue
                else:
                    h = -1
                    result += 1
print(result)


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()))
result = 1
if n > 2:
    h = -1
    for i in range(n-1):
        if a[i]!=a[i+1]:
            c = a[i]<a[i+1]
            if h<0:
                h = c
            else:
                if h==c:
                    continue
                else:
                    h = -1
                    result += 1
print(result)

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):
        if A[i] - A[i-1] == 0:
            l[i] = l[i-1]
        else:
            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:
6
0 2 3 -1 -1 0

Expected output:
2


Actual output:
3


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 (2.4.0), verdict: Wrong Answer):
import sys
input = lambda : sys.stdin.readline().rstrip()

n = int(input())
a = list(map(int, input().split()))
a_ = []

cnt = 0
flag = 0

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

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

Expected output:
4


Actual output:
5


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

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

cnt = 0
flag = 0

for i in range(n - 1):
    if flag == 0:
        if a[i + 1] - a[i] > 0:
            flag = 1
        elif a[i + 1] - a[i] < 0:
            flag = -1
    elif flag == 1 and a[i + 1] - a[i] < 0:
        cnt += 1
        flag = 0
    elif flag == -1 and a[i + 1] - a[i] > 0:
        cnt += 1
        flag = 0
print(cnt + 1)
Problem: p03590
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,k=map(int,input().split())
s=[tuple(map(int,input().split())) for _ in range(n)]
b=bin(k)[2:]
r=sum(b for a,b in s if k|a==k)
for i in range(len(b)-1):
    if b[i]=='0':
        continue
    p=int(b[:i]+'0'*(len(b)-i),2)
    q=int('1'*(len(b)-i-1),2)
    r=max(r,sum(b for a,b in s if a<=q or p<=a<=p+q))
print(r)

Failing test case input:
7 14
0 7
11 1
11 2
1 5
11 6
-1 1
3 -1

Expected output:
20


Actual output:
21


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
s=[tuple(map(int,input().split())) for _ in range(n)]
b=bin(k)[2:]
r=sum(b for a,b in s if k|a==k)
for i in range(len(b)-1):
    if b[i]=='0':
        continue
    l=int(b[:i]+'0'+'1'*(len(b)-i-1),2)
    r=max(r,sum(b for a,b in s if l|a==l))
print(r)

Problem: p03590
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def solve(K, ABs):
    if not ABs: return 0
    ansK = sum(b for a, b in ABs if (K | a) == K)
    pool = []
    for i in range(30, -1, -1):
        if (K & (1<<i)):
            pool.append(i)
    for p in pool:
        v = 1 << p
        KK = (K >> p) << p
        t = sum(b for a, b in ABs if (not(a & v) and a <= KK))
        if t > ansK: ansK = t
    return ansK
   

N, K = map(int, input().split())
ABs = []
for i in range(N):
    a, b = map(int, input().split())
    if a > K: continue
    ABs.append([a, b])

print(solve(K, ABs))

Failing test case input:
3 5
3 3
4 4
2 5

Expected output:
8

Actual output:
9


Fixed submission (verdict: Accepted):
def solve(K, ABs):
    if not ABs: return 0
    ansK = sum(b for a, b in ABs if (K | a) == K)
    pool = []
    for i in range(30, -1, -1):
        if (K & (1<<i)):
            pool.append(i)
    for p in pool:
        v = 1 << p
        KK = (K >> p) << p
        KKK = (K >> p)
        t = sum(b for a, b in ABs if (not(a & v) and (a | KK) >> p == KKK))
        if t > ansK: ansK = t
    return ansK
   

N, K = map(int, input().split())
ABs = []
for i in range(N):
    a, b = map(int, input().split())
    if a > K: continue
    ABs.append([a, b])

print(solve(K, ABs))

Problem: p03590
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,k=map(int,input().split())
s=[tuple(map(int,input().split())) for _ in range(n)]
b=bin(k)[2:]
r=sum(b for a,b in s if k|a==k)
for i in range(len(b)-1):
    if b[0]=='0':
        continue
    p=int(b[:i]+'0'*(len(b)-i),2)
    q=int('1'*(len(b)-i-1),2)
    r=max(r,sum(b for a,b in s if a<=q or p<=a<=p+q))
print(r)

Failing test case input:
7 14
0 7
11 1
11 3
1 5
11 6
-1 1
3 -1

Expected output:
21


Actual output:
22


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
s=[tuple(map(int,input().split())) for _ in range(n)]
b=bin(k)[2:]
r=sum(b for a,b in s if k|a==k)
for i in range(len(b)-1):
    if b[i]=='0':
        continue
    l=int(b[:i]+'0'+'1'*(len(b)-i-1),2)
    r=max(r,sum(b for a,b in s if l|a==l))
print(r)
Problem: p03590
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def solve(K, ABs):
    ansK = sum(b for a, b in ABs if (K | b) == K)
    pool = []
    for i in range(30, 0, -1):
        if (K & (1<<i)):
            pool.append(i)
        else:
            if pool:
                break
    for p in pool:
        v = 1 << p
        t = sum(b for a, b in ABs if not(a & v))
        if t > ansK: ansK = t
    return ansK
   

N, K = map(int, input().split())
ABs = []
for i in range(N):
    a, b = map(int, input().split())
    if a > K: continue
    ABs.append([a, b])

print(solve(K, ABs))

Failing test case input:
7 14
10 5
7 4
11 4
9 8
3 6
6 2
8 0

Expected output:
23


Actual output:
24


Fixed submission (verdict: Accepted):
def solve(K, ABs):
    if not ABs: return 0
    ansK = sum(b for a, b in ABs if (K | a) == K)
    pool = []
    for i in range(30, -1, -1):
        if (K & (1<<i)):
            pool.append(i)
    for p in pool:
        v = 1 << p
        KK = (K >> p) << p
        KKK = (K >> p)
        t = sum(b for a, b in ABs if (not(a & v) and (a | KK) >> p == KKK))
        if t > ansK: ansK = t
    return ansK
   

N, K = map(int, input().split())
ABs = []
for i in range(N):
    a, b = map(int, input().split())
    if a > K: continue
    ABs.append([a, b])

print(solve(K, ABs))

Problem: p03590
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
readline=sys.stdin.readline
read=sys.stdin.read

def main():
    n,k=map(int,readline().split())
    ab=[list(map(int,l.split())) for l in read().splitlines()]
    
    ek=0
    while k>>ek:
        ek+=1

    cand=[]
    m=(1<<ek)-1
    ms=m>>1
    for i in range(ek):
        m0=((m>>i)|k)&(m-(1<<(ek-i-1)))
        cand.append(sum([e[1] for e in ab if e[0]|m0==m0]))
    cand.append(sum([e[1] for e in ab if e[0]|k==k]))
    print(max(cand))

if __name__=='__main__':
    main()


Failing test case input:
7 20
-1 -1
1 0
35 2
1 10
4 6
-1 0
3 -1

Expected output:
15


Actual output:
16


Fixed submission (verdict: Accepted):
import sys
readline=sys.stdin.readline
read=sys.stdin.read

def main():
    n,k=map(int,readline().split())
    ab=[list(map(int,l.split())) for l in read().splitlines()]
    
    ek=0
    while k>>ek:
        ek+=1

    cand=[]
    for i in range(ek):
        if k>>i&1:
            m=(k>>(i+1))<<(i+1)|((1<<i)-1)
            cand.append(sum([e[1] for e in ab if e[0]|m==m]))
    cand.append(sum([e[1] for e in ab if e[0]|k==k]))
    print(max(cand))

if __name__=='__main__':
    main()
Problem: p02984
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a=[]
a=list(map(int, input().split()))

m=[0]*n

for i in range(n):
  if i%2 == 0:
    m[0]+=a[i]
  else:
    m[0]-=a[i]
for i in range(1,n):
  m[i] =(a[i-1]-m[i-1]/2)*2
  
for i in range(n):
  print(m[i],end=" ")
  

Failing test case input:
3
1001001100 1011101000 0

Expected output:
-10099900 2012102100 10099900


Actual output:
-10099900 2012102100.0 10099900.0 

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

m=[0]*n

for i in range(n):
  if i%2 == 0:
    m[0]+=a[i]
  else:
    m[0]-=a[i]
for i in range(1,n):
  m[i] =(a[i-1]-m[i-1]/2)*2
  
for i in range(n):
  print(int(m[i]),end=" ")

Problem: p02984
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
a = list(map(int,input().split()))
h = [0]*N
for i in range(N):
  if i%2==0:
    h[0] = h[0] + a[i]
  else:
    h[0] = h[0] - a[i]
for i in range(N-1):
  h[i+1] = 2*(a[i]-h[i])
print(*h)

Failing test case input:
5
3 8 7 5 5

Expected output:
2 4 12 2 8

Actual output:
2 2 12 -10 30


Fixed submission (verdict: Accepted):
N=int(input())
a = list(map(int,input().split()))
h = [0]*N
for i in range(N):
  if i%2==0:
    h[0] = h[0] + a[i]
  else:
    h[0] = h[0] - a[i]
for i in range(N-1):
  h[i+1] = 2*a[i]-h[i]
print(*h)

Problem: p02984
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
waters = list(map(int, input().split()))
ans = []
x = sum(waters) - sum([waters[i] for i in range(1, N-1, 2)])*2
ans.append(x)
for i in range(N-1):
    ans.append(waters[i] * 2 - x)
    x = ans[-1]
print(ans)

Failing test case input:
3
1000010010 1010000000 0

Expected output:
-9989990 2010010010 9989990


Actual output:
[-9989990, 2010010010, 9989990]


Fixed submission (verdict: Accepted):
N = int(input())
waters = list(map(int, input().split()))
ans = []
x = sum(waters) - sum([waters[i] for i in range(1, N-1, 2)])*2
ans.append(x)
for i in range(N-1):
    ans.append(waters[i] * 2 - x)
    x = ans[-1]
output = [str(num) for num in ans]
print(' '.join(output))

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

x1 = sum(A) - 2 * sum([A[i] for i in range(1,N,2)])
x = [x1]

for i in range(1,N):
    xi = 2 * A[i - 1] - x[i - 1]
    x.append(xi)

print(x)

Failing test case input:
3
1011001000 1011111100 0

Expected output:
-110100 2022112100 110100


Actual output:
[-110100, 2022112100, 110100]


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

x1 = sum(A) - 2 * sum([A[i] for i in range(1,N,2)])
x = [x1]

for i in range(1,N):
    xi = 2 * A[i - 1] - x[i - 1]
    x.append(xi)

print(*x)
Problem: p02984
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n = int(input())
a = list(map(int, input().split()))
ans = [0]*n
ans[0] = sum(a)-(2*(sum(a)-a[0]-a[-1]))
for i in range(1,len(a)):
    ans[i] = 2*a[i-1] -ans[i-1]
ans=[str(a) for a in ans]
ans=" ".join(ans)
print(ans)

Failing test case input:
5
3 8 1 5 5

Expected output:
-4 10 6 -4 14


Actual output:
-6 12 4 -2 12


Fixed submission (verdict: Accepted):

n = int(input())
a = list(map(int, input().split()))
ans = [0]*n

d_sum = sum(a[1:-1:2])

ans[0] = sum(a)-(2*d_sum)

for i in range(1,len(a)):
    ans[i] = 2*a[i-1] -ans[i-1]

ans=[str(a) for a in ans]
ans=" ".join(ans)
print(ans)

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

x_0 = 0

for i in range(N):
    if (i % 2) == 0:
        x_0 += List[i]
    else:
        x_0 -= List[i]

result_x = []
result_x.append(x_0)

for j in range(N-1):
    result_x.append(int((List[j] - (result_x[j])/2) *2))

print(result_x)

Failing test case input:
3
1010011000 1001111100 0

Expected output:
8899900 2011122100 -8899900


Actual output:
[8899900, 2011122100, -8899900]


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

x_0 = 0

for i in range(N):
    if (i % 2) == 0:
        x_0 += List[i]
    else:
        x_0 -= List[i]

result_x = []
result_x.append(x_0)

for j in range(N-1):
    result_x.append(int((List[j] - (result_x[j])/2) *2))

print(*result_x)

Problem: p02984
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
A_list = [int(i) for i in input().split()]
M_list = []

M_list.append(sum(A_list)-sum(A_list[::2])) 
print(M_list[0])

for i in range (N):
         M_list.append(2 * A_list[i] - M_list[i])


print(*M_list)

Failing test case input:
3
1000001100 1010101000 0

Expected output:
-10099900 2010102100 10099900


Actual output:
1010101000
1010101000 989901200 1030300800 -1030300800


Fixed submission (verdict: Accepted):
N = int(input())
A_list = [int(i) for i in input().split()]
M_list = []

M_list.append(sum(A_list)- 2 * sum(A_list[1::2])) 


for i in range (0,N-1):
         M_list.append(2 * A_list[i] - M_list[i])


print(*M_list)

Problem: p02984
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
temp=input().split()
A=[int(temp[i]) for i in range(N)]

x1=sum([pow(-1, k)*A[k] for k in range(N)])/2
for i in range(1, N):
  
  print(sum([pow(-1, k-i)*A[k] for k in range(i, N)])-pow(-1, i)*x1, end=' ')


Failing test case input:
3
1010100100 1011101000 0

Expected output:
-1000900 2021201100 1000900


Actual output:
1010600550.0 500450.0 

Fixed submission (verdict: Accepted):
N=int(input())
temp=input().split()
A=[int(temp[i]) for i in range(N)]
As=[]
As.append(sum([A[i]*pow(-1, i) for i in range(N)]))
for i in range(1, N):
  As.append(A[i-1]-As[i-1])

x1=As[0]/2
print(int(2*x1), end=' ')

for i in range(1, N):
  print(2*int(As[i]-x1*pow(-1, i)), end=' ')
Problem: p02984
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))




X1 = sum(A) - 2 * sum([A[i] for i in range(1,N,2)])
ans = [X1]


for n in range(1,N,1):
  _ = 2 * A[n-1] - ans[n-1]
  ans.append(_)


print(ans)

Failing test case input:
3
1010000000 1010000000 0

Expected output:
0 2020000000 0


Actual output:
[0, 2020000000, 0]


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




X1 = sum(A) - 2 * sum([A[i] for i in range(1,N,2)])
ans = [X1]


for n in range(1,N,1):
  _ = 2 * A[n-1] - ans[n-1]
  ans.append(_)


print(*ans)

Problem: p02984
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)
a2 = 0
for i in range(1, n):
    a2 += a[i]

ans = [0] * n
ans[0] = sum_a - 2*a2
for i in range(1, n, 2):
    ans[i] = 2*a[i-1] - ans[i-1]
print(*ans)

Failing test case input:
3
1011001000 1011111000 0

Expected output:
-110000 2022112000 110000


Actual output:
-110000 2022112000 0


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)
a2 = 0
for i in range(1, n, 2):
    a2 += a[i]

ans = [0] * n
ans[0] = sum_a - 2*a2
for i in range(1, n):
    ans[i] = 2*a[i-1] - ans[i-1]
print(*ans)

Problem: p02984
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
temp=input().split()
A=[int(temp[i]) for i in range(N)]

x1=sum([pow(-1, i)*A[i] for i in range(N)])/2
print(2*x1, end=' ')

for i in range(1, N):
  print(int(2*(sum([pow(-1, k-i)*A[k] for k in range(i, N)])-pow(-1, i)*x1)), end=' ')

Failing test case input:
3
1000000000 0000100000 0

Expected output:
999900000 1000100000 -999900000


Actual output:
999900000.0 1000100000 -999900000 

Fixed submission (verdict: Accepted):
N=int(input())
temp=input().split()
A=[int(temp[i]) for i in range(N)]
As=[]
As.append(sum([A[i]*pow(-1, i) for i in range(N)]))
for i in range(1, N):
  As.append(A[i-1]-As[i-1])

x1=As[0]/2
print(int(2*x1), end=' ')

for i in range(1, N):
  print(2*int(As[i]-x1*pow(-1, i)), end=' ')

Problem: p02984
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = input().split()
A = [int(n) for n in A]
print(A)
S = sum(A)
print(S)
X1 = S
result = []
for i in range(1,N-1,2):
    X1 -= 2*A[i]

result.append(X1)

for i in range(N-1):
    result.append(2*A[i]-result[i])

print(result)

Failing test case input:
3
1000000000 0000001000 0

Expected output:
999999000 1000001000 -999999000


Actual output:
[1000000000, 1000, 0]
1000001000
[999999000, 1000001000, -999999000]


Fixed submission (verdict: Accepted):
N = int(input())
A = input().split()
A = [int(n) for n in A]
S = sum(A)
X1 = S
result = []
for i in range(1,N-1,2):
    X1 -= 2*A[i]

result.append(X1)
text = str(X1)

for i in range(N-1):
    result.append(2*A[i]-result[i])
    text += " " + str(result[i+1])

print(text)