peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n, k = list(map(int, input().split()))

ans = 0

for i in range(1, n+1):
    count = 0
    p = i
    while p<k:
        p = p*2
        count +=1
    ans += (1/n)*((1/2)**count)

print(ans)
# Judge status: Accepted
N = list(input())
N = list(map(int, N))
N = [0] + N
n = len(N)

answer = 0
for i in range(n - 1, -1, -1):
    j = N[i]
    if j == 10:
        N[i - 1] += 1
        continue
    if j == 5 and N[i - 1] >= 5:
        N[i - 1] += 1
        answer += 5
    elif j <= 5:
        answer += j
    else:
        N[i - 1] += 1
        answer += 10 - j

print(answer)
# Judge status: Accepted
mod = [0]
pw = 1
for c in input()[::-1]:
    mod.append((int(c) * pw + mod[-1]) % 2019)
    pw = pw * 10 % 2019
from collections import *
print(sum(v * (v - 1) // 2 for v in Counter(mod).values()))
# Judge status: Accepted
N = int(input())
A = [0] * N
B = [0] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())

A.sort()
B.sort()

if N % 2 == 1:
    mid = N // 2
    print(B[mid] - A[mid] +1)
else:
    mid1 = N // 2
    mid2 = mid1 -1
    smallest = A[mid1] + A[mid2]
    largest = B[mid1] + B[mid2]
    print(largest - smallest + 1)
# Judge status: Accepted
x,y = map(int, input().split())
print(x+int(y/2))
# Judge status: Wrong Answer
N, K = map(int, input().split())
H = list(map(int, input().split()))
H = H[:-K]
print(sum(H))
# Judge status: Accepted
x,y,z = [int(a) for a in input().split()]

if ((z-(x-y))<0):
      print(0)
else:
      print(z-(x-y))
# Judge status: Accepted
A,B = map(int,input().split())
print(max(A*2-1,B*2-1,A+B))
# Judge status: Accepted
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

N = int(input())
total = 0

for n in range(1, N + 1, 2):
    if len(divisor(n)) == 8:
        total += 1

print(total)
# Judge status: Accepted
a,b,c=map(int,input().split())

x=4*a*b-(c-a-b)**2
if a+b-c>0:
  print("No")
elif x<0:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a, b = map(int, input().split())

cnt = 0
for i in range(a, b+1, 1):
    i = str(i)
    if i[0] == i[4] and i[1] == i[3]:
        cnt += 1
    else:
        continue

print(cnt)
# Judge status: Accepted
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    S = int(input())
    mod = 10**9 + 7
    
    dp = [0] * (S + 4)
    dp[0] = 1
    dp[3] = 1
    for i in range(4, S + 1):
        for k in range(i - 2):
            dp[i] += dp[k]
    
    print(dp[S] % mod)


if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
a = map(int, input().split())
b = list(map(int, input().split()))
c = list(map(int, input().split()))

sum = 0

prev = -1

for i in a:
    sum += b[i-1]
    if prev and prev == i-1:
        sum += c[prev-1]
    prev = i

print(sum)
# Judge status: Wrong Answer
import collections
strlist = []
N = int(input())
for i in range(N):
    strlist.append(str(input()))
c = collections.Counter(strlist)
p = max(c.values())
for i in c.most_common():
    if i[1] == p:
        print(i[0])
# Judge status: Accepted
from bisect import bisect_left, bisect_right

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

L.sort()
len_L = len(L)

ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        ans += bisect_left(L, L[i] + L[j]) - j - 1
print(ans)
# Judge status: Accepted
n, k = list(map(int, input().split()))

sums = 0
for i in range(k, n+2):
	sums += i*(n + 1 - i) + 1
	
print (sums % (10**9 + 7))
# Judge status: Accepted
a, b = map(int, input().split())
print(int(a*b))
# Judge status: Accepted
s = input()
if "RRR" in s:
    print(3)
elif "RR" in s:
    print(2)
elif "R" in s:
    print(1)
else:
    print(0)
# Judge status: Wrong Answer
import numpy as np
H,N = map(int,input().split())
A = list(map(int,input().split()))
if np.sum(A)>=H:
    print("yes")
else:
    print("no")
# Judge status: Accepted
A, B, C, K = map(int, input().split())
# threshold = 10 ** 18
res = (-1) ** K * (A - B)
# if abs(res) > threshold:
    # print('Unfair')
# else:
    # print(res)
print(res)
# Judge status: Wrong Answer
x,y,z = map(int,input().split())

ans = int(x/(y+z))
if x%(y+z) <= z:
    ans -= 1
print(ans,x%(y+z))
# Judge status: Wrong Answer
a = input().isupper
if a == 1:
  print("A")
else:
  print("a")
# Judge status: Accepted
def main():
    x = input()
    s, t = 0, 0
    for i in x:
        if i == "S":
            s += 1
        else:
            if s:
                s -= 1
            else:
                t += 1
    print(s + t)

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
t=int(input())
if(t>30):
	print("Yes")
else:
	print("No")
# Judge status: Wrong Answer
N = str(input())
if N=="SAT":
  print("1")
elif N=="FRY":
  print("2")
elif N=="THU":
  print("3")
elif N=="WED":
  print("4")
elif N=="TUE":
  print("5")
elif N=="MON":
  print("6")
else:
  print("7")
# Judge status: Accepted
import collections

n = int(input())
s = []
for i in range(n):
    si = input()
    s.append(si)
    
s.sort()
counted = collections.Counter(s)
M = max(counted.values())

ms = [k for k, v in counted.items() if v == M]
ms.sort()

for i in range(len(ms)):
    print(ms[i])
# Judge status: Accepted
c = input()
v = ["a", "i", "u", "e", "o"]
if c in v:
    print("vowel")
else:
    print("consonant")
# Judge status: Wrong Answer
n = input()
a = list(map(int, input().split()))

cnt = 0
pre = 0

for i in a:
  if i > pre*2:
    print(-1)
    exit()
  
  if i == 0:
    pre = (pre==0)*2 + pre*2
    cnt += pre
  else:
    pre = (pre - i)*2
    cnt += i

print(cnt)
# Judge status: Accepted
n,l = map(int,input().split())
aji = []
count = 0
for i in range(1,n+1):
    aji.append([abs(l+i-1),l+i-1])
    count += l+i-1
aji.sort()

count -= aji[0][1]
print(count)
# Judge status: Wrong Answer
K=int(input())
if K//2==0:
    print((K//2)**2)
else:
    print((K//2)*(K//2+1))
# Judge status: Wrong Answer
n = int(input())

p = [int(i) for i in input().split()]
ans = 0

for i in range(n):
  if i == 0 or i == n-1:
    continue
  x = p[i-1:i+2]
  y = sorted(x)

  if print(y[1]) == p[i]:
    ans +=1
    
print(ans)
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))

c = 0
s = []
l.sort()

for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if (l[i] + l[j] > l[k]) and l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                c = c + 1

print(c)
# Judge status: Accepted
N = int(input())

if N % 10 == 9 or N // 10 == 9:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
l=[int(x) for x in input().split()]

a=max(l)
if (sum(l)-a)==a:
	print("Yes")
else:
	print("No")
# Judge status: Accepted
import math
h=int(input())
w=int(input())
n=int(input())
a=max(h,w)
print(math.ceil(n/a))
# Judge status: Accepted
N,K=map(int,input().split(' '))
R,S,P=map(int,input().split(' '))
h = {'r':P,'p':S,'s':R}
T=input()
hands=[1]*N
ans = 0
for i in range(N-K):
    if T[i] != T[i+K] and hands[i]:
        ans += h[T[i]]
    elif hands[i]:
        hands[i+K]=0
        ans +=h[T[i]]
for i in range(N-K,N):
    if hands[i]:
        ans += h[T[i]]
print(ans)
# Judge status: Wrong Answer
from itertools import product
N=int(input())
s="abcdefghij"
for i in range(N):
  c=s[:i+1]
  for p in product(c,repeat=N-i):
    print(c+"".join(p))
# Judge status: Accepted
N = int(input())
A = [int(i) for i in input().split() ]

count=0
for i in range(min(A)):
   for ii in A:
      if ii % 2 != 0 :
         print(count)
         exit()

   count += 1
   A = [ii//2 for ii in A ]
# Judge status: Accepted
a,b=input().split()
c=int(a+b)



def heihou(n):
    a=int(n**0.5)
    if n==a**2:
        return True
    return False

if heihou(c):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import sys

input = sys.stdin.readline

def main():
    ans = 'Yes'
    w = input()
    s = set(w)
    for i in s:
        if w.count(i)%2 != 0:
            ans = 'No'
            break
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
def P_Number(a , b):

    ans = 0

    for i in range(a, b + 1):
        rev = str(i)
        if str(i) == rev[::-1]:
            ans += 1

    return ans

def main():
    a , b = map(int , input().split())
    print(P_Number(a , b))


if __name__ == '__main__':
    main()
# Judge status: Accepted
#B
n = int(input())
p = list(map(int,input().split()))

p_sort = sorted(p)
cnt = 0
for i in range(n):
    if p[i] != p_sort[i]:
        cnt += 1
        
if cnt <= 2:
    print('YES')
    
else:
    print('NO')
# Judge status: Accepted
a, b = list(map(int, input().split()))
result = 0
for _ in range(2):
  if a >= b:
    result += a
    a -= 1
  else:
    result += b
    b -= 1
print(result)
# Judge status: Wrong Answer
x = int(input())

m = 360 // x
print(m)
# Judge status: Wrong Answer
n = int(input())
h = list(map(int, input().split()))
max_ = h[0]

for i in range(1, n - 1):
    max_ = max(max_, h[i])
    if max_ - h[i] >= 2:
        print("No")
        exit()
print("Yes")
# Judge status: Wrong Answer
N = int(input())
S = input()
num = 0
for i in range(0, N - 2):
  for j in range(i + 1, N - 1):
    for k in range(j + 1, N):
      if (j-i)!=(k-j) and S[i] != S[j] and S[j] != S[k] and S[j] != S[k]:
        num += 1
# Judge status: Accepted
a, b, c, d = map(int, input().split())
X = [a, b]
Y = [c, d]
lst = [[x*y for x in X] for y in Y]
mylist=[]
for i in lst:
    for I in i:
        mylist.append(I)

mylist.sort()
print(mylist[-1])
# Judge status: Wrong Answer
s=input()
cnt=0
for i in range(len(s)-3):
  for j in range(i+3,len(s)):
    t=int(s[i:j+1])
    if t%2019==0:
      cnt+=1
print(cnt)
# Judge status: Wrong Answer
box = [1, 2, 3]
box[0], box[1] = box[1], box[0]
box[0], box[2] = box[2], box[0]
print(box)
# Judge status: Accepted
n, r = map(int, input().split())
if n < 10:
    res = 100 * (10 -n) + r
else:
    res = r
print(res)
# Judge status: Wrong Answer
import itertools

l = [int(input()) for i in range(5)]
l2 = list(itertools.permutations(l))
min = float("INF")
for i in range(120):
    ans = 0
    for j in range(4):
        if l2[i][j] % 10 == 0:
            ans += l2[i][j]
        else:
            ans += (l2[i][j] // 10 + 1) * 10
    ans += l2[i][4]
    if min > ans:
        min = ans
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = map(int, input().split())
count = 0
for a in A:
    if a%2==0:
        count+=1
    else:
        print(count)
        break
# Judge status: Accepted
#!/usr/bin/env python3
from functools import reduce

x, y = map(int, input().split())

mod = 10**9 + 7


def cmb(n, r, m):
    def mul(a, b):
        return a * b % m

    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return (over * pow(under, m - 2, m))%m


r = abs(x - y)
l = (min(x, y) - r) // 3
r += l
if l*2+r*1 in (x,y) and l >= 0:
    print(cmb(r + l, l, mod))
else:
    print(0)
# Judge status: Accepted
def resolve():
    n=int(input())
    x = [0] * n
    y = [0] * n
    ans=0
    t=1
    for i in range(1,n):
        t*=i
    for i in range(n):
        x[i], y[i] = map(int, input().split())
    for i in range(n):
        for j in range(i+1,n):
            ans+=((x[i]-x[j])**2+(y[i]-y[j])**2)**0.5
    print(2*ans/n)
resolve()
# Judge status: Wrong Answer
S = input()

if S == 'SAT':
    print(1)
elif S == 'FRI':
    print(2)
elif S == 'THU':
    print(3)
elif S == 'WED':
    print(4)
elif S == 'TUE':
    print(5)
else:
    print(6)
# Judge status: Accepted
D,N = map(int,input().split())

if N != 100:
    print(N*pow(100,D))
else:
    print(101*pow(100,D))
# Judge status: Accepted
n = int(input())

total = []
for i in range(1, n+1, 2):
  cnt = 0
  for j in range(1, i+1, 2):
    
    if i%j == 0:
      cnt += 1
    
    if cnt == 8:
      total.append(i)
      
    

print(len(total))
# Judge status: Wrong Answer
k = int(input())
s = input()

if len(s) <= k:
	print(s)
else:
 	print(s[0:(k-1)])
# Judge status: Wrong Answer
import math
H,S = input().split()
H1 = int(H)
S1 = int(S) 
N = 0
i=1
N = math.floor(H1/S1)
print(N+1)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if a + b >= 10:
    print("error")
else:
    print(a + b)
# Judge status: Accepted
n = int(input())
csf = [[int(i) for i in input().split()] for _ in range(n - 1)]


def get(i):
    ans = 0
    for c, s, f in csf[i:]:
        ans = max(ans, s)
        ans = (ans + f - 1) // f * f
        ans += c
    return ans


for i in range(n):
    print(get(i))
# Judge status: Accepted
from math import gcd

k = int(input())
res = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        x = gcd(a, b)
        res += sum(gcd(x, c) for c in range(1, k + 1))

print(res)
# Judge status: Wrong Answer
a=input()
s=input()
a=int(a)
if a>=3200:
    print(a)
    print(s)
elif a<3200:
    print('red')
# Judge status: Accepted
N, K, Q = map(int, input().split())

scores = [K-Q] * (N + 1)

for i in range(Q):
    a = int(input())
    scores[a] += 1

for i in range(1, N+1):
    if scores[i] <= 0:
        print('No')
    else:
        print('Yes')
# Judge status: Wrong Answer
p = []
for i in range(5):
    p.append(int(input()))

k = int(input())
for i in range(5):
    for j in range(4-i):
        if p[i] - p[j] >k:
            print(":(")
            exit()
print("Yay!")
# Judge status: Wrong Answer
N = input()
lis = input().split(" ")
cnt = 1
i = 0
for i in range(int(N)):
    for j in range(i-1,-1,-1):
        if int(lis[i])>int(lis[j]):
            break
        else:
            cnt +=1
        break
print(cnt)
# Judge status: Accepted
N=int(input())
A=[]
B=[]
for _ in range(N):
  a, b=map(int, input().split())
  tmpa=a%b
  A.append(tmpa)
  B.append(b)
ans=0
for i in range(N-1, -1, -1):
  tmp=B[i]-(A[i]+ans)%B[i]
  if tmp==B[i]:
    tmp=0
  ans+=tmp
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
s = input()

h=0
for i in range(n-1):
  if s[i]==s[i+1]:
    h+=1
  else:
    if s[i]==s[0] and k>0:
      if s[0] in s[i+1:]:
        h+=2
        k-=1
      else:
        h+=1
        k-=1
print(h)
# Judge status: Accepted
def is_palindromic(n):
    tmp = list(str(n))
    return tmp == tmp[::-1]


A, B = map(int, input().split())
count = 0
for i in range(A, B + 1):
    if is_palindromic(i):
        count += 1
print(count)
# Judge status: Accepted
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def main(X):
  if is_prime(X) == True:
    print(X)
  else:
    return main(X+1)

if __name__ == '__main__':
  X = int(input())
  main(X)
# Judge status: Wrong Answer
print("Yes" if input()==input()[::-1] else "No" )
# Judge status: Wrong Answer
Q, H, S, D = list(map(int, input().split()))
Q *= 8
H *= 4
S *= 2
A = min(Q, H, S, D)
N = int(input())

if N%2 == 0:
    print(int(A * N/2))
else:
  B = min(Q, H, S)
  print(int(B/2 + A * (N-1)/2))
# Judge status: Wrong Answer
import math

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

C = list(set(A))
M = len(C)
t = []
anst = 0
for i in range(M):
  t.append(A.count(C[i]))
  temp = A.count(C[i])
  if temp >=2:
    anst += math.factorial(temp)/(math.factorial(temp-2)*2)

#print(t)
#print(anst)
#print(jisyo[1])
for i in range(N):
  print(t[C.index(A[i])])
  print(int(anst-t[C.index(A[i])]+1))
# Judge status: Wrong Answer
X, Y, A, B, C = map(int, input().split())
P = sorted([int(i) for i in input().split()], reverse=True)
Q = sorted([int(i) for i in input().split()], reverse=True)
R = sorted([int(i) for i in input().split()])


S = sorted(P[:X]+Q[:Y]+R, reverse=True)
ans = sum(S[:X+Y])
# Judge status: Accepted
N,K= map(int,input().split())
H = list(map(int,input().split()))
H.sort()
s = 0
for i in range(N-K):
  s += H[i]
print(s)
# Judge status: Accepted
n,k=map(int,input().split())
num=[list(map(int,input().split())) for i in range(n)]
num.sort(key=lambda s:s[0])
for i in range(n):
    a,b=num[i][0],num[i][1]
    if k-b>0:
        k-=b
    else:
        print(a)
        break
# Judge status: Wrong Answer
n,k,s=map(int,input().split())
ans=0
n_max=10**5
ans=[0]*n
detarame=10**5-1
ans = [s]*k +[s-1]*(n-k)
print(ans)
# Judge status: Accepted
n, a, b = map(int, input().split())
count = 0

def fun(x):
  y = 0
  while(x > 0):
    y = y + (x%10)
    x = x//10
  return y

for i in range(n):
  sum = fun(i+1)
  if a <= sum <= b:
    count = count + (i+1)

print(count)
# Judge status: Accepted
import sys
mina=10**10
def waru(a,b):
  if a%b==0:
    return a//b
  else:
    return (a//b)+1
N,H=map(int,input().split())
A=list()
B=list()
for i in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
ma=max(A)
ind=A.index(ma)
B=[i for i in B if i>ma]
B=sorted(B,reverse=True)
cou=1
s=0
for i in range(len(B)):
  s+=B[i]
  if H<=s:
    print(i+1)
    sys.exit()
H=H-s
print(len(B)+waru(H,ma))
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

L, R, d = map(int, input().split())

print(int(R/d)-int(L/d))
# Judge status: Accepted
w, h, x, y = map(int, input().split())

scale = (w * h) / 2


if x == w/2 and y == h/2:
  print('{0:.9f} 1'.format(scale))
else:
  print('{0:.9f} 0'.format(scale))
# Judge status: Wrong Answer
a,b,c = map(int, input().split())
print((max(a,b,c)*3 - (a+b+c))//2)
# Judge status: Wrong Answer
n,m = map(int,input().split())
n=n*(n-1)
m=m*(m-1)
print(n/2+m/2)
# Judge status: Wrong Answer
n = int(input())
A =[0]*n
B = list(map(int, input().split()))

for i in range(n-1):
    if len(B) == 1:
        print(2*B[i])
        exit()
    elif B[i] <= B[i-1]: 
        A[i] = B[i]
        A[i+1] = B[i]
    else:
        A[i+1] = B[i]
print(sum(A))
# Judge status: Wrong Answer
N=int(input())
s=str(input())
t=str(input())
c=0
S=list(s)
T=list(t)
for i in range(N):
    if S[N-i-1]==T[i]:
        c+=1
print(2*N-c)
# Judge status: Wrong Answer
# coding: UTF-8

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

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

for i in range(0, N, 2):
    sum_a += a[i]
for i in range(1, N, 2):
    sum_b += a[i]

print(sum_a - sum_b)
# Judge status: Accepted
x=int(input())
ans=0
for i in range(1,34):
    for j in range(2,11):
        t=i**j
        if t<=x:
            ans=max(ans,t)
print(ans)
# Judge status: Accepted
s = input()

ans = 0
for i in range(len(s) // 2):
    left, right = s[i], s[-i - 1]
    if left != right:
        ans += 1

print(ans)
# Judge status: Accepted
a,b,c = map(int,input().split())
res = 0
for i in range(b):
    res =(a * i)% b
    if res == c:
        print("YES")
        break
else:
    print("NO")
# Judge status: Accepted
S = input()
f = True
if S[0] != 'A':
  f = False
elif S[2:-1].count('C') != 1:
  f = False
else:
  for s in S[1:]:
    if s not in 'Cabcdefghijklmnopqrstuvwxyz':
      f = False
      break
print('AC' if f else 'WA')
# Judge status: Wrong Answer
a = input()
b = input()
c = input()
i = "a"
player = {"a":a,"b":b,"c":c}

while True:
    l = player[i][0]
    player[i] = player[i][1:]
    if len(player[i])==0:
        print(i)
        break
    i = l
# Judge status: Accepted
S=input()
n=len(S)
print('x'*n)
# Judge status: Accepted
a = list(map(int,list(input())))
ans = 0
b = 0
c = [0 for i in range(2019)]
c[0] = 1
for i in range(len(a)):
  b = (b+pow(10,len(a)-i,2019)*a[i])%2019
  c[b] += 1
c = list(map(lambda x:x*(x-1)//2,c))
ans = sum(c)
print(ans)
# Judge status: Accepted
bingo = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
for _ in range(N):
  b = int(input())
  for i in range(3):
    for j in range(3):
      if bingo[i][j] == b:
        bingo[i][j] = 0

ans = "No"
for k in range(3):
  if bingo[k][0] == bingo[k][1] == bingo[k][2] or \
     bingo[0][k] == bingo[1][k] == bingo[2][k]:
    ans = "Yes"
    break
if bingo[0][0] == bingo[1][1] == bingo[2][2] or \
   bingo[0][2] == bingo[1][1] == bingo[2][0]:
  ans = "Yes"
print(ans)
# Judge status: Accepted
l=input().split("hi")
s="".join(l)
if s=="":
  print("Yes")
else:
  print("No")
# Judge status: Accepted
s = input()
s_cnt =0
t_cnt =0
cnt = 0

for i in range(len(s)):
    if s[i] == 'S':
        s_cnt += 1
    if s[i] == 'T':
        t_cnt += 1
        if s_cnt >0:
            t_cnt -= 1
            s_cnt -= 1
print(t_cnt + s_cnt)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
minus = 0
sum = 0
zero = False
minimum = abs(a[0])
for i in a:
    if i == 0:
        zero = True
    if i < 0:
        minus += 1
    minimum = min(minimum, abs(i))
    sum += abs(i)
if zero:
    print(sum)
elif minus % 2 == 0:
    print(sum)
else:
    print(sum - 2 * minimum)
# Judge status: Accepted
if __name__ == '__main__':
	sx, sy, tx, ty = map(int, input().split())
	u1 = ty - sy
	r2 = tx - sx

	root = 'U' * u1 + 'R' * r2 + 'D' * u1 + 'L' * (r2+1)
	root2 = 'U' * (u1+1) + 'R' * (r2+1) + 'D' + 'R' + 'D' * (u1+1) + 'L' * (r2+1) + 'U'
	print(root + root2)
# Judge status: Wrong Answer
n,k = map(int,input().split())
a = list(map(int,input().split()))

#n,k = 10,3
#a = [5,1,3,2,4,1,1,2,3,4]

count = [0] * (n+1)
for i in a:
  count[i] += 1

count2=[]
for i in count:
  if i:
    count2.append(i)
count2 = sorted(count2)

#何種類減らせばいいか
x = len(set(a))
y = x - k
y = max(0,y)

ans = 0
if not y:
  print(ans)
else:
  for i in range(y+1):
    ans += i
  print(ans)
# Judge status: Wrong Answer
def main():
  S=input()
  S_rev=S[::-1]
  sCount=0
  for i in range(len(S)):
    if(S[i]!=S_rev[i]):
      sCount+=1
  print(sCount)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
a = []
for i in range(n): a.append(int(input()))

cur = 0
cnt = 0
for i in range(10**7):
    if a[cur] == 2:
        print(cnt)
        exit()
    cur = a[cur]-1
    cnt += 1
print(-1)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
tmp = []
for _ in range(M):
    tmp.append( list(map(int,input().split())))

cnt = 0
t = []
for i in range(M):
    t=t+[tmp[i][1]]*tmp[i][0]
    cnt+= tmp[i][0]
    if cnt >=N:
        break
A = sorted(A+t,reverse = 1)

print(sum(A[:N]))
# Judge status: Accepted
def main():
    A1, A2, A3 = map(int, input().split())

    if A1 + A2 + A3 >= 22:
        ans = "bust"
    else:
        ans = "win"

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())
S = [0]*87
S[0] = 2; S[1] = 1;
for i in range(2, 86+1):
  S[i] = S[i-1] + S[i-2]
print(S[N])
# Judge status: Accepted
def read_int():
    return int(input())


def read_ints():
    return map(int, input().split(' '))


n = read_int()
a = []
b = []
for i in range(n):
    ai, bi = read_ints()
    a.append(ai)
    b.append(bi)
a.sort()
b.sort()
if n % 2 == 0:
    ma = a[n // 2 - 1] + a[n // 2]
    mb = b[n // 2 - 1] + b[n // 2]
    print(mb - ma + 1)
else:
    ma = a[n // 2]
    mb = b[n // 2]
    print(mb - ma + 1)
# Judge status: Wrong Answer
import sys

def main():
    N = int(input())
    
    cnt = 0
    for i in range(1, N):
        if 1 <= i < 10:
            cnt += 1
        elif 100 <= i < 1000:
            cnt += 1
        elif 10000 <= i < 100000:
            cnt += 1
                    
    print(cnt)
main()
# Judge status: Wrong Answer
import numpy as np

N=int(input())
M=10**9+7
A=[int(x) for x in input().split()]
A=np.array(A)

ans=0
for i in range(60):
  #one=sum([a>>i&1 for a in A])
  one=np.sum(A>>i&1)
  zero=N-one
  ans+=(one*zero)*pow(2,i,M)
  ans%=M
  #print(one,zero)
print(ans)
# Judge status: Accepted
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,l = inpl()
mi = INF
a = [i+l for i in range(n)]
no = -1
for i in range(n):
    if abs(a[i]) < mi:
        no = i
        mi = abs(a[i])
# print(no)
print(sum(x for i,x in enumerate(a) if i != no))