Harryxun/stf_run huggingface dataset:
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [list(input().split()) for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    x,y,a,b,c=map(int,input().split())
    p=sorted(list(map(int,input().split())), reverse=True)
    q=sorted(list(map(int,input().split())), reverse=True)
    r=sorted(list(map(int,input().split())), reverse=True)

    ptn1 = 0
    ptn2 = 0
    ptn1 = sum(q[:y])
    ptn2 = sum(p[:x])
    idxr = 0
    idxp = 0
    for i in range(x):
        if r[idxr] > p[idxp]:
            ptn1 += r[idxr]
            idxr += 1
        else:
            ptn1 += p[idxp]
            idxq += 1
    idxr = 0
    idxq = 0
    for i in range(y):
        if r[idxr] > q[idxq]:
            ptn2 += r[idxr]
            idxr += 1
        else:
            ptn2 += q[idxq]
            idxq += 1

    print(max(ptn1,ptn2))
if __name__ == '__main__':
    main()



### FIXED CODE ###

def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [list(input().split()) for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    x,y,a,b,c=map(int,input().split())
    p=sorted(list(map(int,input().split())), reverse=True)[:x]
    q=sorted(list(map(int,input().split())), reverse=True)[:y]
    r=sorted(list(map(int,input().split())), reverse=True)
    print(sum(sorted((p+q+r), reverse=True)[:x+y]))

if __name__ == '__main__':
    main()
N = int(input())
ans_lis = [[0　for k in range(9)] for i in range(9)]
for i in range(1,N+1):
  t = str(i)
  mae = int(t[0])
  ushiro = int(t[-1])
  ans_lis[mae-1][ushiro-1] += 1
ans = 0
for i in range(9):
  for j in range(9):
    ans += ans_lis[i][j] * ans_lis[j][i]
print(ans)


### FIXED CODE ###

N = int(input())
ans_lis = [[0] * 9 for i in range(9)]
for i in range(1,N+1):
  t = str(i)
  mae = int(t[0])
  ushiro = int(t[-1])
  if ushiro == 0:
    continue
  ans_lis[mae-1][ushiro-1] += 1
ans = 0
for i in range(9):
  for j in range(9):
    ans += ans_lis[i][j] * ans_lis[j][i]
print(ans)
x = int(input())

a = x / 60

hour = a / 60

minute = x - (hour * 60)

second = x - 60 * (hour + minute)

print(str(hour:minute:second))

### FIXED CODE ###

S = int(input())

h = S // 3600

m = S % 3600 // 60

s = S % 3600 % 60

print(str(h) + ':' + str(m) + ':' + str(s))
N = int(input())
S = input()
A = [1 if(S[i]=='E') else 0 for i in range(N)]
for i in range(1,N):
  ans = min(ans, i - sum(A[:i])+ sum(A[i+1:]))
ans = min(ans, sum(A[1:]), N-sum(A[:]))
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
A = [1 if S[0]=='E' else 0]
for i in range(1,N):
  A.append(1 if S[i]=='E' else 0)
  A[i] += A[i-1]
ans = min(N-1-A[N-2], A[N-1]-A[0])
for i in range(1,N):
  ans = min(ans, i-A[i-1]+A[N-1]-A[i])
print(ans)
w, h, x, y = [int(s) for s in input().split(" ")]

a = w * h

print("%f %d" % (a * 0.5, int(w // 2 == x and h // 2 == y))

### FIXED CODE ###

w, h, x, y = [int(s) for s in input().split(" ")]

a = w * h

print("%lf %d" % (a * 0.5, int(divmod(w, 2) == (x, 0) and divmod(h, 2) == (y, 0))))
import numpy as np

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

A = []
B = []

for i in range(H):
    A.append(list(map(int, input().split())))

for i in range(H):
    B.append(list(map(int, input().split())))

dp = False * np.ones([H, W, 80**3], dtype=bool)
dp[0][0][abs(A[0][0] - B[0][0])] = True

for i in range(H):
    for j in range(W):
        diff = A[i][j] - B[i][j]
        if i > 0:
            idx = np.where(dp[i - 1][j][:])[0]
            dp[i][j][np.abs(idx - diff)] = True
            dp[i][j][np.abs(idx + diff)] = True

        if j > 0:
            idx = np.where(dp[i][j - 1][:])[0]
            dp[i][j][np.abs(idx - diff)] = True
            dp[i][j][np.abs(idx + diff)] = True

print(dp[H - 1][W - 1][:].nonzero()[0].min())


### FIXED CODE ###

import numpy as np

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

A = []
B = []

max_bias = 80
bias = max_bias * (H + W - 1) + 1

for i in range(H):
    A.append(list(map(int, input().split())))

for i in range(H):
    B.append(list(map(int, input().split())))

A = np.array(A, dtype=np.int)
B = np.array(B, dtype=np.int)
D = np.abs(A - B)

dp = np.zeros([H, W, bias * 2 + 1], dtype=bool)
dp[0][0][bias - D[0][0]] = True
dp[0][0][bias + D[0][0]] = True

for i in range(H):
    for j in range(W):
        diff = D[i][j]
        
        if i > 0:
            dp[i, j, diff:] |= dp[i - 1, j, :bias * 2 + 1 - diff]
            dp[i, j, : bias * 2 + 1 - diff] |= dp[i - 1, j, diff:]

        if j > 0:
            dp[i, j, diff:] |= dp[i, j - 1, :bias * 2 + 1 - diff]
            dp[i, j, : bias * 2 + 1 - diff] |= dp[i, j - 1, diff:]

idx = dp[H - 1][W - 1][:].nonzero()[0]
print(np.abs(idx - bias).min())
A = int(input())
B = int(input())
C = int(input())
K = int(input())

all_number = 0

if K >= A:
    N = K - A
    all_number = 1*A

    if N == 0:
        print(all_number)

    elif N >= B:
        N = N - B
        all_number = all_number - 1*N
        print(all_number)

    elif N < B:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)

### FIXED CODE ###

A, B, C, K = map(int,input().split())
if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(2*A + B - K)
n,k=map(int,input().split())
string = ''
for i in range(n):
    a,b=(input().split())
    string += a*int(b)
print(sorted(string)[k-1])

### FIXED CODE ###

a = [int(num) for num in input().split()]
print('Yes' if a[0]<=a[2]<=a[1] else 'No')
from itertools import accumulate
n,x = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
ruiseki = list(accumulate(l))
i = 0
while ruiseki[i] <= x:
    i += 1
print(i+1)


### FIXED CODE ###

from itertools import accumulate
n,x = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
ruiseki = list(accumulate(l))
ruiseki.insert(0,0)
i = 0
#print(ruiseki)
while i < len(ruiseki) and ruiseki[i] <= x:
    i += 1
print(i)
import sys

input = sys.stdin.readline

n = int(input())
ls = [list(map(int, input().split())) for _ in range(n - 1)]

es = [[] for _ in range(n + 1)]
for a, b, c in ls:
    es[a].append((b, c))
    es[b].append((a, c))
ds = [0] * (n + 1)


def dfs(cur, prev, c):
    ds[cur] = ds[prev] + c
    for e, c in es[cur]:
        if e != prev:
            dfs(e, cur, c)


q, k = map(int, input().split())
qs = [list(map(int, input().split())) for _ in range(q)]

dfs(k, k, 0)
for x, y in qs:
    print(ds[x] + ds[y])

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**6)

input = sys.stdin.readline

n = int(input())
ls = [list(map(int, input().split())) for _ in range(n - 1)]

es = [[] for _ in range(n + 1)]
for a, b, c in ls:
    es[a].append((b, c))
    es[b].append((a, c))
ds = [0] * (n + 1)


def dfs(cur, prev, c):
    ds[cur] = ds[prev] + c
    for e, c in es[cur]:
        if e != prev:
            dfs(e, cur, c)


q, k = map(int, input().split())
qs = [list(map(int, input().split())) for _ in range(q)]

dfs(k, k, 0)
for x, y in qs:
    print(ds[x] + ds[y])
k = int(input())
sunuke_list = [1,2,3,4,5,6,7,8]
def s(n):
    n_charlist = list(str(n))
    return sum(list(map(int, n_charlist)))
def combine_int(i,n):
    i_charlist = list(str(i))
    n_charlist = ['9'] * n
    ret_charlist = i_charlist + n_charlist
    ret_str = ''.join(ret_charlist)
    return int(ret_str)
for n in range(1,13):
    i = n-1
    while((i+1)/(s(i)+9*n) <= (i+2)/(s(i+1)+9*n)):
        sunuke_list.append(combine_int(i,n))
        i += 1
for i in range(k):
    print(sunuke_list[i])


### FIXED CODE ###

k = int(input())
sunuke_list = [1,2,3,4,5,6,7,8]
def s(n):
    n_charlist = list(str(n))
    return sum(list(map(int, n_charlist)))
def combine_int(i,n):
    i_charlist = list(str(i))
    n_charlist = ['9'] * n
    ret_charlist = i_charlist + n_charlist
    ret_str = ''.join(ret_charlist)
    return int(ret_str)
for n in range(1,14):
    if n >= 12:
        i = n-2
    else:
        i = n-1
    while((i+1)/(s(i)+9*n) <= (i+2)/(s(i+1)+9*n)):
        sunuke_list.append(combine_int(i,n))
        i += 1
for i in range(k):
    print(sunuke_list[i])
from itertools import combinations_with_replacement

n,m,q = map(int, input().split())
l = list(list(map(int, input().split())) for i in range(n))
ans = 0

for l2 in combinations_with_replacement(range(1,m+1),n):
    total = 0
    for i in range(q):
        if l2[l[i][1] - 1] - l2[l[i][0] - 1] == l[i][2]:
            total += l[i][3]
    ans = max(ans, total)
print(ans)

### FIXED CODE ###

from itertools import combinations_with_replacement as c
N, M, Q = map(int, input().split())
l1 = list(list(map(int, input().split())) for _ in range(Q))
ans = 0

for l2 in c(range(1, M + 1), N):
    total = 0
    for i in range(Q):
        if l2[l1[i][1] - 1] - l2[l1[i][0] - 1] == l1[i][2]:
            total += l1[i][3]
    ans = max(ans, total)

print(ans)
if len(set(S)) != 2:
  print("NO")
else:
  print("YES")

### FIXED CODE ###

S = input()
if len(set(S)) != 2:
  print("No")
else:
  print("Yes")
S= input().split() 
 

a=0
 
sum=0
for i in S[0]:
	
	sum=sum+int(i)
 
 
 
anser=int(S[0])%sum
 
 
 
 
 
 
if anser == 0:
	print("Yes")
 
else : print("No")

### FIXED CODE ###

S= map(str, input().split()) 
b=list(S)

a=0


for i in range(len(b[0])):
	

	if b[0][i] is "+":
		a+=1

	if b[0][i] is "-":
		a-=1




print(a)
N = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
max = l[N-1]
tc = N
st = [j+1 for j in range(N-1)]
for i in range(N-2):
    if l[i]+l[i+1] > max:
        k = N-i-1
        ans += ((k-1)*k*(k+1))//6
        break
    for j in range(i+1,N-1):
        if j == tc:
            ans += tp
            break
        s = l[i]+l[j]
        if s <= l[j+1]:
            continue
        if s > max:
            tc = j 
            tp = (N-j-1) * (N-j) //2 #これをiの中でできないか
            ans += tp
            break
        start = st[j]
        if s <= l[start+1]:
            ans += start-j-1
            continue
        end = N
        while start != end:
            center = (start + end)//2
            if s <= l[center]:
                end = center
            else:
                start = center + 1
        st[j] = end
        ans += end-j-1
print(ans)

### FIXED CODE ###

N = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
max = l[N-1]
tc = N
st = [j+1 for j in range(N-1)]
for i in range(N-2):
    if l[i]+l[i+1] > max:
        k = N-i-1
        ans += ((k-1)*k*(k+1))//6
        break
    for j in range(i+1,N-1):
        if j == tc:
            ans += tp
            break
        s = l[i]+l[j]
        if s <= l[j+1]:
            continue
        if s > max:
            tc = j 
            tp = (N-j-1) * (N-j) //2 #これをiの中でできないか
            ans += tp
            break
        start = st[j]
        if s <= l[start]:
            ans += start-j-1
            continue
        end = N
        while start != end:
            center = (start + end)//2
            if s <= l[center]:
                end = center
            else:
                start = center + 1
        st[j] = end
        ans += end-j-1
print(ans)
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
q = int(input())
cnt_A = dict(Counter(A))
for i in range(q):
    ans = 0
    b, c = map(int, input().split())
    if cnt_A[b] > 0:
        m = cnt_A[b]
        cnt_A[b] = 0
        if c not in cnt_A:
            cnt_A[c] = m
        else:
            cnt_A[c] += m
    ans = sum([k * v for k, v in cnt_A.items()])
    print(ans)

### FIXED CODE ###

from collections import Counter

n = int(input())
A = list(map(int, input().split()))
q = int(input())
cnt_A = dict(Counter(A))
ans = sum(A)
for i in range(q):
    b, c = map(int, input().split())
    if b in cnt_A and cnt_A[b] > 0:
        count = cnt_A[b]
        cnt_A[b] = 0
        if c not in cnt_A:
            cnt_A[c] = count
        else:
            cnt_A[c] += count
        ans += ((c - b) * count)
    print(ans)
S = input()

ACGT = ["A","C","T","G"]
ctr = 0
ctrs = []
for c in S:
  if c in ACGT:
    ctr += 1
  else:
    ctrs.append(ctr)
    ctr = 0

print(max(ctrs))

### FIXED CODE ###

S = input()
L = len(S)
ACGT = ["A","C","T","G"]
ctr = 0
ctrs = [0]
for l in range(L):
  if S[l] in ACGT:
    ctr += 1
    if l==L-1:
      ctrs.append(ctr)
  else:
    ctrs.append(ctr)
    ctr = 0
 
print(max(ctrs))
N=int(input())
ans=0

for i in range(1,n):
  if len(str(i)) % 2 == 1:
      ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0

for i in range(1, n + 1):
  if len(str(i)) % 2 == 1:
    ans += 1

print(ans)
n=int(input())
s=[]
for i in range(0,n):
    s.append(int(input()))
c=0
max=0
pos=0
for i in range(n):
    c=0
    for j in range(i,n-1):
        if(s[j]>s[j+1]):
            c+=1
        else:
            break
    if(c>max):
        max=c
        pos=i+1
    if(max>(n-i-1)):
        break
print(pos)


### FIXED CODE ###

n = int(input())
x = input().split()
y = [0]
c = 0
for i in range(n-1):
  if int(x[i]) >= int(x[i+1]):
    c = c + 1
  else:
    y.append(c)
    c = 0
y.append(c)
print(max(y))
n = int(input())
list = list(map(int,input().split()))
min_ = min(list)
max_ = max(list)
num=[]
for a in range(min_,max_):
  _ = []
  for b in range(len(list)):
    _.append((a - list[b])**2)
  num.append(sum(_))
if n == 1:
  print(0)
  exit()
print(min(num))

### FIXED CODE ###

n = int(input())
list_ = list(map(int,input().split()))
min_ = min(list_)
max_ = max(list_)
num=[]
for a in range(min_,max_):
  _ = []
  for b in range(len(list_)):
    _.append((a - list_[b])**2)
  num.append(sum(_))
if len(list(set(list_))) == 1:
  print(0)
  exit()
print(min(num))
N, M = map(int, input().split())
L1, R1 = map(int, input().split())
flag = 0
def find_key(L1,R1,L2,R2):
  if R1 < L2 or R2 < L1:
    return(False)
  else:
    a = [R1,L1,R2,L2]
    a.sort()
    return(a[1],a[2])

for i in range(M - 1):
  L,R = map(int, input().split())
  if find_key(L1,R1,L,R) != False:
    L1,R1 = find_key(L1,R1,L,R)
  else:
    flag = 1
    print(0)
    break
if flag = 0:
  print(R1-L1+1)

### FIXED CODE ###

A,B = map(int,input().split())
print(B if A >= 13 else 0 if A  <= 5 else B//2)
import math
from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = Counter(A)
    sum_ = sum([math.factorial(i,2) for i in count.values()])

    for i in range(len(A)):
        remain = A[:i] + A[i+1:]
        took_count = count[A[i]]
        sub = took_count - 1
        print(int(sum_ - sub))

if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = Counter(A)
    sum_ = sum([v*(v-1)/2 for v in count.values()])

    for i in range(len(A)):
        took_count = count[A[i]]
        sub = took_count - 1
        print(int(sum_ - sub))

if __name__ == '__main__':
    main()
import sys
sys.setrecursionlimit(100001)

N, M = [int(n) for n in input().split()]
S = input()

ans = []

def rest(l):
    s = M
    while s > 0:
        if s >= l:
            ans.append(l)
            return True
        if S[l-s] == "1":
            if s == 1:
                return -1
            s -= 1
            continue
        l -= s
        if rest(l) == -1:
            s -= 1
        else:
            ans.append(s)
            return True
    return -1

rest(N)

if len(ans) == 0:
    print(-1)
else:
    print(" ".join([str(n) for n in ans]))

### FIXED CODE ###

import sys
sys.setrecursionlimit(200001)

N, M = [int(n) for n in input().split()]
S = input()

p1 = False
x1 = 0
m1 = N
c1 = 0
for n in S:
    if n == "1":
        if p1:
            c1 += 1
        else:
            c1 = 1
            p1 = True
    else:
        p1 = False
        if c1 > 0:
            if c1 > x1:
                x1 = c1
            if c1 < m1:
                m1 = c1
           
def rest(l, ans):
    s = M
    while s > 0:
        if s >= l:
            ans.append(l)
            return ans
        if S[l-s] == "1":
            if s == 1:
                return -1
            s -= 1
            continue
        l -= s
        if rest(l, ans) == -1:
            s -= 1
        else:
            ans.append(s)
            return ans
    return -1

if x1 > M - 1:
    ans = -1
else:
    ans = rest(N, [])

if ans == -1:
    print(-1)
else:
    print(" ".join([str(n) for n in ans]))
A. B = map(int,input().split())
if A <= B*2:
    print(0)
else:
    print(A-2*B)

### FIXED CODE ###

A, B = map(int,input().split())
if A <= B*2:
    print(0)
else:
    print(A-2*B)
s = int(input())

for i in range(1,4):
    if s[0] == s[i]:
        for j in range(2,4):
            if s[1] == s[j]
    else:
        print("No") 
        exit()
    print("Yes")

### FIXED CODE ###

s = input()
s_list = list(s)
s_list.sort()

if s_list[0] == s_list[1] and s_list[2] == s_list[3] and s_list[0] != s_list[2]:
    print("Yes")
else:
    print("No")
n = int(input())
memo = [-1] * (n + 1)
def dp(n):
    if n == 0:
        return 0
    if memo[n] != -1:
        return memo[n]
    res = n
    for i in range(7):
        if n >= 6 ** i:
            res = min(res, dp(n - 6 ** i) + 1)
    for j in range(6):
        if n >= 9 ** j:
            res = min(res, dp(n - 9 ** j) + 1)
    memo[n] = res
    return memo[n]

print(dp(n))

### FIXED CODE ###

n = int(input())
dp = [n] * (n + 1)
dp[0] = 0
a = [1, 6**1, 6**2, 6**3, 6**4, 6**5, 6**6, 9**1, 9**2, 9**3, 9**4, 9**5]
for i in range(1, n + 1):
    for j in a:
        if i - j >= 0:
            dp[i] = min(dp[i], dp[i - j] + 1)
print(dp[n])
n = int(input())

city_list = []
point_list = []
#tmp_list = []
for i in range(n):
    tmp = list(input().split())
    city_list.append(tmp[0])
    point_list.append(int(tmp[1]))
    #tmp_list.append(tmp)

indices = [*range(len(city_list))]
sorted_indices = sorted(indices, key=lambda i: city_list[i])
sorted_city = [city_list[i] for i in sorted_indices]

#print(sorted_city)
#print(sorted_indices)

tmp_list = []
tmp_indices_list = []
ans_indices_list = []
for j in range(n):
    if j == 0:
        tmp_list.append(point_list[int(sorted_indices[j])]) # 同一cityのpointを追加していく
        tmp_indices_list.append(int(sorted_indices[j])) # 同一cityのindicesを追加していく
    else:
        if sorted_city[j] == sorted_city[j-1]:
            tmp_list.append(point_list[int(sorted_indices[j])]) # 同一cityのpointを追加していく
            tmp_indices_list.append(int(sorted_indices[j])) # 同一cityのindicesを追加していく

            if j == n-1:
                indices = [*range(len(tmp_list))]
                sorted_tmp_indices = sorted(indices, key=lambda i: -tmp_list[i])
                sorted_tmp_point = [tmp_list[i] for i in sorted_tmp_indices]
                #print(sorted_tmp_indices)

                for k in sorted_tmp_indices:
                    ans_indices_list.append(tmp_indices_list[k])

        elif sorted_city[j] != sorted_city[j-1]:
            #print(tmp_list)
            indices = [*range(len(tmp_list))]
            sorted_tmp_indices = sorted(indices, key=lambda i: -tmp_list[i])
            sorted_tmp_point = [tmp_list[i] for i in sorted_tmp_indices]
            #print(sorted_tmp_indices)

            for k in sorted_tmp_indices:
                ans_indices_list.append(tmp_indices_list[k])

            if j == n-1:
                ans_indices_list.append(int(sorted_indices[j]))

            tmp_list = []
            tmp_indices_list = []
            tmp_list.append(point_list[int(sorted_indices[j])]) # 同一cityのpointを追加していく
            tmp_indices_list.append(int(sorted_indices[j])) # 同一cityのindicesを追加していく

#print(ans_indices_list)

for ans in ans_indices_list:
    print(ans+1)

### FIXED CODE ###

n = int(input())

s_list = []
cnt = 0
for j in range(n):
    i,p = input().split()
    s_list.append([i,int(p),j])

s_list.sort(key=lambda x:(x[0],-x[1]))
 
for k in s_list:
  print(k[2]+1)
import fractions import *
N,X0=map(int,input().split())
X=list(map(int,input().split()))
ans=abs(X[0]-X0)
for i in range(1,N):
    ans=gcd(ans,abs(X[i]-X0))
print(ans)

### FIXED CODE ###

import fractions
N,X0=map(int,input().split())
X=list(map(int,input().split()))
X_=[]
ans=abs(X[0]-X0)
for i in range(1,N):
    ans=fractions.gcd(ans,abs(X[i]-X0))
print(ans)
-*- using:utf-8 -*-

def count_negative(n,a):
    count = 0
    for i in range(n):
        if a[i] == 0:
            return 0
        elif a[i] < 0:
            count += 1
    return count

def num_of_min(n,a):
    minimum = max(a)
    count = 0
    tmp = 0
    for i in range(n):
        tmp = abs(a[i])
        if tmp < minimum:
            minimum = tmp
            count = i
        else:
            pass
    return count

def flipping(n,a):
    nc = count_negative(n,a)
    total = 0
    count = 0
    if nc % 2 == 0:
        for i in range(n):
            total += abs(a[i])
    else:
        count = num_of_min(n,a)
        target = a.pop(count)

        k = n - 1
        for i in range(k):
            total += abs(a[i])
        else:
            total += target*(-1)

    return total

if __name__ == '__main__':
    n = int(raw_input())
    a = map(int,raw_input().split())
    gt = flipping(n,a)
    print("%d" %gt)

### FIXED CODE ###

#-*- using:utf-8 -*-

def count_negative(n,a):
    count = 0
    for i in range(n):
        if a[i] == 0:
            return 0
        elif a[i] < 0:
            count += 1
    return count

def num_of_min(n,a):
    minimum = sum(map(abs,a))
    
    count = 0    
    tmp = 0
    for i in range(n):
        tmp = abs(a[i])
        if tmp < minimum:
            minimum = tmp
            count = i
        else:
            pass
    return count

def flipping(n,a):
    nc = count_negative(n,a)
    total = 0
    count = 0
    if nc % 2 == 0:
        total = sum(map(abs,a))
    else:
        count = num_of_min(n,a)
        target = a.pop(count)
        
        total = sum(map(abs,a))
        if target > 0:
            total += target*(-1)
        else:
            total += target

    return total

if __name__ == '__main__':
    n = int(raw_input())
    a = map(int,raw_input().split())
    gt = flipping(n,a)
    print("%d" %gt)
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
bb=set(a)
for i in range(n-1):
    tm=a[i+1]-a[i]
    bb.add(tm)
cv=list(bb)
cv.sort()

if k in cv:
    print("POSSIBLE")
    exit()

if max(cv)<k:
    print("IMPOSSIBLE")
    exit()

if n==1:
    if a[0]==k:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    exit()

xc=0
cb=False
if cv[0]==1:
    xc=cv[1]
else:
    xc=cv[0]

for i in range(len(cv)):
    if cv[i]%xc!=0:
        cb=True

if k<=max(cv):
    if cb:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    exit()
    
print("IMPOSSIBLE")

### FIXED CODE ###

import fractions
n,k=map(int,input().split())
a=list(map(int,input().split()))
if max(a)<k:
    print("IMPOSSIBLE")
    exit()
t=a[0]
if n!=1:
    for i in range(1,n):
        t=fractions.gcd(t,a[i])

if k%t==0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
import numpy
import bisect

N,M,K = map(int, input().split())
ans = 0
A = list(map(int,input().split()))
B = list(map(int,input().split()))

A = numpy.cumsum(numpy.array(A))
A = list(A)
A.insert(0, 0)
B = numpy.cumsum(numpy.array(B))
B = list(B)
B.insert(0, 0)
ans = 0

for i in range(N+1):
    if K - A[i] < 0:
        break
    b = bisect.bisect(B, K - A[i])
    ans = max(ans, i+b-1)

print(ans)

### FIXED CODE ###

import numpy
import bisect

N,M,K = map(int, input().split())
ans = 0
A = list(map(int,input().split()))
B = list(map(int,input().split()))

A = numpy.cumsum(numpy.array(A))
A = list(A)
A.insert(0, 0)
B = numpy.cumsum(numpy.array(B))
B = list(B)
B.insert(0, 0)
ans = 0

for i in range(N+1):
    if K - A[i] < 0:
        break
    b = bisect.bisect(B, K - A[i])
    ans = max(ans, i+b-1)

print(ans)