Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
K, A, B = map(int, input().split())

need_turns = A + 1 + 1  # 交換に必要なターン
first_need_turns = need_turns - 1

if A + 2 > B or K < first_need_turns:  # 交換せずにビスケットを叩き続ける方が得
    print(1 + K)
    exit()

ans = B  # 一度交換した
K -= (need_turns - 1)

# print("{}, {}".format(K, ans))

while K >= 0:
    if ans >= A and K >= 2:
        ans += (B - A) * K / 2
        K = 0
    else:
        ans += 1
        K -= 1

print(ans)


Fixed submission:
# https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_a

N, K = map(int, input().split())

if K <= (N + 1) / 2:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
K, A, B = map(int, input().split())
 
need_turns = A + 1 + 1  # 交換に必要なターン
first_need_turns = need_turns - 1
 
if A + 2 > B or K < first_need_turns:  # 交換せずにビスケットを叩き続ける方が得
    print(1 + K)
    exit()
 
ans = B  # 一度交換した
K -= (need_turns - 1)
 
# print("{}, {}".format(K, ans))
 
while K > 0:
    if ans >= A and K >= 2:
        ans += (B - A) * K / 2
        K = K % 2
    else:
        ans += 1
        K -= 1
 
print(ans)

Fixed submission:
# https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_a

N, K = map(int, input().split())

if K <= (N + 1) / 2:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
K, A, B = map(int, input().split())

need_turns = A + 1 + 1  # 交換に必要なターン
first_need_turns = need_turns - 1

if A + 2 > B or K < first_need_turns:  # 交換せずにビスケットを叩き続ける方が得
    print(1 + K)
    exit()

ans = B  # 一度交換した
K -= (need_turns - 1)

# print("{}, {}".format(K, ans))

while K > 0:
    if ans >= A and K >= 2:
        ans += (B - A) * K / 2
        K = K % 2
    else:
        ans += 1
        K -= 1

print(ans)


Fixed submission:
# https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_a

N, K = map(int, input().split())

if K <= (N + 1) / 2:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
# https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_c


K, A, B = map(int, input().split())

need_turns = A + 1 + 1  # 交換に必要なターン
first_need_turns = need_turns - 1

if A + 2 > B or K < first_need_turns:  # 交換せずにビスケットを叩き続ける方が得
    print(1 + K)
    exit()

ans = B  # 一度交換した
K -= (need_turns - 1)

# print("{}, {}".format(K, ans))

while K > 0:
    if ans >= A and K >= 2:
        ans += (B - A) * K / 2
        K = 0
    else:
        ans += 1
        K -= 1

print(ans)

Fixed submission:
# https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_a

N, K = map(int, input().split())

if K <= (N + 1) / 2:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):

K, A, B = map(int, input().split())

dp = [[-1 for _ in range(2)] for _ in range(K + 1)]

dp[0][0] = 1

for k in range(K):
    if dp[k][1] >= 0:
        dp[k + 1][0] = max(dp[k][0] + 1, dp[k][1] + B)
    else:
        dp[k + 1][0] = dp[k][0] + 1
    if dp[k][0] >= A:
        dp[k + 1][1] = max(dp[k][0] - A, dp[k][1] + 1)
    else:
        if dp[k][1] >= 0:
            dp[k + 1][1] = dp[k][1] + 1

# for p in dp:
#     print(p)

print(max(dp[K][0], dp[K][1]))

Fixed submission:
K, A, B = map(int, input().split())

need_turns = A + 1 + 1  # 交換に必要なターン
first_need_turns = need_turns - 1

if A + 2 > B or K < first_need_turns:  # 交換せずにビスケットを叩き続ける方が得
    print(1 + K)
    exit()

ans = B  # 一度交換した
K -= (need_turns - 1)

# print("{}, {}".format(K, ans))

while K > 0:
    if ans >= A and K >= 2:
        ans += (B - A) * int(K / 2)
        K = K % 2
    else:
        ans += 1
        K -= 1

print(ans)
Buggy python submission (verdict: Runtime Error):
# https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d

L = int(input())

A = [int(input()) for _ in range(L)]

INF = int(1e15)
dp = [[INF] * (L + 1) for _ in range(5)]

for i in range(4):
    dp[i][0] = 0

for i in range(n):
    dp[0][i + 1] = dp[0][i] + A[i]  # 全部取り除く
    dp[1][i + 1] = min(dp[j][i] for j in range(2)) + (A[i] % 2 if A[i] != 0 else 2)
    dp[2][i + 1] = min(dp[j][i] for j in range(3)) + (1 if A[i] % 2 == 0 else 0)
    dp[3][i + 1] = min(dp[j][i] for j in range(4)) + (A[i] % 2 if A[i] != 0 else 2)
    dp[4][i + 1] = min(dp[j][i] for j in range(5)) + A[i]  # 全部取り除く


print(min(dp[i][L] for i in range(1, 5)))


Fixed submission:
# https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d

L = int(input())

A = [int(input()) for _ in range(L)]

INF = int(1e15)
dp = [[INF] * (L + 1) for _ in range(5)]

for i in range(4):
    dp[i][0] = 0

for i in range(L):
    dp[0][i + 1] = dp[0][i] + A[i]  # 全部取り除く
    dp[1][i + 1] = min(dp[j][i] for j in range(2)) + (A[i] % 2 if A[i] != 0 else 2)
    dp[2][i + 1] = min(dp[j][i] for j in range(3)) + (1 if A[i] % 2 == 0 else 0)
    dp[3][i + 1] = min(dp[j][i] for j in range(4)) + (A[i] % 2 if A[i] != 0 else 2)
    dp[4][i + 1] = min(dp[j][i] for j in range(5)) + A[i]  # 全部取り除く


print(min(dp[i][L] for i in range(1, 5)))

Buggy python submission (verdict: Runtime Error):
# https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d

L = int(input())

A = [int(input()) for _ in range(L)]

INF = int(1e15)
dp = [[INF] * (L + 1)] for _ in range(5)]

for i in range(4):
    dp[i][0] = 0

for i in range(n):
    dp[0][i + 1] = dp[0][i] + A[i]  # 全部取り除く
    dp[1][i + 1] = min(dp[j][i] for j in range(2)) + (A[i] % 2 if A[i] != 0 else 2)
    dp[2][i + 1] = min(dp[j][i] for j in range(3)) + (1 if A[i] % 2 == 0 else 0)
    dp[3][i + 1] = min(dp[j][i] for j in range(4)) + (A[i] % 2 if A[i] != 0 else 2)
    dp[4][i + 1] = min(dp[j][i] for j in range(5)) + A[i]  # 全部取り除く


print(min(dp[i][L] for i in range(1, 5)))


Fixed submission:
# https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d

L = int(input())

A = [int(input()) for _ in range(L)]

INF = int(1e15)
dp = [[INF] * (L + 1) for _ in range(5)]

for i in range(4):
    dp[i][0] = 0

for i in range(L):
    dp[0][i + 1] = dp[0][i] + A[i]  # 全部取り除く
    dp[1][i + 1] = min(dp[j][i] for j in range(2)) + (A[i] % 2 if A[i] != 0 else 2)
    dp[2][i + 1] = min(dp[j][i] for j in range(3)) + (1 if A[i] % 2 == 0 else 0)
    dp[3][i + 1] = min(dp[j][i] for j in range(4)) + (A[i] % 2 if A[i] != 0 else 2)
    dp[4][i + 1] = min(dp[j][i] for j in range(5)) + A[i]  # 全部取り除く


print(min(dp[i][L] for i in range(1, 5)))
Buggy python submission (verdict: Runtime Error):
# https://atcoder.jp/contests/keyence2019/tasks/keyence2019_b

import re

S = input()

if "keyence" == S:
    print("YES")
else:
    patterns = ["^keyence*", "^k*eyence$", "^ke*yence$", "^key*ence$", "^keye*nce$", "^keyen*ce$", "^keyenc*e$", "*keyence$"]

    matched = False
    for pattern in patterns:
        matchOB = re.search(pattern, S)
        if matchOB:
            matched = True
            break
    if matched:
        print("YES")
    else:
        print("NO")




Fixed submission:
# https://atcoder.jp/contests/keyence2019/tasks/keyence2019_b

import re

S = input()

if "keyence" == S:
    print("YES")
else:
    patterns = ["^keyence(.*)", "^k(.*)eyence$", "^ke(.*)yence$", "^key(.*)ence$", "^keye(.*)nce$", "^keyen(.*)ce$", "^keyenc(.*)e$", "keyence$"]

    matched = False
    for pattern in patterns:
        matchOB = re.search(pattern, S)
        if matchOB:
            matched = True
            break
    if matched:
        print("YES")
    else:
        print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/agc030/tasks/agc030_a

def main():
    A, B, C = map(int, input().split())
    deli = 0
    while A > 0 and C > 0:
        deli += 1
        A -= 1
        C -= 1
    # 美味しくないクッキーがなくなった
    while B > 0 and C > 0:
        deli += 2
        B -= 1
        C -= 1

    if C > 0:
        deli += 1

    deli += B
    print(deli)


if __name__ == '__main__':
    main()



Fixed submission:
# https://atcoder.jp/contests/agc030/tasks/agc030_a

def main():
    A, B, C = map(int, input().split())
    deli = 0
    if A > 0 and C > 0:
        eat = min(A, C)
        deli += eat
        A -= eat
        C -= eat

    # 美味しくないクッキーがなくなった, お腹壊してない
    if B > 0 and C > 0:
        eat = min(B, C)
        deli += eat * 2
        B -= eat
        C -= eat
    # お腹壊してない

    if C > 0:
        deli += 1

    deli += B
    print(deli)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# https://beta.atcoder.jp/contests/agc029/tasks/agc029_a


def main():
    S = list(input())
    count = 0
    while len(S) > 0:
        if S.count("B") == 0:
            break
        if S[-1] == "B":
            S = S[0:-1]
            continue

        for i in range(len(S)-1, -1, -1):
            if S[i] == "B":
                count += len(S) - 1 - i
                # print("{}, {}".format(len(S) - 1, i))
                S[i] = "W"
                S = S[0:-1]
                break

    print(count)


if __name__ == '__main__':
    main()


Fixed submission:
# https://beta.atcoder.jp/contests/agc029/tasks/agc029_a


def main():
    S = list(input())
    count = 0
    w_offset = 0
    for i in range(len(S)):
        if S[i] == "W":
            count += i - w_offset
            w_offset += 1

    print(count)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/abc113/tasks/abc113_c

N, M = map(int, input().split())
c_l = [list(map(int, input().split())) for _ in range(M)]

dict = {}

for c in c_l:
    if c[0] in dict:
        dict[c[0]].append(c[1])
    else:
        dict[c[0]] = [c[1]]


for k, v in dict.items():
    v.sort()

# print(dict)

for c in c_l:
    idx = dict[c[0]].index(c[1]) + 1
    print("{:06}{:06}".format(c[0], idx))






Fixed submission:
# https://atcoder.jp/contests/abc113/tasks/abc113_c

N, M = map(int, input().split())
c_l = [[int(i) for i in input().split()] + [j] for j in range(M)]

# print(c_l)
c_l.sort(key=lambda x: x[1])

counter = [0] * (N+1)
for c in c_l:
    p = c[0]
    counter[p] += 1
    c.append("{:06}{:06}".format(c[0], counter[p]))

c_l.sort(key=lambda x: x[2])

for c in c_l:
    print(c[3])
Buggy python submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc109/tasks/abc109_c

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)


def main():
    N, X = map(int, input().split())

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

    ans = abs(X - xl[0])
    for i in range(1, len(xl)):
        ans = gcd(max(ans, abs(X - xl[i])), min(ans, abs(X - xl[i])))

    print(ans)


main()
# https://atcoder.jp/contests/abc109/tasks/abc109_c

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)


def main():
    N, X = map(int, input().split())

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

    ans = abs(X - xl[0])
    for i in range(1, len(xl)):
        ans = gcd(max(ans, abs(X - xl[i])), min(ans, abs(X - xl[i])))

    print(ans)


main()


Fixed submission:
# https://atcoder.jp/contests/abc109/tasks/abc109_c

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)


def main():
    N, X = map(int, input().split())

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

    ans = abs(X - xl[0])
    for i in range(1, len(xl)):
        ans = gcd(max(ans, abs(X - xl[i])), min(ans, abs(X - xl[i])))

    print(ans)


main()
Buggy python submission (verdict: Time Limit Exceeded):
# https://abc100.contest.atcoder.jp/tasks/abc100_c


def get_primes_dic(v):
    m = {}
    i = 2

    while i <= v:
        while v % i == 0:
            if i in m:
                m[i] += 1
            else:
                m[i] = 1
            v //= i

        i += 1

    return m


N = int(input())

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

count = 0

for i in a:
    dic = get_primes_dic(i)
    if 2 in dic:
        count += dic[2]

print(count)



Fixed submission:
# https://abc100.contest.atcoder.jp/tasks/abc100_c


def even_count(v):
    if v % 2 != 0:
        return 0
    else:
        r = 0
        while v % (2 ** 20) == 0:
            r += 20
            v //= (2 ** 20)

        while v % (2 ** 10) == 0:
            r += 10
            v //= (2 ** 10)

        while v % 2 == 0:
            r += 1
            v //= 2

    return r


N = int(input())

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

count = 0

for i in a:
    count += even_count(i)

print(count)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())


def get_height(n):
    return n * (n + 1) // 2


h = get_height(b - a)

print(i - b)




Fixed submission:
a, b = map(int, input().split())


def get_height(n):
    return n * (n + 1) // 2


h = get_height(b - a)

print(h - b)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

match = 0
for l in range(len(A)):
    base = A[l]
    match += 1
    for r in range(l+1, len(A)):
        ando = base & A[r]
        if ando == 0:
            match += 1
        else:
            break
        base |= A[r]

print(match)



Fixed submission:
A, B = map(int, input().split())

print(max(A + B, A - B, A * B))
Buggy python submission (verdict: Time Limit Exceeded):
# https://agc024.contest.atcoder.jp/tasks/agc024_a


A, B, C, K = map(int, input().split())

for i in range(K):
    A, B, C = B + C, A + C, A + B

ans = A - B

if ans > 10 ** 18:
    print('Unfair')
else:
    print(ans)

Fixed submission:
# https://agc024.contest.atcoder.jp/tasks/agc024_a


A, B, C, K = map(int, input().split())

if K < 2:
    for i in range(K):
        A, B, C = B + C, A + C, A + B
    ans = A - B

    if ans > 10 ** 18:
        print('Unfair')
    else:
        print(ans)
else:
    if K % 2 == 0:
        ans = A - B
    else:
        ans = -A + B

    if ans > 10 ** 18:
        print('Unfair')
    else:
        print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c, d = mao(int, input().split())

if abs(a - c) <= d:
    print('Yes')
elif abs(a - b) <= d and abs(b - c) <= d:
    print('Yes')
else:
    print('No')

Fixed submission:
a, b, c, d = map(int, input().split())

if abs(a - c) <= d:
    print('Yes')
elif abs(a - b) <= d and abs(b - c) <= d:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
# https://abc096.contest.atcoder.jp/tasks/abc096_d

import itertools


def is_prime(n):
    if n < 2: return False
    if n == 2: return True
    if n % 2 == 0: return False

    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1

    return True


N = int(input())


l = []

n = 2
while len(l) < N * 3:
    if is_prime(n):
        l.append(n)
    n += 1


for a in itertools.combinations(l, N):
    # print(a)
    is_ok = True
    for c in itertools.combinations(a, 5):
        if is_prime(sum(c)):
            # print(str(c) + ' is prime = ' + str(sum(c)))
            is_ok = False
            break
    if is_ok:
        print(' '.join(map(str, a)))
        break



Fixed submission:



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

# print(a)
# print(b)

m = a - 1
n = 1 if b >= a else 0

print(str(m + n))
Buggy python submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc096/tasks/abc096_c

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

# 隣に # が一つ以上あるかどうか
def has_neighbor(y, x):
    dhs = [1, -1, 0, 0]
    dws = [0, 0, 1, -1]
    for dh, dw in zip(dhs, dws):
        if S[y + dh][x + dw] == "#":
            return True
    return False


for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            if not has_neighbor(h, w):
                print("No")
                exit()

print("Yes")




Fixed submission:
# https://abc096.contest.atcoder.jp/tasks/abc096_c

neighbor_i = [-1, 0, 1, 0]
neighbor_j = [0, -1, 0, 1]

H, W = map(int, input().split())


def can_draw(l, target_i, target_j):
    for i, j in zip(neighbor_i, neighbor_j):
        if target_i + i < 0 or target_j < 0:
            continue
        if target_i + i >= H or target_j + j >= W:
            continue
        if l[target_i + i][target_j + j] == '#':
            return True

    return False


data = []
for i in range(H):
    raw = list(str(input()))
    data.append(raw)


# print(data)


ok = True
for i in range(H):
    for j in range(W):
        if data[i][j] == '#':
            if not can_draw(data, i, j):
                ok = False
                break
    if not ok:
        break

if ok:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
# https://abc096.contest.atcoder.jp/tasks/abc096_d

import itertools


def is_prime(n):
    if n < 2: return False
    if n == 2: return True
    if n % 2 == 0: return False

    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1

    return True


N = int(input())


l = []

n = 2
while len(l) < N * 10:
    if is_prime(n):
        l.append(n)
    n += 1


for a in itertools.combinations(l, N):
    if 17 in a:
        continue
    # print(a)
    is_ok = True
    for c in itertools.combinations(a, 5):
        if is_prime(sum(c)):
            # print(str(c) + ' is prime = ' + str(sum(c)))
            is_ok = False
            break
    if is_ok:
        print(' '.join(map(str, a)))
        break



Fixed submission:

def is_prime(n):
    if n < 2: return False
    if n == 2: return True
    if n % 2 == 0: return False

    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1

    return True


N = int(input())


l = []

n = 2
while len(l) < N:
    if is_prime(n) and n % 5 == 1:
        l.append(n)
    n += 1

print(' '.join(map(str, l)))

Buggy python submission (verdict: Time Limit Exceeded):
# https://abc096.contest.atcoder.jp/tasks/abc096_d

import itertools


def is_prime(n):
    if n < 2: return False
    if n == 2: return True
    if n % 2 == 0: return False

    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1

    return True


N = int(input())


l = []

n = 2
while len(l) < N * 10:
    if is_prime(n):
        l.append(n)
    n += 1


for a in itertools.combinations(l, N):
    # print(a)
    is_ok = True
    for c in itertools.combinations(a, 5):
        if is_prime(sum(c)):
            # print(str(c) + ' is prime = ' + str(sum(c)))
            is_ok = False
            break
    if is_ok:
        print(' '.join(map(str, a)))
        break



Fixed submission:

def is_prime(n):
    if n < 2: return False
    if n == 2: return True
    if n % 2 == 0: return False

    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1

    return True


N = int(input())


l = []

n = 2
while len(l) < N:
    if is_prime(n) and n % 5 == 1:
        l.append(n)
    n += 1

print(' '.join(map(str, l)))
Buggy python submission (verdict: Time Limit Exceeded):
# https://agc023.contest.atcoder.jp/tasks/agc023_a

N = list(map(int, input()))[0]

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

# print(N)
#
# print(li)


counter = []

found = 0

for i in li:
    for j in range(len(counter)):
        counter[j] += i
        if counter[j] == 0:
            found += 1
    counter.append(i)
    if i == 0:
        found += 1

print(found)



Fixed submission:
# https://agc023.contest.atcoder.jp/tasks/agc023_a

import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def convert_map(l):
    d = {}
    for i in l:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    return d


N = list(map(int, input()))[0]

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

counter = [0]
for i in li:
    counter.append(counter[-1] + i)

# print(counter)

d = convert_map(counter)

# print(d)

patterns = 0
for key, value in d.items():
    if value >= 2:
        patterns += combinations_count(value, 2)

print(patterns)
Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/abc094/tasks/arc095_a

import itertools
import collections
import bisect
import copy

def main():
    N = int(input())
    X = list(map(int, input().split()))
    for i in range(N):
        temp_X = copy.copy(X)
        del temp_X[i]
        temp_X.sort()
        # print(temp_X)
        print(temp_X[(len(temp_X)+1)//2 - 1])


if __name__ == '__main__':
    main()
    

Fixed submission:
# https://atcoder.jp/contests/abc094/tasks/arc095_a

import itertools
import collections
import bisect
import copy

def main():
    N = int(input())
    X = list(map(int, input().split()))
    Y = sorted(X)
    for i in range(N):
        pos = bisect.bisect(Y, X[i])
        if pos <= N//2:
            print(Y[N//2])
        else:
            print(Y[N // 2 - 1])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc088/tasks/abc088_b

import itertools
import collections
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    a_sum = sum([a for a in range(A,2)])
    b_sum = sum([a for a in range(1, A,2)])
    print(a_sum - b_sum)


if __name__ == '__main__':
    main()


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

a.sort(reverse=True)

alice_score = 0
bob_score = 0

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

print(alice_score - bob_score)

Buggy python submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc088/tasks/abc088_b?lang=ja

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

a.sort(reverse=True)

alice_score = 0
bob_score = 0

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

print(alice_score - bob_score)
# https://atcoder.jp/contests/abc088/tasks/abc088_b?lang=ja

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

a.sort(reverse=True)

alice_score = 0
bob_score = 0

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

print(alice_score - bob_score)


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

a.sort(reverse=True)

alice_score = 0
bob_score = 0

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

print(alice_score - bob_score)
Buggy python submission (verdict: Runtime Error):
def is_reachable(src, dst):
    can_go = True
    dt = dst[0] - src[0]
    dist = abs(dst[1] - src[1]) + abs(dst[2] - src[2])
    if dt < dist:
        can_go = False
    if dt % 2 != dist % 2:
        can_go = False
    return can_go


route = [list(map(int, input().split())) for _ in range(N)]
route.insert(0, [0, 0, 0])

# print(route)

reachable = True

for i in range(N):
    source = route[i]
    destination = route[i + 1]
    if not is_reachable(source, destination):
        reachable = False

print(reachable)


Fixed submission:
# https://atcoder.jp/contests/abc086/tasks/arc089_a

N = int(input())


def is_reachable(src, dst):
    can_go = True
    dt = dst[0] - src[0]
    dist = abs(dst[1] - src[1]) + abs(dst[2] - src[2])
    if dt < dist:
        can_go = False
    if dt % 2 != dist % 2:
        can_go = False
    return can_go


route = [list(map(int, input().split())) for _ in range(N)]
route.insert(0, [0, 0, 0])

# print(route)

reachable = True

for i in range(N):
    source = route[i]
    destination = route[i + 1]
    if not is_reachable(source, destination):
        reachable = False

if reachable:
    print("Yes")
else:
    print("No")