ZhenlongDai/ACPR huggingface dataset:
Problem: p02838
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def solve(string):
    n, *a = map(int, string.split())
    a = [list(map(int, "{:060b}".format(_a))) for _a in a]
    m = 10**9 + 7
    ans = 0
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Failing test case input:
10
0 0 1 711 144969 3606555 90292 1781441 195528422 25753549153

Expected output:
211184535


Actual output:
0


Fixed submission (verdict: Accepted):
def solve(string):
    n, *a = map(int, string.split())
    a = ["{:060b}".format(_a) for _a in a]
    m = 10**9 + 7
    ans = 0
    for i, d in enumerate(zip(*a)):
        s = "".join(d).count("1")
        ans += s * (n - s) * pow(2, 59 - i, m)
        ans %= m
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Problem: p02838
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def solve(string):
    n, *a = map(int, string.split())
    a = [list(map(int, "{:060b}".format(_a))) for _a in a]
    m = 10**9 + 7
    ans = 0
    for d in zip(*a):
        s = sum(d)
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Failing test case input:
10
5 1 45 4519 144969 3606555 535597 1127593 195528422 15184658045

Expected output:
154905677


Actual output:
0


Fixed submission (verdict: Accepted):
def solve(string):
    n, *a = map(int, string.split())
    a = ["{:060b}".format(_a) for _a in a]
    m = 10**9 + 7
    ans = 0
    for i, d in enumerate(zip(*a)):
        s = "".join(d).count("1")
        ans += s * (n - s) * pow(2, 59 - i, m)
        ans %= m
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Problem: p02838
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
ans = 0
for i in range(60):
    count = sum(1 for j in a if j>>i == 1)
    ans += count * (n-count) * 2**i
print(ans % mod)

Failing test case input:
10
5 1 10 4519 144969 3606555 535597 1781441 195528422 25753549153

Expected output:
214703889


Actual output:
861027896


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
ans = 0
for i in range(60):
    mask = 1 << i
    count = sum(1 for j in a if mask & j == 0)
    ans += count * (n-count) * pow(2,i,mod)
print(ans % mod)
Problem: p02838
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

bitlist = [0] * 60

for i in A:
    for index, num in enumerate(reversed(bin(i)[2:])):
        if num == "1":
            bitlist[index] += 1
ans = 0
for bit, num in enumerate(bitlist):
    ans += num * (N-num) * (2 ** bit)

print(ans)

Failing test case input:
10
3 14 159 1904 58979 323846 2643383 27950288 419716939 9375105820

Expected output:
103706799


Actual output:
88103707415


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

bitlist = [0] * 60

for i in A:
    for index, num in enumerate(reversed(bin(i)[2:])):
        if num == "1":
            bitlist[index] += 1
ans = 0
for bit, num in enumerate(bitlist):
    ans += num * (N-num) * (2 ** bit)
    ans %= (10**9+7)
print(ans)

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













N=int(input())
A=list(map(int,input().split()))
p=10**9+7

ans=0
for k in range(60):
    cnt_z=0
    cnt_o=0
    
    for i in range(N):
        s=A[i]%2
        if s==0:
            cnt_z +=1
        else:
            cnt_o +=1
        A[i] >>= 1
    ans += ((2**k)*cnt_z*cnt_o)%p
       
print(ans)

Failing test case input:
10
4 1 49 6527 85420 787258 1612639 1932882 103360234 15184658045

Expected output:
617826416


Actual output:
2617826430


Fixed submission (verdict: Accepted):













N=int(input())
A=list(map(int,input().split()))
p=10**9+7

ans=0
for k in range(60):
    cnt_z=0
    cnt_o=0
    
    for i in range(N):
        s=A[i]%2
        if s==0:
            cnt_z +=1
        else:
            cnt_o +=1
        A[i] >>= 1
    ans += ((2**k)*cnt_z*cnt_o)%p
       
print(ans%p)

Problem: p02838
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
ans = 0

for bit in range(10):
    m = 1 << bit
    
    c = sum(a&m for a in A) >> bit
    
    ans += (c*(N-c))<<bit
    
    ans %= mod
print(ans)

Failing test case input:
10
0 0 1 358 39763 7015634 92549 663262 332665684 12968449561

Expected output:
727852887


Actual output:
23704


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
ans = 0

for bit in range(60):
    m = 1 << bit
    
    c = sum(a&m for a in A) >> bit
    
    ans += (c*(N-c))<<bit
    
    ans %= mod
print(ans)

Problem: p02838
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
MOD = 1000000007

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

ans = 0
for k in range(60):
    mask = 1<<k
    cnt1 = sum(1 for x in a if x&mask != 0)
    ans += cnt1*(n-cnt1)*(1<<k)
print(ans)

Failing test case input:
10
4 1 32 6527 144969 1412470 1425293 2621982 195528422 15184658045

Expected output:
156202879


Actual output:
138156203845


Fixed submission (verdict: Accepted):
MOD = 1000000007

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

ans = 0
for k in range(60):
    mask = 1<<k
    cnt1 = sum(1 for x in a if x&mask != 0)
    ans += cnt1*(n-cnt1)*(1<<k)
print(ans%MOD)
Problem: p02838
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [format(i, '060b') for i in map(int, input().split())]
divide = 10 ** 9 + 7
ans = []

for i in range(60):
    bit_list = [b[59-i] for b in a]
    val = bit_list.count('0') * bit_list.count('1')
    ans.append((val * 2 ** i) % divide)

print(sum(ans))

Failing test case input:
10
1 1 302 6527 58979 541636 4318549 2345853 102512643 14164456034

Expected output:
323177923


Actual output:
2323177937


Fixed submission (verdict: Accepted):
n = int(input())
divide = 10 ** 9 + 7

a = [format(i, '060b') for i in map(int, input().split())]
ans = []

for i in range(60):
    bit_list = [b[59-i] for b in a]
    val = bit_list.count('0') * bit_list.count('1')
    ans.append((val * 2 ** i))

print(sum(ans)%divide)
Problem: p03434
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse = True)
ans = 0
for i in range(0,N-1,2):
	ans += (A[i] - A[i+1])
print(ans)

Failing test case input:
3
2 7 4

Expected output:
5

Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse = True)
A.insert(N,0)
ans = 0
for i in range(0,N,2):
	ans += (A[i] - A[i+1])
print(ans)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
a.sort()
print((sum(a[::2])-(sum(a[1::2]))))

Failing test case input:
4
139 1 2 5

Expected output:
135


Actual output:
-135


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
print((sum(a[::2])-(sum(a[1::2]))))

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

bob = []
alice = []
for i in range(1, n+1):
    if i % 2 == 1:
        max_value = max(array)
        array.remove(max_value)
        alice.append(max_value)
    else:
        min_value = min(array)
        array.remove(min_value)
        bob.append(min_value)

print(sum(alice)-sum(bob))


Failing test case input:
4
139 0 2 4

Expected output:
137


Actual output:
141


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

bob = []
alice = []
for i in range(1, n+1):
    max_value = max(array)
    if i % 2 == 1:
        alice.append(max_value)
    else:
        bob.append(max_value)
    array.remove(max_value)

print(sum(alice)-sum(bob))

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
L = list(map(int, input().split()))
L.sort()
A = 0
B = 0
for i in range(N):
  if i % 2 == 0:
    A += i
  else:
    B += i
print(A-B)

Failing test case input:
2
0 171

Expected output:
171


Actual output:
-1


Fixed submission (verdict: Accepted):
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
ans = 0
for i in range(N):
  if i % 2 == 0:
    ans += L[i]
  else:
    ans -= L[i]
print(ans)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input()) 
M = str(input())
A = M.split()
print (A[1])
Bob=0
Alice=0
A.reverse() 
print(A)
for i in range(0,N):
      if i % 2 == 0: 
         Alice=Alice+int(A[i])
      else:
         Bob=Bob+int(A[i])
print(Alice-Bob)

Failing test case input:
2
5 -2

Expected output:
7


Actual output:
-2
['-2', '5']
-7


Fixed submission (verdict: Accepted):
N = int(input()) 
A = sorted(map(int, input().split()), reverse = True)
Bob=0
Alice=0
for i in range(0,N):
      if i % 2 == 0: 
         Alice=Alice+int(A[i])
      else:
         Bob=Bob+int(A[i])
print(Alice-Bob)
Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
card = list(map(int,input().split()))
sorted_card = sorted(card)
Alice = 0
Bob = 0

for i in range(N):
    if i == 0 or i % 2 == 0:
        Alice += sorted_card[i]
    else:
        Bob += sorted_card[i]

print(Alice - Bob)

Failing test case input:
4
20 18 2 18

Expected output:
18

Actual output:
-18


Fixed submission (verdict: Accepted):
N = int(input())
card = list(map(int,input().split()))
sorted_card = sorted(card,reverse=True)
Alice = 0
Bob = 0

for i in range(N):
    if i == 0 or i % 2 == 0:
        Alice += sorted_card[i]
    else:
        Bob += sorted_card[i]

print(Alice - Bob)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input(""))
data = input("")
a = sorted(data.split(" "))[::-1]
ans = 0
for i in range(n):
    if i%2 == 0:
        ans += int(a[i])
    else: ans -= int(a[i])
print(ans)

Failing test case input:
2
-1 -48

Expected output:
47


Actual output:
-47


Fixed submission (verdict: Accepted):
n = int(input(""))
data = input("")
a = data.split(" ")
ans = 0

for i in range(n):
    a[i] = int(a[i])
a.sort(reverse = True)

for i in range(n):
    if i%2 == 0:
        ans += int(a[i])
    else: ans -= int(a[i])
print(ans)

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

Failing test case input:
3
3 7 4

Expected output:
6


Actual output:
0


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

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
sum1 = 0
sum2 = 0
for j in range(N):
    if j%2 == 0:
        print(a[j])
        sum1 = sum1 + a[j]
    elif j%2 ==1:
        print(a[j])
        sum2 = sum2 + a[j]
print(sum1 - sum2)


Failing test case input:
2
-1 152

Expected output:
153


Actual output:
152
-1
153


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
sum1 = 0
sum2 = 0
for j in range(N):
    if j%2 == 0:
        sum1 = sum1 + a[j]
    elif j%2 ==1:
        sum2 = sum2 + a[j]
print(sum1 - sum2)
Problem: p03434
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
N=int(input())
a=list(map(int,input().split()))
a=sorted(a)
print(a)
alice=0
bob=0
if(N%2==0):
    for i in range(0,N-1,2):
        alice=a[i+1]+alice
        bob=a[i]+bob
else:
    for i in range(1,N-1,2):
        alice=a[i+1]+alice
        bob=a[i]+bob
    alice=alice+a[0]
print(alice-bob)

Failing test case input:
2
-43 123

Expected output:
166


Actual output:
[-43, 123]
166


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

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

a.sort(reverse=True)

alice = 0
bob = 0
for i in range(n-1):
    if i % 2 is 0:
        alice = alice + int(a[i])
    else:
        bob = bob + int(a[i])
        
print(alice - bob)

Failing test case input:
3
3 9 4

Expected output:
8


Actual output:
5


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

a.sort(reverse=True)

alice = 0
bob = 0
for i in range(n):
    if i % 2 is 0:
        alice = alice + int(a[i])
    else:
        bob = bob + int(a[i])
        
print(alice - bob)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
alice=sum(a[::2])
Bob=sum(a[1::2])
print(alice-Bob)

Failing test case input:
2
-144 215

Expected output:
359


Actual output:
-359


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
b=sorted(a,reverse=True)
alice=sum(b[::2])
Bob=sum(b[1::2])
print(alice-Bob)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
card_n = int(input())
card_collection = list(map(int, input().split()))

scores = {"alice" : 0, "bob" :0}
card_collection.sort()
for i, card in enumerate(card_collection):
    if i % 2 == 0:
        scores['bob'] += card
    else:
        scores['alice'] += card
print(scores['alice'] - scores['bob'])

    

Failing test case input:
3
2 7 4

Expected output:
5

Actual output:
-5


Fixed submission (verdict: Accepted):
card_n = int(input())
card_collection = list(map(int, input().split()))

scores = {"alice" : 0, "bob" :0}
card_collection.sort(reverse = True)
for i, card in enumerate(card_collection):
    if i % 2 == 0:
        scores['alice'] += card
    else:
        scores['bob'] += card
print(scores["alice"] - scores["bob"])
Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(i) for i in input().split()]
A.sort()

if N == 1:
	print(A[0])
else:
	Alice = sum(A[0::2])
	Bob = sum(A[1::2])
	print(Alice-Bob)

Failing test case input:
2
2 32

Expected output:
30


Actual output:
-30


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse=True)

if N == 1:
	print(A[0])
else:
	Alice = sum(A[0::2])
	Bob = sum(A[1::2])
	print(Alice-Bob)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [int(i) for i in input().split()]
a.sort
print(sum(a[::2]) - sum(a[1::2]))

Failing test case input:
2
-2 152

Expected output:
154


Actual output:
-154


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
print(sum(a[::2]) - sum(a[1::2]))

Problem: p03434
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = input()
A = list(input().split())
A = list(map(int,A))
A = sorted(A,reverse = True)
a = 0
b = 0
try :
  while len(A) != 0 :
    a += A.pop(0)
    b += A.pop(0)
except IndexError :
  print(a-b)
print(a-b)

Failing test case input:
3
2 7 4

Expected output:
5

Actual output:
5
5


Fixed submission (verdict: Accepted):
N = input()
A = list(input().split())
A = list(map(int,A))
A = sorted(A,reverse = True)
a = 0
b = 0
try :
  while len(A) != 0 :
    a += A.pop(0)
    b += A.pop(0)
  print(a-b)
except IndexError :
  print(a-b)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
A=list(map(int,input().split(' ')))
A.sort()
a=0
b=0
i=0
while i < n:
    if i%2==0:
        a+= A[i]
    else:
        b += A[i]
    i += 1
print(a-b)

Failing test case input:
2
0 -84

Expected output:
84


Actual output:
-84


Fixed submission (verdict: Accepted):
n=int(input())
A=list(map(int,input().split(' ')))
A.sort()
a=0
b=0
i=0
while i < n:
    if i%2==0:
        a+= A[i]
    else:
        b += A[i]
    i += 1
print(abs(a-b))

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = input()
a = input().split()

tmp = sorted(a, reverse=True)

al = 0
bo = 0

for i in range(len(tmp)):
  if i %2 == 0:
    al = al + int(tmp[i])

  else:
    bo = bo + int(tmp[i])

print(al - bo)

Failing test case input:
4
20 1 4 12

Expected output:
11


Actual output:
-5


Fixed submission (verdict: Accepted):
n = input()
a = input().split()
a = map(int, a)
tmp = sorted(a, reverse=True)

al = 0
bo = 0

for i in range(len(tmp)):
  if i %2 == 0:
    al = al + int(tmp[i])

  else:
    bo = bo + int(tmp[i])

print(al - bo)
Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = input()
a = list(map(int, input().split()))
a= sorted(a, reverse=True)
print(a)
ans =0
for i in a:
    if i%2 == 0:
        ans += i
    elif i%2 ==1:
        ans -= i
print(ans)

Failing test case input:
2
1 70

Expected output:
69


Actual output:
[70, 1]
69


Fixed submission (verdict: Accepted):
n = input()
a = list(map(int, input().split()))
a= sorted(a, reverse=True)
ans =0
for i in range(len(a)):
    if i%2 == 0:
        ans += a[i]
    elif i%2 ==1:
        ans -= a[i]
print(ans)

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

a[:n].sort(reverse=True)

A=B=I=0
for i in a:
    if I %2:B+=i
    else:A+=i
    I+=1

print(A-B)




Failing test case input:
2
2 32

Expected output:
30


Actual output:
-30


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

A=B=I=0
for i in a:
    if I %2:B+=i
    else:A+=i
    I+=1

print(A-B)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
alist = input().split()
alist = sorted(alist, reverse=True)
print(alist)
count = 1
alice = 0
bob = 0

for a in alist:
    if count % 2:
        alice += int(a)
    else:
        bob += int(a)
    count+=1
print(alice - bob)

Failing test case input:
2
0 -48

Expected output:
48


Actual output:
['0', '-48']
48


Fixed submission (verdict: Accepted):
N = int(input())
alist = input().split()
aint = list(map(int, alist))
aint = sorted(aint, reverse=True)
count = 1
alice = 0
bob = 0

for a in aint:
    if count % 2:
        alice += a
    else:
        bob += a
    count = count + 1
print(alice - bob)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    target_num = input()
    target_list = input().split()

    target_list.sort(reverse=True)

    result_a = 0
    result_b = 0
    a_flg = True
    for target in target_list:
        if a_flg:
            result_a += int(target)
            a_flg = False
        else:
            result_b += int(target)
            a_flg = True

    print(result_a - result_b)


if __name__ == '__main__':
    main()


Failing test case input:
2
-56 -1

Expected output:
55


Actual output:
-55


Fixed submission (verdict: Accepted):
def main():
    target_num = input()
    target_list = list(map(int, input().split()))

    target_list.sort(reverse=True)

    result_a = 0
    result_b = 0
    a_flg = True
    for target in target_list:
        if a_flg:
            result_a += int(target)
            a_flg = False
        else:
            result_b += int(target)
            a_flg = True

    print(result_a - result_b)


if __name__ == '__main__':
    main()

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
input()
a = list(map(int, input().split()))
a.sort()
print(sum(a[::2]) - sum(a[1::2]))

Failing test case input:
2
-1 45

Expected output:
46


Actual output:
-46


Fixed submission (verdict: Accepted):
input()
a = list(map(int, input().split()))
a.sort(reverse=True)
print(sum(a[::2]) - sum(a[1::2]))
Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
firstint = int(input())
inputary = input()
listA= inputary.split()
listA.sort(reverse=True)
Alice = 0
Bob = 0
for index,elm in enumerate(listA):
    if index % 2 is 0:
        Alice += int(listA[index])
    else:
        Bob += int(listA[index])

print(Alice - Bob)


Failing test case input:
4
23 4 1 12

Expected output:
14


Actual output:
-8


Fixed submission (verdict: Accepted):
firstint = int(input())
inputary = input()
listA= inputary.split()
numlist =[ int(x) for x in listA]
numlist.sort(reverse=True)
Alice = 0
Bob = 0
for index,elm in enumerate(numlist):
    if index % 2 == 0:
        Alice += int(numlist[index])
    else:
        Bob += int(numlist[index])

print(Alice - Bob)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

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

for i in range(N):
   for j in reversed(range(i+1,N)):
        print(i,j)
        if a[j] > a[j-1]:
            temp = a[j]
            a[j] = a[j-1]
            a[j-1] = temp

Alice = 0
Bob = 0

k = 0
count =1
while k < N:
    if count % 2 == 0:
        Bob += a[k]
    else:
        Alice += a[k]
    k += 1
    count += 1

print(Alice-Bob)

Failing test case input:
4
47 4 1 5

Expected output:
45


Actual output:
0 3
0 2
0 1
1 3
1 2
2 3
45


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

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

for i in range(N):
   for j in reversed(range(i+1,N)):
        
        if a[j] > a[j-1]:
            temp = a[j]
            a[j] = a[j-1]
            a[j-1] = temp

Alice = 0
Bob = 0

k = 0
count =1
while k < N:
    if count % 2 == 0:
        Bob += a[k]
    else:
        Alice += a[k]
    k += 1
    count += 1

print(Alice-Bob)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
sorted(a, reverse=True)
alice = 0
bob = 0
flag_alice = True
for num in a:
    print(num)
    if flag_alice:
        alice += num
        flag_alice = False
    else:
        bob += num
        flag_alice = True
print(alice - bob)


Failing test case input:
4
23 4 1 12

Expected output:
14


Actual output:
23
4
1
12
8


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = 0
bob = 0
flag_alice = True
for num in a:
    if flag_alice:
        alice += num
        flag_alice = False
    else:
        bob += num
        flag_alice = True
print(alice - bob)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
x = input().split()
x.sort(reverse=True)
a = 0
b = 0
for i in range(0, n):
  if i % 2 == 0:
    a += int(x[i])
  else:
    b += int(x[i])
print(a - b)

Failing test case input:
2
-56 -1

Expected output:
55


Actual output:
-55


Fixed submission (verdict: Accepted):
n = int(input())
x = input().split()
y = []
for i in x:
  y.append(int(i))
y.sort(reverse=True)
a = 0
b = 0
for i in range(0, n):
  if i % 2 == 0:
    a += int(y[i])
  else:
    b += int(y[i])
print(a - b)
Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=int(input())
li = list(map(int,input().split()))

sortedList = sorted(li, reverse=True)
print(sortedList)

alice = 0
bob = 0
turn = 1

while(len(sortedList)):
  if turn % 2 == 1:
    alice += sortedList.pop(0)
  else:
    bob += sortedList.pop(0)
  
  turn += 1

print(alice - bob)

Failing test case input:
2
1 37

Expected output:
36


Actual output:
[37, 1]
36


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

sortedList = sorted(li, reverse=True)

alice = 0
bob = 0
turn = 1

while(len(sortedList)):
  if turn % 2 == 1:
    alice += sortedList.pop(0)
  else:
    bob += sortedList.pop(0)
  
  turn += 1

print(alice - bob)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
B = []
for i in range(0,N,2):
  B.append(A[i])
print(abs(sum(A)-sum(B)*2))


Failing test case input:
4
18 4 1 3

Expected output:
16


Actual output:
12


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
A.sort()
B = []
for i in range(0,N,2):
  B.append(A[i])
print(abs((sum(A)-sum(B))-sum(B)))

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

card_values_sorted = sorted(card_values, reverse=True)
print(card_values_sorted)

Alice_score = 0
Bob_score = 0
for i in range(N):
    if i%2 == 0:
        Alice_score += card_values_sorted[i]
    else:
        Bob_score += card_values_sorted[i]

print(Alice_score - Bob_score)

Failing test case input:
2
5 -2

Expected output:
7


Actual output:
[5, -2]
7


Fixed submission (verdict: Accepted):
N = int(input())
card_values = list(map(int, input().split(" ")))
 
card_values_sorted = sorted(card_values, reverse=True)

Alice_score = 0
Bob_score = 0
for i in range(N):
    if i%2 == 0:
        Alice_score += card_values_sorted[i]
    else:
        Bob_score += card_values_sorted[i]
 
print(Alice_score - Bob_score)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
n = range(N)
list_Alice = [0]
list_Bob = [0]
A.sort()
for i in n:
  if i%2 == 0:
    list_Alice.append(A[i])
  else:
    list_Bob.append(A[i])
print(sum(list_Alice) - sum(list_Bob))

Failing test case input:
2
16 -9

Expected output:
25


Actual output:
-25


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
n = range(N)
list_Alice = [0]
list_Bob = [0]
A.sort(reverse = True)
for i in n:
  if i%2 == 0:
    list_Alice.append(A[i])
  else:
    list_Bob.append(A[i])
print(sum(list_Alice) - sum(list_Bob))
Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
c = 0
N = int(input())
A = list(map(int, input().split(" ")))
A.sort()
for i in range(N):
    if (i+1) % 2 != 0:
        c+=A[i]
    else:
        c-=A[i]
print(c)

Failing test case input:
2
-1 -48

Expected output:
47


Actual output:
-47


Fixed submission (verdict: Accepted):
c = 0
N = int(input())
A = list(map(int, input().split(" ")))
A.sort(reverse=True)
for i in range(N):
    if ((i+1) % 2) != 0:
        c+=A[i]
    else:
        c-=A[i]
print(c)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
A.sort()
print(sum(A[::2]) - sum(A[1::2]))

Failing test case input:
2
-1 45

Expected output:
46


Actual output:
-46


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
A.sort()
A.reverse()
print(sum(A[::2]) - sum(A[1::2]))

Problem: p03434
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from sys import stdin

n = stdin.readline().rstrip()
A = [int(x) for x in stdin.readline().rstrip().split()]

A.sort(reverse=True)

print (A)

N=M=0

for i in range(0,len(A),2):
    N = N + A[i]

for i in range(1, len(A), 2):
    M = M + A[i]

print (N-M)







Failing test case input:
2
-4 30

Expected output:
34


Actual output:
[30, -4]
34


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

n = stdin.readline().rstrip()
A = [int(x) for x in stdin.readline().rstrip().split()]

A.sort(reverse=True)

N=M=0

for i in range(0,len(A),2):
    N = N + A[i]

for i in range(1, len(A), 2):
    M = M + A[i]

print (N-M)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
an=map(int,input().split())
Cards=[]
for a in an:
    Cards.append(int(a))
Cards.sort
AliceCards=Cards[0::2]
BobsCards=Cards[1::2]
print(sum(AliceCards)-sum(BobsCards))



Failing test case input:
4
33 4 1 3

Expected output:
31


Actual output:
27


Fixed submission (verdict: Accepted):
N=int(input())
an=map(int,input().split())
Cards=[]
for a in an:
    Cards.append(int(a))
SortedCards=sorted(Cards,reverse=True)
AliceCards=SortedCards[0::2]
BobsCards=SortedCards[1::2]
print(sum(AliceCards)-sum(BobsCards))

Problem: p03434
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
from math import ceil

n=ni()
a=nl()

sa = sorted(a)[::-1]
print(sum(a[:ceil(n/2)])-sum(a[ceil(n/2):]))


Failing test case input:
2
0 105

Expected output:
105


Actual output:
-105


Fixed submission (verdict: Accepted):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
from math import ceil

n=ni()
a=nl()

sa = sorted(a)[::-1]
aa = []
bb = []
for i in range(n):
  if i%2==0:
    aa.append(sa[i])
  else:
    bb.append(sa[i])

print(sum(aa)-sum(bb))
Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

S=0
N = int(input())
l = map(int, input().split())

l = list(sorted(l))

for i in range(1, N+1):
    print(i)
    if i%2 == 1:
        S+=l[N-i]
        
    else:
        S-=l[N-i]
        
            


print(S)

Failing test case input:
2
0 -24

Expected output:
24


Actual output:
1
2
24


Fixed submission (verdict: Accepted):
S=0
N = int(input())
l = map(int, input().split())

l = list(sorted(l))

for i in range(1, N+1):
    if i%2 == 1:
        S+=l[N-i]
        
    else:
        S-=l[N-i]
        
            


print(S)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

cards = map(int, input().split())

sorted_cards = sorted(cards)

Alice = sum(sorted_cards[0::2])
Bob = sum(sorted_cards[1::2])

print(Alice-Bob)

Failing test case input:
4
47 4 2 5

Expected output:
44


Actual output:
-44


Fixed submission (verdict: Accepted):
def solve():
    N = int(input())

    cards = map(int, input().split())

    sorted_cards = sorted(cards, reverse=True)

    Alice = sum(sorted_cards[0::2])
    Bob = sum(sorted_cards[1::2])

    print(Alice-Bob)


solve()

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = sorted(list(map(int,input().split())),reverse = True)
ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += a[i]
print(ans)

Failing test case input:
2
-1 123

Expected output:
124


Actual output:
123


Fixed submission (verdict: Accepted):
n = int(input())
a = sorted(list(map(int,input().split())),reverse = True)
ans1 = 0
ans2 = 0
for i in range(n):
    if i % 2 == 0:
        ans1 += a[i]
    else:
        ans2 += a[i]
print(ans1-ans2)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ans = sum(a[1:len(a):2]) - sum(a[0:len(a):2])
print(ans)

Failing test case input:
3
3 9 4

Expected output:
8


Actual output:
-8


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
a.reverse()
ans = sum(a[0:len(a):2]) - sum(a[1:len(a):2])
print(ans)

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

n = int(input())
a = list(map(int, input().split()))
alice = 0
bob = 0
sorted_a = sorted(a)

for i in sorted_a:
    alice += sorted_a.pop()
    bob += sorted_a.pop()

print(alice - bob)


Failing test case input:
3
2 7 4

Expected output:
5

Actual output:
3


Fixed submission (verdict: Accepted):

n = int(input())
a = list(map(int, input().split()))
alice = 0
bob = 0
a.sort()

for i in range(len(a)):
    if i % 2 == 0:
        alice += a.pop()
    else:
        bob += a.pop()

print(alice - bob)
Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = sorted(list(map(int, input().split())))
al = 0
bb = 0
for i in range(n):
  if i % 2 == 0:
    al += a[i]
  else:
    bb += a[i]
print(al - bb)

Failing test case input:
2
-23 123

Expected output:
146


Actual output:
-146


Fixed submission (verdict: Accepted):
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
al = 0
bb = 0
for i in range(n):
  if i % 2 == 0:
    al += a[i]
  else:
    bb += a[i]
print(al - bb)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=list(map(int,input().split()))
s.sort()
a=[int(i) for i in s[::-2]]
b=[int(j) for j in s[1::-2]]
print(sum(a)-sum(b))

Failing test case input:
2
-316 115

Expected output:
431


Actual output:
0


Fixed submission (verdict: Accepted):
n=int(input())
s=list(map(int,input().split()))
s.sort(reverse=True)
a=[int(i) for i in s[::2]]
b=[int(j) for j in s[1::2]]
print(sum(a)-sum(b))

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
i = int(input())
a = list(map(int, input().split()))
a.sort
a.reverse
alice = a[0::2]
bob = a[1::2]
print(sum(alice) - sum(bob))


Failing test case input:
2
-43 215

Expected output:
258


Actual output:
-258


Fixed submission (verdict: Accepted):
i = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
alice = a[0::2]
bob = a[1::2]
print(sum(alice) - sum(bob))

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

a = a.split()

alice = 0
bob = 0
ans = 0


for i in range(n):
	if i%2 == 0:
		alice = alice + int(a[i])
	else:
		bob = bob + int(a[i])
	
print(alice - bob)

Failing test case input:
3
3 9 4

Expected output:
8


Actual output:
-2


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

a = a.split()


for i in range(n):
	a[i] = int(a[i])

a	= sorted(a)
a.reverse()

alice = a[0]
bob = 0
for i in range(1, n):
	if i%2 == 0:
		alice = alice + a[i]
	else:
		bob = bob + a[i]
	
print(alice - bob)

Problem: p03434
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
x=0
y=0
for i in range(N):
  if i%2==0:
    x+=i
  else:
    y+=i
print(abs(x-y))


Failing test case input:
2
-1 123

Expected output:
124


Actual output:
1


Fixed submission (verdict: Accepted):
N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
x=0
y=0
for i in range(N):
  if i%2==0:
    x+=a[i]
  else:
    y+=a[i]
print(abs(x-y))
Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = list(map(int , input().split()))
a = list(map(int , input().split()))

a = sorted(a, reverse=True)
print(a)
al = 0
bo = 0
for i, aa in enumerate(a):
    if i %2 == 0:
        al += aa
    else:
        bo += aa
print(al -bo)

Failing test case input:
2
13 -4

Expected output:
17


Actual output:
[13, -4]
17


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

a = sorted(a, reverse=True)
al = 0
bo = 0
for i, aa in enumerate(a):
    if i %2 == 0:
        al += aa
    else:
        bo += aa
print(al -bo)

Problem: p03434
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
s=0
a.reverse()
s=sum(a[:n:2])-sum(a[1:n:2])
print(-s)

Failing test case input:
2
1 70

Expected output:
69


Actual output:
-69


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
s=0
a.sort()
s=sum(a[:n:2])-sum(a[1:n:2])
if s>0:
    print(s)
else:
    print(-s)

Problem: p03434
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
Ali,Bob=0,0
for i in range(0,n-1,1):
    Ali +=a[i]
    Bob +=a[i+1]
print(Ali-Bob)

Failing test case input:
4
139 1 2 5

Expected output:
135


Actual output:
138


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
a.append(0)
Ali,Bob=0,0
for i in range(0,n,2):
    Ali +=a[i]
    Bob +=a[i+1]
print(Ali-Bob)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int( input())
a=list(set([int(j) for j in range(N)]))
print(sum(a[::2])-sum(a[1::2]))

Failing test case input:
4
20 2 0 12

Expected output:
10


Actual output:
-2


Fixed submission (verdict: Accepted):
N=input()
a= sorted([int(j) for j in input().split()],reverse=True)
print(sum(a[::2])-sum(a[1::2]))

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=a[0::2]
print(sum(a)-sum(b)*2)


Failing test case input:
3
3 7 4

Expected output:
6


Actual output:
-6


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
b=a[1::2]
print(sum(a)-sum(b)*2)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
sumA = 0
sumB = 0

for i in range(len(a)):
    if i % 2 == 0:
        sumA += a[i]
    else:
        sumB += a[i]


Failing test case input:
2
-2 38

Expected output:
40


Actual output:

Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
sumA = 0
sumB = 0

for i in range(len(a)):
    if i % 2 == 0:
        sumA += a[i]
    else:
        sumB += a[i]

print(sumA-sumB)
Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [int(x) for x in input().split()]
sortA = sorted(a, reverse=True)
Alice = 0
Bob = 0
print(sortA)
for i in range(len(a)):
    if i % 2 == 0:
        Alice+=sortA[i]
    else:
        Bob+=sortA[i]
    
print(Alice - Bob)

Failing test case input:
2
0 89

Expected output:
89


Actual output:
[89, 0]
89


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(x) for x in input().split()]
sortA = sorted(a, reverse=True)
Alice = 0
Bob = 0
for i in range(len(a)):
    if i % 2 == 0:
        Alice+=sortA[i]
    else:
        Bob+=sortA[i]
    
print(Alice - Bob)

Problem: p03434
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
N = int (input ())
l = input ().split ()
list.sort (l, reverse=True)
a = 0
x = 0
m = math.ceil(N/2)
for i in range (m):
    x += int (l[a])
    a += 2
b = 1
y = 0
for i in range (N-m):
    y += int (l[b])
    b += 2
print (x-y)


Failing test case input:
4
139 1 2 5

Expected output:
135


Actual output:
141


Fixed submission (verdict: Accepted):
N = int (input ())
L = input ().split ()
l = [int(s) for s in L]
list.sort (l, reverse=True)
a = 0
x = 0
y = 0
while True:
    x += int (l[a])
    a += 1
    if a == N:
        break
    y += int (l[a])
    a += 1
    if a == N:
        break
print (x-y)

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


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

cards = sorted(a)
alice = cards[-1::-2]
bob = cards[-2::-2]

print(alice)
print(bob)
ans = sum(alice) - sum(bob)

print(ans)


Failing test case input:
2
0 -196

Expected output:
196


Actual output:
[0]
[-196]
196


Fixed submission (verdict: Accepted):


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

cards = sorted(a)
alice = cards[-1::-2]
bob = cards[-2::-2]

ans = sum(alice) - sum(bob)

print(ans)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
input()
a=sorted(list(map(int,input().split())))
print(sum(a[::2])-sum(a[1::2]))

Failing test case input:
2
5 -2

Expected output:
7


Actual output:
-7


Fixed submission (verdict: Accepted):
input()
a=sorted(list(map(int,input().split())))[::-1]
print(sum(a[::2])-sum(a[1::2]))
Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def draw_max_card(card_list):
    max_card = max(card_list)
    card_list.remove(max_card)
    return max_card

n = int(input())
card_list = list(map(int, input().split(" ")))
points_alice = 0
points_bob  = 0
for count in range(1, n + 1):
    print(count)
    if count % 2 != 0:
        points_alice += draw_max_card(card_list)
    else:
        points_bob += draw_max_card(card_list)


Failing test case input:
2
-1 -196

Expected output:
195


Actual output:
1
2


Fixed submission (verdict: Accepted):
def draw_max_card(card_list):
    max_card = max(card_list)
    card_list.remove(max_card)
    return max_card

n = int(input())
card_list = list(map(int, input().split(" ")))
points_alice = 0
points_bob  = 0
for count in range(1, n + 1):
    if count % 2 != 0:
        points_alice += draw_max_card(card_list)
    else:
        points_bob += draw_max_card(card_list)

print(points_alice - points_bob)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += a[i]
    else:
        ans -= a[i]
ans

Failing test case input:
2
0 43

Expected output:
43


Actual output:

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

Problem: p03434
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = sorted(list(map(int,input().split())),reverse=True)
A = sum(a[::2])
B = sum(a[::2])
print(A - B)

Failing test case input:
2
-15 81

Expected output:
96


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
A = sum(a[::2])
B = sum(a[1::2])
print(A - B)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
alist = input().split()
alist = sorted(alist, reverse=True)
count = 1
alice = 0
bob = 0

for a in alist:
    if count % 2:
        alice += int(a)
    else:
        bob += int(a)
    count+=1
print(alice - bob)

Failing test case input:
4
33 4 1 3

Expected output:
31


Actual output:
-27


Fixed submission (verdict: Accepted):
N = int(input())
alist = input().split()
aint = list(map(int, alist))
aint = sorted(aint, reverse=True)
count = 1
alice = 0
bob = 0

for a in aint:
    if count % 2:
        alice += a
    else:
        bob += a
    count = count + 1
print(alice - bob)

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

input()
data = sorted(map(int, input().split(' ')))


s = 0
for i, n in enumerate(data):
    s = s + int(math.pow((-1),(i%2)))*n
print(s)

Failing test case input:
4
20 18 2 12

Expected output:
12


Actual output:
-12


Fixed submission (verdict: Accepted):
import math

input()
data = sorted(map(int, input().split(' ')), reverse=True)


s = 0
for i, n in enumerate(data):
    s = s + int(math.pow((-1),(i%2)))*n
print(s)
Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
data = [input() for x in range(0, 2, 1)]

cards = [int(x) for x in data[1].split(" ")]


for i in range(0, len(cards), 1):
  
  for j in range(i + 1, len(cards), 1):
    
    if cards[i] > cards[j]:
      tmp1 = cards[i]
      tmp2 = cards[j]
      
      cards[i] = tmp2
      cards[j] = tmp1
      
alice = 0
bob = 0



for i, v in enumerate(cards):
  
  if i %2 == 0:
    alice += v
  else:
    bob += v
    
print(alice - bob)


Failing test case input:
2
0 171

Expected output:
171


Actual output:
-171


Fixed submission (verdict: Accepted):
data = [input() for x in range(0, 2, 1)]

cards = [int(x) for x in data[1].split(" ")]


for i in range(0, len(cards), 1):
  
  for j in range(i + 1, len(cards), 1):
    
    if cards[i] < cards[j]:
      tmp1 = cards[i]
      tmp2 = cards[j]
      
      cards[i] = tmp2
      cards[j] = tmp1
      
alice = 0
bob = 0



for i, v in enumerate(cards):
  
  if i %2 == 0:
    alice += v
  else:
    bob += v
    
print(alice - bob)

Problem: p03434
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
alice = 0
bob = 0
A.sort(reverse=True)
print(A)
for i in range(N):
    if i%2 == 0:
        alice += A.pop(0)
    else:
        bob += A.pop(0)
print(alice-bob)

Failing test case input:
2
-1 123

Expected output:
124


Actual output:
[123, -1]
124


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
alice = 0
bob = 0
A.sort(reverse=True)
for i in range(N):
    if i%2 == 0:
        alice += A.pop(0)
    else:
        bob += A.pop(0)
print(alice-bob)

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

n = input()
n = int(n)


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

print(nums)

nums.sort(reverse=True)

print(nums)

i = 0
Alis = 0
Bob = 0

for i in range(0,n):
    if i % 2 == 0:
        Alis = Alis + nums[i]
    else:
        Bob = Bob + nums[i]

print(Alis-Bob)





Failing test case input:
2
1 51

Expected output:
50


Actual output:
[1, 51]
[51, 1]
50


Fixed submission (verdict: Accepted):

n = input()
n = int(n)


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



nums.sort(reverse=True)



i = 0
Alis = 0
Bob = 0

for i in range(0,n):
    if i % 2 == 0:
        Alis = Alis + nums[i]
    else:
        Bob = Bob + nums[i]

print(Alis-Bob)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = input()
li = list(map(int,input().split()))
li.sort(reverse=True)
Alice = 0
Bob = 0
count = 1
for i in li:
    if count % 2:
        Alice += i
        count += 1
        print(count,Alice)
    else:
        Bob += i
        count += 1
        print(count,Bob)
print(Alice - Bob)



Failing test case input:
2
16 -9

Expected output:
25


Actual output:
2 16
3 -9
25


Fixed submission (verdict: Accepted):
n = input()
li = list(map(int,input().split()))
li.sort(reverse=True)
Alice = 0
Bob = 0
count = 1
for i in li:
    if count % 2:
        Alice += i
        count += 1
    else:
        Bob += i
        count += 1
print(Alice - Bob)
Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
a.sort()
cnt = 0
sum1 = 0
sum2 = 0
for i in range(n):
	if cnt % 2 == 0:
		sum1 += a[i]
	else:
		sum2 += a[i]
print(sum1 - sum2)

Failing test case input:
4
23 4 0 12

Expected output:
15


Actual output:
39


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
cnt = 0
sum1 = 0
sum2 = 0
for i in range(n):
	if cnt % 2 == 0:
		sum1 += a[i]
	else:
		sum2 += a[i]
	cnt += 1
print(sum1 - sum2)

Problem: p03434
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
X = int(input())
A = list(map(int, input().split()))
list.sort(A, reverse=True)
B=0
C=0
ans = 0
for i,j in enumerate(A):
    print(i)
    if (i+1)%2 != 0:
        B+=j
    else :
        C+=j
ans = B-C
print(ans)
    




Failing test case input:
2
-65 215

Expected output:
280


Actual output:
0
1
280


Fixed submission (verdict: Accepted):
X = int(input())
A = list(map(int, input().split()))
list.sort(A, reverse=True)
B=0
C=0
ans = 0
for i,j in enumerate(A):
    if (i+1)%2 != 0:
        B+=j
    else :
        C+=j
ans = B-C
print(ans)

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
A.sort(key=lambda x: -x)
print(sum(A[0::2]))

Failing test case input:
2
-1 -84

Expected output:
83


Actual output:
-1


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
A.sort(key=lambda x: -x)
print(sum(A[0::2])-sum(A[1::2]))

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

def main():
    n = int(input())
    cards = list(map(int, input().split()))
    alice_point = 0
    bob_point = 0

    cards.sort()
    for i in range(0, n):
        if i%2 == 0:
            alice_point += cards[i]
        else:
            bob_point += cards[i]

    print(alice_point - bob_point)

if __name__ == '__main__':
    main()

Failing test case input:
2
0 -74

Expected output:
74


Actual output:
-74


Fixed submission (verdict: Accepted):
import math
def main():
    n = int(input())
    cards = list(map(int, input().split()))
    alice_point = 0
    bob_point = 0

    cards.sort()
    for i in range(0, n):
        if i%2 == 0:
            alice_point += cards[i]
        else:
            bob_point += cards[i]

    print(abs(alice_point - bob_point))

if __name__ == '__main__':
    main()

Problem: p03434
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
a = [int(i) for i in input().split()] 
a.sort()
p1=a[0:N:2]
p2=a[1:N:2]
sum1=0
sum2=0
for i in p1:
	sum1+=i
for i in p2:
	sum2+=i

print(sum1-sum2)

Failing test case input:
2
1 -27

Expected output:
28


Actual output:
-28


Fixed submission (verdict: Accepted):
N=int(input())
a = [int(i) for i in input().split()] 
a.sort(reverse=True)
p1=a[0:N:2]
p2=a[1:N:2]
sum1=0
sum2=0
for i in p1:
	sum1+=i
for i in p2:
	sum2+=i

print(sum1-sum2)