ZhenlongDai/ACPR huggingface dataset:
Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = 0
    for i in range(len(A) - 1):
        if 0 == A[i] and 0 > A[i + 1]:
            A[i + 1] *= -1
            continue
        if 0 > A[i]:
            A[i] *= -1
            A[i + 1] *= -1
        B += A[i]
    print(B + A[-1])


main()


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

Expected output:
12


Actual output:
4


Fixed submission (verdict: Accepted):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    c = 0
    for a in A:
        if 0 > a:
            c += 1
    ans = 0
    absA = [abs(a) for a in A]
    if c % 2 == 0:
        ans = sum(absA)
    else:
        ans = sum(absA) - 2 * min(absA)
    print(ans)
    

main()

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

negCount = 0


sum = 0


min = 0
if A[0] < 0:
    min = A[0] * -1
else:
    min = A[0]

for i in A:
    
    if i < 0:
        negCount += 1
        i *= -1

    sum += i

    if i < min:
        min = i

print(min)

if negCount % 2 == 0:
    print(sum)
    
else:
    print(sum - (min*2))

    


Failing test case input:
11
-29003401 1000100000 -8674852 1101000010 -856410392 0 1010010110 -493324020 1000000011 -485738863 1010000110

Expected output:
6994261769


Actual output:
0
6994261769


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

negCount = 0


sum = 0


min = 0
if A[0] < 0:
    min = A[0] * -1
else:
    min = A[0]

for i in A:
    
    if i < 0:
        negCount += 1
        i *= -1

    sum += i

    if i < min:
        min = i

if negCount % 2 == 0:
    print(sum)
    
else:
    print(sum - (min*2))

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
m = 10**9
cn = 0
s = 0
for x in input().split():
    y = int(x)
    z = abs(y)
    if y < 0:
        cn += 1
        print("cn+=1",y,cn)
    s += z
    print("sum:",s)
    if m > z:
        m = z
        print("m:updated",m)
if cn%2 == 0:
    print(s)
else:
    print(s - m*2)

Failing test case input:
3
-6 0 -1

Expected output:
7


Actual output:
cn+=1 -6 1
sum: 6
m:updated 6
sum: 6
m:updated 0
cn+=1 -1 2
sum: 7
7


Fixed submission (verdict: Accepted):
n = int(input())
m = 10**9
cn = 0
s = 0
for x in input().split():
    y = int(x)
    z = abs(y)
    if y < 0:
        cn += 1
    s += z
    if m > z:
        m = z
if cn%2 == 0:
    print(s)
else:
    print(s - m*2)

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
c=0
k=0
for i in range(0,n):
  if a[i]<0:
    c=c+a[i]
  k=k+abs(a[i])
  a[i]=abs(a[i])
a.sort()
if c%2==1:
  k=k-a[0]
  print(k)
else:
  print(k)

Failing test case input:
5
10 -4 -8 -11 3

Expected output:
30

Actual output:
33


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
c=0
k=0
for i in range(0,n):
  if a[i]<0:
    c=c+1
  k=k+abs(a[i])
  a[i]=abs(a[i])
a.sort()
if c%2==1:
  k=k-2*a[0]
  print(k)
else:
  print(k)
Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(abs,list(map(int, input().split()))))

a.sort()
if n % 2 == 0:
    ans = sum(a)
else:
    ans = sum(a) - (a[0]*2)
print(ans)

Failing test case input:
3
-10 5 -4

Expected output:
19

Actual output:
11


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

num = 0
for i in range(n):
    if a[i] < 0:
        num = num + 1
if num % 2 == 0:
    ans = sum(b)
else:
    ans = sum(b) - (b[0]*2)
print(ans)

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

def main():
    _ = input()
    A = list(map(int, input().split()))
    A_list = []
    count = 0
    for a in A:
        if a < 0:
            count += 1
            A_list.append(a * -1)
        else:
            A_list.append(a)
    if count % 2 == 0:
        print(sum(A_list))
    else:
        print(sum(A_list))
        print(min(A_list))
        print(sum(A_list)-min(A_list) * 2)


if __name__ == "__main__":
    main()


Failing test case input:
11
-503952896 1000010000 -425259316 1000001000 -2255404057 0 1010010001 -474477572 1000100011 -252067600 1100000100

Expected output:
9021282553


Actual output:
9021282553
0
9021282553


Fixed submission (verdict: Accepted):

def main():
    _ = input()
    A = list(map(int, input().split()))
    A_list = []
    count = 0
    for a in A:
        if a < 0:
            count += 1
            A_list.append(a * -1)
        else:
            A_list.append(a)
    if count % 2 == 0:
        print(sum(A_list))
    else:
        print(sum(A_list)-min(A_list) * 2)


if __name__ == "__main__":
    main()

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())

A=[int(i) for i in input().split()]

flg=1
for num in A:
    if num < 0:
        flg*(-1)
        
B=[abs(i) for i in A]

if flg==1:
    print(sum(B))
else:
    print(sum(B)-2*sorted(B)[0])

Failing test case input:
5
15 -4 -4 -28 5

Expected output:
48


Actual output:
56


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

A=[int(i) for i in input().split()]

flg=1
for num in A:
    if num < 0:
        flg*=(-1)
        
B=[abs(i) for i in A]

if flg==1:
    print(sum(B))
else:
    print(sum(B)-2*sorted(B)[0])
Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
neg_num = 0
min_abs_a = -float('inf')
sum_abs_A = 0
include_zero = False
for a in A:
  sum_abs_A += abs(a)
  if a == 0: include_zero = True
  if a < 0 :
    neg_num += 0
    min_abs_a = min(abs(a),min_abs_a)
print(sum_abs_A if neg_num%2==0 or include_zero is True else sum_abs_A - 2*min_abs_a)

Failing test case input:
5
10 -4 -4 -11 5

Expected output:
26


Actual output:
34


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
neg_num = 0
min_abs_a = float('inf')
sum_abs_A = 0
include_zero = False
for a in A:
  sum_abs_A += abs(a)
  min_abs_a = min(abs(a),min_abs_a)
  if a == 0: include_zero = True
  if a < 0 : neg_num += 1
print(sum_abs_A if neg_num%2==0 or include_zero is True else sum_abs_A - 2*min_abs_a)

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
  print(sum(map(abs, a)))
  exit()
minus = len([i for i in range(n) if a[i]<0 ])
if minus % 2 == 0:
  print(print(sum(map(abs, a))))
else:
  a = sorted(a, key=lambda x: abs(x))
  print(sum(map(abs, a[1:])))

Failing test case input:
5
3 -4 -4 -28 5

Expected output:
38


Actual output:
41


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
  print(sum(map(abs, a)))
  exit()
minus = len([i for i in range(n) if a[i]<0 ])
if minus % 2 == 0:
  print(sum(map(abs, a)))
else:
  a = sorted(a, key=lambda x: abs(x))
  print(sum(map(abs, a[1:]))-abs(a[0]))

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
input()
a = list(map(int, input().split()))
cnt = sum([i < 0 for i in a])
s = [abs(i) for i in a]
print(cnt)
if cnt % 2 == 0:
    print(sum(s))
else:
    print(sum(s) - min(s) * 2)

Failing test case input:
11
-1000000000 1000000000 -364513171 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000

Expected output:
9364513171


Actual output:
5
9364513171


Fixed submission (verdict: Accepted):
input()
a = list(map(int, input().split()))
cnt = sum([i < 0 for i in a])
s = [abs(i) for i in a]
if cnt % 2 == 0:
    print(sum(s))
else:
    print(sum(s) - min(s) * 2)

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
num = list(map(int,input().split()))
numabs = [abs(i) for i in num]
cnt = 0    
negative = []        
for i in num :
    if i < 0 :
        cnt += 1
        negative.append(i)

if cnt % 2 == 0 or num.count(0) >= 1 :
    print(sum(numabs))

if cnt % 2 == 1 and num.count(0) == 0 :
    print(sum(numabs)+2*max(negative))

Failing test case input:
3
-14 5 1

Expected output:
18


Actual output:
-8


Fixed submission (verdict: Accepted):
n = int(input())
num = list(map(int,input().split()))
numabs = [abs(i) for i in num]
cnt = 0           
for i in num :
    if i < 0 :
        cnt += 1

if cnt % 2 == 0 :
    print(sum(numabs))

if cnt % 2 == 1 :
    print(sum(numabs) - 2*min(numabs))
Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))

minus = 0
plus_min = 1000000000
total = 0

for j in range(N):
    if A[j] >= 0:
        plus_min = min(A[j],plus_min)
    else:
        minus += 1

    total += abs(A[j])

if minus % 2 == 0:
    print(total)
else:
    print(total-2*plus_min)

Failing test case input:
5
2 -1 -4 -1 7

Expected output:
13


Actual output:
11


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

minus = 0
plus_min = 1000000000
minus_max = -1000000000
total = 0

for j in range(N):
    if A[j] >= 0:
        plus_min = min(A[j],plus_min)
    else:
        minus_max = max(A[j],minus_max)
        minus += 1

    total += abs(A[j])

if minus % 2 == 0:
    print(total)
else:
    print(total-2*min(abs(minus_max),plus_min))

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
  print(sum(map(abs, a)))
  exit()
minus = len([i for i in range(n) if a[i]<0 ])
if minus % 2 == 0:
  print(sum(map(abs, a)))
else:
  a = sorted(a, key=lambda x: abs(x))
  print(sum(map(abs, a[1:]))-a[0])


Failing test case input:
5
2 -2 -4 -1 7

Expected output:
14


Actual output:
16


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
  print(sum(map(abs, a)))
  exit()
minus = len([i for i in range(n) if a[i]<0 ])
if minus % 2 == 0:
  print(sum(map(abs, a)))
else:
  a = sorted(a, key=lambda x: abs(x))
  print(sum(map(abs, a[1:]))-abs(a[0]))

Problem: p03062
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
sm=sum(map(abs,a))
f=1
for i in range(n-1):
  f= 1 if a[i]*f>=0 else -1
print (sm if f*a[n-1]>0 else sm-2*min(abs(a[n-1]),abs(a[n-2])) )
       
 
  
  


Failing test case input:
5
3 -4 -1 -28 5

Expected output:
39


Actual output:
31


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
sm=sum(map(abs,a))
f=1

for i in range(n-1):
  f= 1 if a[i]*f>=0 else -1
print (sm if f*a[n-1]>0  or 0 in a else sm-2*min(map(abs,a)))

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
l = list(map(int, input().split()))
m = 0
low = l[0]
s = 0
for i in range(n):
  if l[i] < 0:
    l[i] = abs(l[i])
    m += 1
  if low > l[i]:
    low = l[i]
  s += l[i]
if m%2:
  s -= low*2
print(s)

Failing test case input:
11
-1000000000 1000010000 -295190852 1000000000 -1382285407 0 1000010000 -1000000000 1000000001 -162702447 1000000100

Expected output:
8840198807


Actual output:
10840198807


Fixed submission (verdict: Accepted):
n = int(input())
l = list(map(int, input().split()))
m = 0
low = abs(l[0])
s = 0
for i in range(n):
  if l[i] < 0:
    l[i] = abs(l[i])
    m += 1
  if low > l[i]:
    low = l[i]
  s += l[i]
if m%2:
  s -= low*2
print(s)
Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


N = int(input())
A = [int(x) for x in input().split()]



for i in range(N-1):
    if A[i] < 0:
        A[i] *= -1
        A[i+1] *= -1
    
tmp = []
for i in reversed(range(0, N-1)):
    A[i] *= -1
    A[i+1] *= -1
    tmp.append(sum(A))
    
print(max(tmp))

Failing test case input:
3
-14 5 1

Expected output:
18


Actual output:
10


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

abs_list = sorted([abs(x) for x in A])[::-1]

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

if abs(min(A)) != min(abs_list):
    A[A.index(min(A))] *= -1
    A[A.index(min(abs_list))] *= -1
    
print(sum(A))

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
nums = list(map(int,input().split()))
cnt = 0
for num in nums:
  if num < 0:
    cnt += 1
    
abnums = [abs(i) for i in nums]
if cnt % 2 == 0:
  ans = sum(abnums)
else:
  ans = sum(nums) - min(abnums)*2
print(ans)

Failing test case input:
11
-16874157 1000110000 -164217899 1001000010 -856410392 0 1010010010 -239123828 1000000010 -337457434 1010000110

Expected output:
6635203850


Actual output:
3407036430


Fixed submission (verdict: Accepted):

n = int(input())
nums = list(map(int,input().split()))
cnt = 0
for num in nums:
  if num < 0:
    cnt += 1
    
abnums = [abs(i) for i in nums]
if cnt % 2 == 0:
  ans = sum(abnums)
else:
  ans = sum(abnums) - min(abnums)*2
print(ans)

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
absmin = 0
minnum = 0
for i in range(n):
  if abs(a[i]) < abs(a[absmin]):
    i = absmin
  if a[i] <= 0:
    minnum += 1
  a[i] = abs(a[i])
if minnum % 2 == 1:
  a[absmin] = -1 * abs(a[absmin])
ans = 0
for i in range(n):
  ans += a[i]
print(ans)

Failing test case input:
11
-29003401 1000100000 -8674852 1101000010 -856410392 0 1010010110 -493324020 1000000011 -485738863 1010000110

Expected output:
6994261769


Actual output:
6976912065


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
absmin = 0
minnum = 0
for i in range(n):
  if abs(a[i]) < abs(a[absmin]):
    absmin = i
  if a[i] <= 0:
    minnum += 1
  a[i] = abs(a[i])
if minnum % 2 == 1:
  a[absmin] = -1 * abs(a[absmin])
ans = 0
for i in range(n):
  ans += a[i]
print(ans)
Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = map(int, input().split())
plus_count = 0
total = 0
minus_max = -999999999999999999

for a in A:
	total += abs(a)
	if a >= 0:
		plus_count += 1
	if a <= 0: 
		if minus_max < a:
			minus_max = a
			
if plus_count % 2 == 0 or plus_count == N:
	print(total)
else:
	print(total + 2 * minus_max)

Failing test case input:
5
3 -1 -4 -1 16

Expected output:
23


Actual output:
25


Fixed submission (verdict: Accepted):
N = int(input())
A = map(int, input().split())
minus_count = 0
total = 0
minimum = 999999999999999999

for a in A:
	total += abs(a)
	if abs(a) < minimum:
		minimum = abs(a)
	if a < 0:
		minus_count += 1
			
if minus_count % 2 == 0:
	print(total)
else:
	print(total - 2 * minimum)

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x = int(input())
y = list(map(int, input().split(" ")))

for i in range(x - 1):
  if y[i] < 0:
    y[i] = y[i] * -1
    y[i + 1] = y[i + 1] * -1
    
print(sum(y))

Failing test case input:
5
5 -1 -1 -28 2

Expected output:
35


Actual output:
33


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

for i in range(x - 1):
  if y[i] < 0:
    y[i] *=-1
    y[i + 1] *=-1

if y[-1] < 0 and abs(min(y[0:-1])) < abs(y[-1]) :
  y[-1] *= -1
  y[y.index(min(y[0:-1]))] *= -1

print(sum(y))

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(abs, map(int, input().split())))
print(sum(a) if len([i for i in a if i < 0]) % 2 == 0 else sum(a) - 2 * min(a))

Failing test case input:
3
-1 5 1

Expected output:
5


Actual output:
7


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
abs_a = list(map(abs, a))
print(sum(abs_a) if len([i for i in a if i < 0]) % 2 == 0 else sum(abs_a) - 2 * min(abs_a))

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

cnt=0
S=0
mi=10000000000
C0=False

for i in range(N):
    mi=min(mi,abs(A[i]))
    if A[i]>0:
        S+=A[i]
    elif A[i]==0:
        C0==True
    elif A[i]<0:
        cnt+=1
        S+=(-A[i])

if cnt%2==0 or C0==True:
    print(S)
else:
    print(S-mi)


Failing test case input:
3
-2 5 1

Expected output:
6


Actual output:
7


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

cnt=0
S=0
mi=10000000000
C0=False

for i in range(N):
    mi=min(mi,abs(A[i]))
    if A[i]>0:
        S+=A[i]
    elif A[i]==0:
        C0==True
    elif A[i]<0:
        cnt+=1
        S+=(-A[i])

if cnt%2==0 or C0==True:
    print(S)
else:
    print(S-mi*2)
Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()
c=0
for i in a:
    if i < 0:
        c+=1

b = [abs(i) for i in a]

if c%2 == 0:
    print(b)
    exit()

b.sort()
print(sum(b)-2*b[0])

Failing test case input:
5
6 0 -3 -10 6

Expected output:
25


Actual output:
[6, 0, 3, 10, 6]


Fixed submission (verdict: Accepted):
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()
c=0
for i in a:
    if i < 0:
        c+=1

b = [abs(i) for i in a]

if c%2 == 0:
    print(sum(b))
    exit()

b.sort()
print(sum(b)-2*b[0])

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
if abs(a[0])>abs(a[n-1]):
  for i in range(n-1):
    if a[i]<0:
      a[i]*=-1
      a[i+1]*=-1
  print(sum(a))
else:
  for i in range(n-1,0,-1):
    if a[i]<0:
      a[i]*=-1
      a[i-1]*=-1
  print(sum(a))

Failing test case input:
11
-503952896 1000110000 -393529007 1001000000 -2255404057 0 1010010001 -474477572 1000100011 -415342299 1100000100

Expected output:
9153925943


Actual output:
8146020151


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
count=0
flag=1
num=10*9+1
for i in range(n):
  if a[i]<0:
    count+=1
    a[i]*=-1
  elif a[i]==0:
    flag=0
if count%2==0 or flag==0:
  print(sum(a))
else:
  print(sum(a)-2*min(a))

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
line = [int(a) for a in input().split()]
if 0 in line:
  line = [abs(a) for a in line]
  print(sum(line))
else:
  b = [i for i in line if i<0]
  if len(b)%2==0:
    line = [abs(a) for a in line]
    ans = sum(line)
    print(ans)
  else:
  	b.sort()
  	line = [abs(a) for a in line]
  	ans = sum(line)+2*b[-1]
  	print(ans)

Failing test case input:
3
-14 5 1

Expected output:
18


Actual output:
-8


Fixed submission (verdict: Accepted):
N = int(input())
line = [int(a) for a in input().split()]
if 0 in line:
  line = [abs(a) for a in line]
  print(sum(line))
else:
  b = [i for i in line if i<0]
  if len(b)%2==0:
    line = [abs(a) for a in line]
    ans = sum(line)
    print(ans)
  else:
    line = [abs(a) for a in line]
    line.sort()
    ans = sum(line)-2*line[0]
    print(ans)

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=[int(i) for i in input().split()]
ans=None
a_pos=[abs(i) for i in a]
a_min=min(a_pos)
if n%2==0:
    ans=sum(a_pos)
else: ans=sum(a_pos)-2*a_min

print(ans)

Failing test case input:
3
-2 1 -1

Expected output:
4


Actual output:
2


Fixed submission (verdict: Accepted):
n=int(input())
a=[int(i) for i in input().split()]
ans=None
a_pos=[abs(i) for i in a]
a_min=min(a_pos)
a_neg=sum([1 if i<0 else 0 for i in a])
if a_neg%2==0:
    ans=sum(a_pos)
else: ans=sum(a_pos)-2*a_min
print(ans)
Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin

N = int(stdin.readline().rstrip())
data = stdin.readline().rstrip().split()

abs_sum = 0
negative_elements = []
zero_exist = False

for number in data:
    num = int(number)
    abs_sum += abs(num)
    if num == 0:
        zero_exist = True
    elif num < 0:
        negative_elements.append(int(num))

if len(negative_elements) % 2 == 0 or zero_exist:
    print(abs_sum)
else:
    print(abs_sum - 2 * min(negative_elements))

Failing test case input:
5
15 -4 -4 -28 5

Expected output:
48


Actual output:
112


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

N = int(stdin.readline().rstrip())
data = stdin.readline().rstrip().split()

abs_sum = 0
negative_elements = []
zero_exist = False

for number in data:
    num = int(number)
    abs_sum += abs(num)
    if num == 0:
        zero_exist = True
    elif num < 0:
        negative_elements.append(int(num))

if len(negative_elements) % 2 == 0 or zero_exist:
    print(abs_sum)
else:
    print(abs_sum - (2 * min([abs(int(x)) for x in data])))

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = map(int, input().split())
plus_count = 0
total = 0
minimum = 999999999999999999

for a in A:
	total += abs(a)
	if abs(a) < minimum:
		minimum = abs(a)
	if a > 0:
		plus_count += 1
			
if plus_count % 2 == 0:
	print(total)
else:
	print(total - 2 * minimum)

Failing test case input:
5
2 -1 -4 -1 7

Expected output:
13


Actual output:
15


Fixed submission (verdict: Accepted):
N = int(input())
A = map(int, input().split())
minus_count = 0
total = 0
minimum = 999999999999999999

for a in A:
	total += abs(a)
	if abs(a) < minimum:
		minimum = abs(a)
	if a < 0:
		minus_count += 1
			
if minus_count % 2 == 0:
	print(total)
else:
	print(total - 2 * minimum)

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input=sys.stdin.readline
N=int(input())
num = list(map(int,input().split()))
c=0
ans=0
for i in range(N):
  if num[i]<0:
    c+=1 
ans = list(map(lambda x: abs(x),num))
if c%2==0:
  print(ans)
else:
  print(sum(ans) - min(num,key=lambda x: abs(x))*2)

Failing test case input:
3
-6 0 -3

Expected output:
9


Actual output:
[6, 0, 3]


Fixed submission (verdict: Accepted):
import sys
input=sys.stdin.readline
N=int(input())
num = list(map(int,input().split()))
c=0
ans=0
for i in range(N):
  if num[i]<0:
    c+=1 
ans = list(map(lambda x: abs(x),num))
if c%2==0:
  print(sum(ans))
else:
  print(sum(ans) - min(ans,key=lambda x: abs(x))*2)
Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(x) for x in input().split(' ')]

s = 0
mc = 0
for i in A:
  if i <= 0:
    mc += 1
  s += abs(i)

if (mc % 2 == 1):
  mv = min(A[0],A[-1])
  
  s -= mv*2
print(s)

Failing test case input:
5
3 -1 -4 -1 16

Expected output:
23


Actual output:
19


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

s = 0
mc = 0
mh = 1e10
for i in A:
  if i <= 0:
    mc += 1
  if abs(i) <= mh:
    mh = abs(i)
  s += abs(i)

if (mc % 2 == 1):
  mv = min(A[0],A[-1])
  
  s -= mh*2
print(s)

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
An = list(map(int, input().split()))
An = [abs(a) for a in An]
if N % 2 == 0:
  print(sum(An))
else:
  print(sum(An) - 2*min(An))

Failing test case input:
3
-10 5 -4

Expected output:
19

Actual output:
11


Fixed submission (verdict: Accepted):
N = int(input())
An = list(map(int, input().split()))
M = sum([0 if a >=0 else 1 for a in An])
An = [abs(a) for a in An]
if M % 2 == 0:
  print(sum(An))
else:
  print(sum(An) - 2*min(An))

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A=[int(x) for x in input().split()]
B=[x for x in A if x<0]
absA=[abs(x) for x in A]
if len(B)%2==0:
  minus=0
else:
  minus=max(B)
  
print(sum(absA)+minus)

Failing test case input:
11
-16874157 1000110000 -164217899 1001000010 -856410392 0 1010010000 -239123828 1000000010 -337457434 1010000110

Expected output:
6635203840


Actual output:
6618329683


Fixed submission (verdict: Accepted):
N=int(input())
A=[int(x) for x in input().split()]
B=[x for x in A if x<0]
absA=[abs(x) for x in A]
if len(B)%2==0:
  minus=0
else:
  minus=min(absA)
  
print(sum(absA)-minus*2)

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


def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  N = readInts()[0]
  A = readInts()
  minus = 0
  m = abs(A[0])
  s = 0
  for a in A:
    if a < 0:
      minus += 1
    if abs(a) < m:
      m = abs(a)
    s += abs(a)

  if minus % 2 == 0:
    print(s)
  else:
    print(s - m)

if __name__ == "__main__":
  main()


Failing test case input:
5
3 -4 -1 -28 5

Expected output:
39


Actual output:
40


Fixed submission (verdict: Accepted):


def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  N = readInts()[0]
  A = readInts()
  minus = 0
  m = abs(A[0])
  s = 0
  for a in A:
    if a < 0:
      minus += 1
    if abs(a) < m:
      m = abs(a)
    s += abs(a)

  if minus % 2 == 0:
    print(s)
  else:
    print(s - 2 * m)

if __name__ == "__main__":
  main()
Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
for i in range(n-1):
    if a[i] < 0:
        a[i] = a[i] * -1
        a[i+1] = a[i+1] * -1
if a[n-1] < 0 and a[n-2] < abs(a[n-1]):
    a[n-2] = a[n-2] * -1
    a[n-1] = a[n-1] * -1
print(sum(a))

Failing test case input:
5
10 -4 -4 -14 5

Expected output:
29


Actual output:
27


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

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
c=0
k=0
for i in range(0,n):
  if a[i]<0:
    c=c+1
  k=k+abs(a[i])
  a[i]=abs(a[i])
a.sort()
print(a)
if c%2==1:
  k=k-2*a[0]
  print(k)
else:
  print(k)

Failing test case input:
5
3 -4 -1 -28 5

Expected output:
39


Actual output:
[1, 3, 4, 5, 28]
39


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

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))
ans=0
c=0
tmp=10**9
for a in A:
    if a<0:
        c+=1
    ans+=abs(a)
    tmp=min(tmp,abs(a))
print(tmp)
if c%2==0:
    print(ans)
else:
    print(ans-tmp*2)

Failing test case input:
5
3 -4 -4 -28 5

Expected output:
38


Actual output:
3
38


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))
ans=0
c=0
tmp=10**9
for a in A:
    if a<0:
        c+=1
    ans+=abs(a)
    tmp=min(tmp,abs(a))
if c%2==0:
    print(ans)
else:
    print(ans-tmp*2)

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

n = int(input())
a_list = [int(i) for i in input().split()]
sum = 0
ans = 0
mini = 10000000000
count = 0
for i in range(n):
    if a_list[i]<0:
        count += 1
    mini = min(mini,abs(a_list[i]))
    sum += abs(a_list[i])

if count%2==1:
    print(sum - mini)
else:
    print(sum)


Failing test case input:
5
3 -4 -1 -28 5

Expected output:
39


Actual output:
40


Fixed submission (verdict: Accepted):
import math

n = int(input())
a_list = [int(i) for i in input().split()]
sum = 0
ans = 0
mini = 10000000000
count = 0
for i in range(n):
    if a_list[i]<0:
        count += 1
    mini = min(mini,abs(a_list[i]))
    sum += abs(a_list[i])

if count%2==1:
    print(sum - 2*mini)
else:
    print(sum)
Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
neg_num = 0
min_abs_a = float('inf')
sum_abs_A = 0
include_zero = False
for a in A:
  sum_abs_A += abs(a)
  if a == 0: include_zero = True
  if a < 0 : neg_num += 0
  min_abs_a = min(abs(a),min_abs_a)
print(sum_abs_A if neg_num%2==0 or include_zero is True else sum_abs_A - 2*min_abs_a)

Failing test case input:
3
-1 1 1

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
neg_num = 0
min_abs_a = float('inf')
sum_abs_A = 0
include_zero = False
for a in A:
  sum_abs_A += abs(a)
  min_abs_a = min(abs(a),min_abs_a)
  if a == 0: include_zero = True
  if a < 0 : neg_num += 1
print(sum_abs_A if neg_num%2==0 or include_zero is True else sum_abs_A - 2*min_abs_a)

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A= list(map(int, input().split()))
minus = 0
A_abs = []
for i in range(N):
    A_abs.append(abs(int(A[i])))
    if(A_abs[i] < 0):
        minus += 0

if minus % 2 == 0:
    print(sum(A_abs))
else:
    print(sum(A_abs) - 2*min(A_abs))

Failing test case input:
5
15 -4 -4 -14 5

Expected output:
34


Actual output:
42


Fixed submission (verdict: Accepted):
N = int(input())
A= list(map(int, input().split()))
minus = 0
A_abs = []
for i in range(N):
    A_abs.append(abs(int(A[i])))
    if(A[i] < 0):
        minus += 1

if minus % 2 == 0:
    print(sum(A_abs))
else:
    print(sum(A_abs) - 2*min(A_abs))

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
ans = 0
min_chk = 10**10
minus_chk = 0
for i in input().split():
    i = int(i)
    if i < 0 :
        minus_chk += 1
    num = abs(i)
    min_chk = min(num,min_chk)
    ans += num
if min_chk != 0:
    if minus_chk%2 == 1:
        print(ans-2*num)
    else:
        print(ans)
else:
    print(ans)

Failing test case input:
5
3 -4 -4 -28 5

Expected output:
38


Actual output:
34


Fixed submission (verdict: Accepted):
N=int(input())
ans = 0
min_chk = 10**10
minus_chk = 0
for i in input().split():
    i = int(i)
    if i < 0 :
        minus_chk += 1
    num = abs(i)
    min_chk = min(num,min_chk)
    ans += num
if min_chk != 0:
    if minus_chk%2 == 1:
        print(ans-2*min_chk)
    else:
        print(ans)
else:
    print(ans)

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

abs_min=+a[0]
abs_sum=0
cnt=0
for val in a:
	if val<0:
		cnt+=1
	abs_sum+=abs(val)
	abs_min=min([abs_min,abs(val)])

if cnt%2==0:
	print(abs_sum)
else:
	print(abs_sum-2*abs_min)

Failing test case input:
11
-29003401 1000100000 -8674852 1101000010 -856410392 0 1010010110 -493324020 1000001011 -485738863 1010000110

Expected output:
6994262769


Actual output:
7052269571


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

abs_min=abs(a[0])
abs_sum=0
cnt=0
for val in a:
	if val<0:
		cnt+=1
	abs_sum+=abs(val)
	abs_min=min([abs_min,abs(val)])

if cnt%2==0:
	print(abs_sum)
else:
	print(abs_sum-2*abs_min)
Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
num_sum = 0
num_min = a[0]
num_minus = 0

for i in range(n):
    if (a[i] <= 0):
        num_minus += 1
    num_min = min(num_min, abs(a[i]))
    num_sum += abs(a[i])

if (num_minus % 2 == 0):
    print (num_sum)
else:
    print(num_sum-num_min*2)


Failing test case input:
3
-1 5 1

Expected output:
5


Actual output:
9


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
num_sum = 0
num_min = abs(a[1])
num_minus = 0

for i in range(n):
    if (a[i] <= 0):
        num_minus += 1
    num_min = min(num_min, abs(a[i]))
    num_sum += abs(a[i])

if (num_minus % 2 == 0):
    print (num_sum)
else:
    print(num_sum-num_min*2)

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

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


ans = 0
minnum = abs(A[0])
for i in range(N):
    ans += abs(A[i])
    minnum = min(minnum,abs(A[i]))
    
ans -= minnum*2
print(ans)

Failing test case input:
3
-10 5 -4

Expected output:
19

Actual output:
11


Fixed submission (verdict: Accepted):

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


ans = 0
minnum = abs(A[0])
numminus = 0
for i in range(N):
    if A[i]<0:
        numminus+=1
    ans += abs(A[i])
    minnum = min(minnum,abs(A[i]))
    
if numminus%2 == 1:
    ans -= minnum*2
print(ans)

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

A_m = list()
A_p = list()
for a in A:
    if a >= 0: A_p.append(a)
    else: A_m.append(a)
M = 0
M += sum(A_p)
M -= sum(A_m)
if len(A_m)%2:
    M -= 2*max(A_m)
print(M)

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

Expected output:
11


Actual output:
15


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

A_m = list()
A_p = list()
for a in A:
    if a >= 0: A_p.append(a)
    else: A_m.append(a)
M = 0
M += sum(A_p)
M -= sum(A_m)
if len(A_m)%2:
    A_abs = list(map(abs, A))
    M = sum(A_abs)
    M -= 2*min(A_abs)
print(M)

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

for x in range(0, len(aList)):
	aList[x] = -aList[x] if aList[x] < 0 else aList[x]

aMin = min(aList)

print(sum(aList) - ((aMin if len(aList)%2 == 1 else 0)*2))




Failing test case input:
3
-2 1 -1

Expected output:
4


Actual output:
2


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

minNum = 0

for x in range(0, len(aList)):
	minNum += 1 if aList[x] < 0 else 0
	aList[x] = -aList[x] if aList[x] < 0 else aList[x]

aMin = min(aList)


even = minNum%2==0

if even:
	print(sum(aList))
else:
	print(sum(aList) - (aMin*2))
Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [int(x) for x in input().split()]
abs_a = [abs(x) for x in a]
parity_a = len([x for x in a if x < 0]) % 2

if parity_a == 0:
  print(sum(abs_a))
else:
  print(sum(abs_a) - min(abs_a))

Failing test case input:
3
-1 5 1

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(x) for x in input().split()]
abs_a = [abs(x) for x in a]
parity_a = len([x for x in a if x < 0]) % 2

if parity_a == 0:
  print(sum(abs_a))
else:
  print(sum(abs_a) - 2 * min(abs_a))

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
lis = list(map(int,input().split()))
numm = 0
ans = 0
nu = 10 ** 9
for num in lis:
  nu = min(nu,num)
  ans += abs(num)
  if num < 0:
    numm += 1
if numm % 2 == 1:
  print(ans-nu*2)
else:
  print(ans)

Failing test case input:
11
-54256173 1000110000 -95473458 1001000010 -856410392 0 1010010000 -239123828 1000100010 -337457434 1110000110

Expected output:
6703941415


Actual output:
8416762199


Fixed submission (verdict: Accepted):
n = int(input())
lis = list(map(int,input().split()))
numm = 0
ans = 0
nu = 10 ** 9
for num in lis:
  nu = min(nu,abs(num))
  ans += abs(num)
  if num < 0:
    numm += 1
if numm % 2 == 1:
  print(ans-nu*2)
else:
  print(ans)

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=[int(i) for i in input().split()]
ans=None
a_pos=[abs(i) for i in a]
a_min=min(a_pos)
if n%2==0:
    ans=sum(a_pos)
else: ans=sum(a_pos)-2*a_min

Failing test case input:
11
-1000000000 1000000000 -364513171 1000000000 -1382285407 0 1000000000 -1000000000 1000000001 -1000000000 1000000100

Expected output:
9746798679


Actual output:

Fixed submission (verdict: Accepted):
n=int(input())
a=[int(i) for i in input().split()]
ans=None
a_pos=[abs(i) for i in a]
a_min=min(a_pos)
a_neg=sum([1 if i<0 else 0 for i in a])
if a_neg%2==0:
    ans=sum(a_pos)
else: ans=sum(a_pos)-2*a_min
print(ans)

Problem: p03062
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
lst = list(map(int, input().split()))
mcnt = 0
for i in range(n):
  if lst[i] < 0:
    mcnt += 1
if 0 in lst or mcnt % 2 == 0:
  print(sum(list(map(abs, lst))))
  exit()
m = min(lst, key=abs)
print(sum(list(map(abs, lst))) - 2 * m)

Failing test case input:
5
15 -4 -4 -14 5

Expected output:
34


Actual output:
50


Fixed submission (verdict: Accepted):
n = int(input())
lst = list(map(int, input().split()))
mcnt = 0
for i in range(n):
  if lst[i] < 0:
    mcnt += 1
if 0 in lst or mcnt % 2 == 0:
  print(sum(list(map(abs, lst))))
  exit()
m = min(lst, key=abs)
print(sum(list(map(abs, lst))) - 2 * abs(m))
Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

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

ans = 0
cost = float('inf')
count = 0

for i in a:
    ans += abs(i)
    cost = min(cost,abs(i))
    if i > 0:
        count += 1

if 0 not in a:
    count = max(count,n-count)
    if count % 2 != 0:
        ans -= cost

print(ans)

Failing test case input:
3
-1 1 1

Expected output:
1


Actual output:
3


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

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

ans = 0
cost = float('inf')
count = 0

for i in a:
    ans += abs(i)
    cost = min(cost,abs(i))
    if i < 0:
        count += 1

if 0 not in a:
    
    if count % 2 != 0:
        ans -= 2*cost

print(ans)

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



signA = sum([1 for a in A if a<0])

absA = [abs(a) for a in A]
absA.sort()

sumA = sum(absA)
      
         
if any([a==0 for a in A]):
  print(sumA)
if signA%2==0:
  print(sumA)
if signA%2!=0:
  print(sumA - 2*absA[0])

Failing test case input:
3
-6 0 -3

Expected output:
9


Actual output:
9
9


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



signA = sum([1 for a in A if a<0])

absA = [abs(a) for a in A]
absA.sort()

sumA = sum(absA)
      
         
if any([a==0 for a in A]):
  print(sumA)
elif signA%2==0:
  print(sumA)
elif signA%2!=0:
  print(sumA - 2*absA[0])

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def flipping(n,a):
    c = list(filter(lambda x:x<0,a))
    b = list(map(lambda x:abs(x),a))
    if len(c)%2==0:
        return sum(b)
    if len(c)%2!=0:
        return sum(b)-min(b)
    return b
n = int(input())
a=list(map(int, input().split()))
print(flipping(n,a))

Failing test case input:
5
15 -4 -4 -28 5

Expected output:
48


Actual output:
52


Fixed submission (verdict: Accepted):
def flipping(n,a):
    c = list(filter(lambda x:x<0,a))
    b = list(map(lambda x:abs(x),a))
    if len(c)%2==0:
        return sum(b)
    if len(c)%2!=0:
        return sum(b)-2*min(b)
    return b
n = int(input())
a=list(map(int, input().split()))
print(flipping(n,a))

Problem: p03062
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

b = [abs(i) for i in a]

if (sum([i < 0 for i in a]) + sum([i == 0 for i in a]))% 2 == 0:
    print(sum(b))
else:
    b = [abs(i) for i in a]
    a0 = a.pop(0)
    af = a.pop()
    print(sum(b) - min(abs(a0), abs(af)) * 2)

Failing test case input:
3
-6 0 -3

Expected output:
9


Actual output:
3


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

b = [abs(i) for i in a]

if (sum([i < 0 for i in a]) + sum([i == 0 for i in a])) % 2 == 0:
    print(sum(b))
else:
    print(sum(b) - min(b) * 2)
Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
cnt = 0
for i in range(N):
  if A[i] < 0:
    A[i] = abs(A[i])
    cnt += 1
if cnt == 1:
  print(sum(A)-2*min(A))
else:
  print(sum(A))

Failing test case input:
5
10 -4 -8 -11 3

Expected output:
30

Actual output:
36


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

Problem: p03062
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    s, cnt = [0]*n, 0
    for i in range(n):
        s[i] = abs(a[i])
        if i < 0:
            cnt += 1
    if cnt%2:
        print(sum(s) - 2*min(s))
    else:
        print(sum(s))

if __name__ == "__main__":
    main()

Failing test case input:
5
17 -4 -4 -14 5

Expected output:
36


Actual output:
44


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    s, cnt = [0]*n, 0
    for i in range(n):
        s[i] = abs(a[i])
        if a[i] < 0:
            cnt += 1
    if cnt%2:
        print(sum(s) - 2*min(s))
    else:
        print(sum(s))

if __name__ == "__main__":
    main()

Problem: p03062
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def main():
  n=int(input())
  a=list(map(int,input().split()))
  dp=[0]*2
  for i in range(n):
    dp2=[max(dp[0]+a[i],dp[1]-a[i]),max(dp[0]-a[i],dp[1]+a[i])]
    dp=dp2
  print(max(dp))
main()

Failing test case input:
5
10 -4 -8 -11 5

Expected output:
30


Actual output:
38


Fixed submission (verdict: Accepted):
def main():
  n=int(input())
  a=list(map(int,input().split()))
  dp=[0,-10**18]
  for i in range(n-1):
    dp2=[max(dp[0]+a[i],dp[1]-a[i]),max(dp[0]-a[i],dp[1]+a[i])]
    dp=dp2
  print(max(dp[0]+a[-1],dp[1]-a[-1]))
main()

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
A=list(map(int,input().split()))
B=[abs(i) for i in A]
P=0
for i in A:
    if i<0:P +=1
    elif i==0:print(sum(B));exit()

print(B if P%2==0 else sum(B)-2*min(B))

Failing test case input:
3
-2 1 -1

Expected output:
4


Actual output:
[2, 1, 1]


Fixed submission (verdict: Accepted):
n=int(input())
A=list(map(int,input().split()))
B=[abs(i) for i in A]
P=0
for i in A:
    if i<0:P +=1
    elif i==0:print(sum(B));exit()

print(sum(B) if P%2==0 else sum(B)-2*min(B))

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

for i in range(N - 1):
  if A[i] < 0:
    A[i] *= -1
    A[i + 1] *= -1
print(sum(A))

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

Expected output:
11


Actual output:
3


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

for i in range(N):
  if A[i] < 0:
    count += 1
    A[i] *= -1
print(sum(A) if count % 2 == 0 else sum(A) - min(A) * 2)
Problem: p03062
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
a = [int(i) for i in input().split()]

minv = 0
count = 0
s = 0
for i in range(n):
    if a[i] < 0:
        s += -a[i]
        if minv > -a[i] or minv == 0:
            minv = -a[i]
        count += 1
    else:
        s += a[i]
        if minv > a[i] or minv == 0:
            minv = a[i]

if count % 2 == 1:
    s += 2*(-minv)

print(s)


Failing test case input:
11
-1000000000 1000010000 -425259316 1000000000 -2020380734 0 1000010000 -1000000000 1000000001 -162702447 1000000100

Expected output:
9608362598


Actual output:
9282957704


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

minv = -1
count = 0
s = 0
for i in range(n):
    if a[i] < 0:
        s += -a[i]
        if minv > -a[i] or minv == -1:
            minv = -a[i]
        count += 1
    else:
        s += a[i]
        if minv > a[i] or minv == -1:
            minv = a[i]

if count % 2 == 1:
    s += 2*(-minv)

print(s)

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
minus_count = 0
for i in a:
    if i < 0:
        minus_count += 1
a = [abs(e) for e in a]
if minus_count % 2 != 0:
    a.pop(a.index(min(a)))
ans = sum(a)
print(ans)

Failing test case input:
5
10 -4 -4 -11 5

Expected output:
26


Actual output:
30


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
a_min = 0
minus_count = 0
for i in a:
    if i < 0:
        minus_count += 1
a = [abs(e) for e in a]
if minus_count % 2 != 0:
    a_min = a.pop(a.index(min(a)))
ans = sum(a) - a_min
print(ans)

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A =list(map(int, input().split()))
minus = [i for i in A if i < 0]
if len(minus) % 2 == 0:
  max_num = [abs(i) for i in A]
else:
  max_num = [abs(i) for i in A]
  if min(max_num) in A:
    print(sum(max_num) - 2*min(max_num))
  else:
    print(sum(max_num) + min(max_num))

Failing test case input:
5
3 -4 -1 -28 5

Expected output:
39


Actual output:
42


Fixed submission (verdict: Accepted):
N = int(input())
A =list(map(int, input().split()))
minus = [i for i in A if i < 0]
if len(minus) % 2 == 0:
  max_num = [abs(i) for i in A]
  print(sum(max_num))
else:
  max_num = [abs(i) for i in A]
  if min(max_num) in A:
    print(sum(max_num) - 2*min(max_num))
  else:
    print(sum(max_num) + -(2*min(max_num)))

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

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


ans = 0
minnum = abs(A[0])
for i in range(N):
    ans += abs(A[i])
    minnum = min(minnum,abs(A[i]))
    
if N%2 == 1:
    ans -= minnum*2
print(ans)

Failing test case input:
3
-2 1 -1

Expected output:
4


Actual output:
2


Fixed submission (verdict: Accepted):

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


ans = 0
minnum = abs(A[0])
numminus = 0
for i in range(N):
    if A[i]<0:
        numminus+=1
    ans += abs(A[i])
    minnum = min(minnum,abs(A[i]))
    
if numminus%2 == 1:
    ans -= minnum*2
print(ans)
Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
neg_num = 0
min_abs_a = float('inf')
sum_abs_A = 0
include_zero = False
for a in A:
  sum_abs_A += abs(a)
  if a == 0: include_zero = True
  if a < 0 :
    neg_num += 0
    min_abs_a = min(abs(a),min_abs_a)
print(sum_abs_A if neg_num%2==0 or include_zero is True else sum_abs_A - 2*min_abs_a)

Failing test case input:
5
15 -4 -4 -14 5

Expected output:
34


Actual output:
42


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
neg_num = 0
min_abs_a = float('inf')
sum_abs_A = 0
include_zero = False
for a in A:
  sum_abs_A += abs(a)
  min_abs_a = min(abs(a),min_abs_a)
  if a == 0: include_zero = True
  if a < 0 : neg_num += 1
print(sum_abs_A if neg_num%2==0 or include_zero is True else sum_abs_A - 2*min_abs_a)

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

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

print(sum(A))


Failing test case input:
5
3 -1 -4 -1 16

Expected output:
23


Actual output:
-7


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

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

if A[-1] < 0:
    A[-1] *= -1
    print(sum(A) - 2*min(A))
else:
    print(sum(A))

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


N = int(input())
A = [int(a) for a in input().split()]








ng = [a for a in A if a < 0]    
ab = [abs(a) for a in A]    

if len(ng) % 2 == 0:
    print(sum(ab))
else:
    mn = max(ng)
    print(sum(ab)+2*mn)



Failing test case input:
3
-2 0 1

Expected output:
3


Actual output:
-1


Fixed submission (verdict: Accepted):


N = int(input())
A = [int(a) for a in input().split()]








ng = [a for a in A if a < 0]    
ab = [abs(a) for a in A]    

if len(ng) % 2 == 0:
    print(sum(ab))
else:
    mn = min(ab)
    print(sum(ab)-2*mn)

Problem: p03062
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

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

neg = sum(1 for x in a if x<0)

ans = 0

if neg%2:
	for i in range(len(a)):
		if i == 0:
			exc = abs(a[i])
		else:
			exc = min(exc, abs(a[i]))
	ans = sum(abs(x) for x in a)-exc
else:
	ans = sum(abs(x) for x in a)

print(ans)

Failing test case input:
5
15 -4 -4 -14 5

Expected output:
34


Actual output:
38


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

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

neg = sum(1 for x in a if x<0)

ans = 0

if neg%2:
	for i in range(len(a)):
		if i == 0:
			exc = abs(a[i])
		else:
			exc = min(exc, abs(a[i]))
	ans = sum(abs(x) for x in a)-exc*2
else:
	ans = sum(abs(x) for x in a)

print(ans)