Problem:
 Score : 200 points    Problem Statement You have N apples, called Apple 1 , Apple 2 , Apple 3 , ..., Apple N . The flavor of Apple i is L+i-1 , which can be negative.  You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.  You planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.  You want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.  Find the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.  We can prove that this value is uniquely determined.      Constraints  2 \leq N \leq 200  -100 \leq L \leq 100  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  L       Output Find the flavor of the apple pie made of the remaining N-1 apples when you optimally choose the apple to eat.        Sample Input 1 5 2      Sample Output 1 18  The flavors of Apple 1 , 2 , 3 , 4 , and 5 are 2 , 3 , 4 , 5 , and 6 , respectively. The optimal choice is to eat Apple 1 , so the answer is 3+4+5+6=18 .       Sample Input 2 3 -1      Sample Output 2 0  The flavors of Apple 1 , 2 , and 3 are -1 , 0 , and 1 , respectively. The optimal choice is to eat Apple 2 , so the answer is (-1)+1=0 .       Sample Input 3 30 -50      Sample Output 3 -1044

Solution (Python):
n,l = map(int, input().split())
a = [i+l-1 for i in range(1, n+1)]
aabs = [abs(i) for i in a]
print(sum(a) - a[aabs.index(min(aabs))])

Solution (Python):
n, l = map(int, input().split())

taste_lists = list()
for i in range(n):
    taste = l+i
    taste_lists.append(taste)

eat = 0
if taste_lists[0] > 0 and taste_lists[-1] > 0:
    eat = taste_lists[0]
elif taste_lists[0] < 0 and taste_lists[-1] < 0:
    eat = taste_lists[-1]
else:
    eat = 0

taste_lists.remove(eat)
ans = 0
for i in taste_lists:
    ans += i

print(ans)

Solution (Python):
n,l=map(int,input().split())
mi=10000
for i in range(n):
    m=l+i
    if mi!=min(mi,abs(m)):
        j=i
        mi=min(mi,abs(m))

ans=0
for i in range(n):
    if i!=j:
        ans+=l+i
print(ans)

Solution (Python):
n,l = map(int, input().split())
if l > 0:
    x = 1
elif n + l < 1:
    x = n
else:
    x = 1 - l
print(int(1 - l - x + n * (2 * l + n - 1) / 2))

Solution (Python):
n,l = map(int,input().split())

D=[]
for i in range(n):
    d = l+i
    D.append(d)

if l+1>0 :
    mind = min(D)
elif l+n<=0:
    mind = max(D)
else:
    mind = 0


ans = sum(D)-mind
print(ans)

Solution (Python):
N, L = map(int, input().split())
taste = range(L, L+N)
print(sum(taste) - min(taste, key=abs))

Solution (Python):
N,L=map(int,input().split())
T=[]
for i in range(N):
    T.append(L+i)
if L>=1:
    print(sum(T)-T[0])
elif T[N-1]<=-1:
    print(sum(T)-T[N-1])
else:
    print(sum(T))

Solution (Python):
n,l = map(int,input().split())
azi = list()
for i in range(n):
    azi.append(l+i)
kei = sum(azi)
s = list()
for i in range(n):
    s.append(kei-azi[i])

tmp = float('inf')
ans = 0
for i in range(n):
    if tmp >= abs(kei-s[i]):
        ans = s[i]
        tmp = abs(kei-s[i])
print(ans)

Solution (Python):
N, L = list(map(int, input().split()))
ans = 0
l = N + abs(L)
for i in range(N):
	a = L + i
	if abs(a) < abs(l):
		l = a
	ans += a

print(ans - l)

Solution (Python):
N,L = map(int,input().split())
count = L
taste = []
for i in range(N):
    taste.append(count)
    count += 1
if 0 in taste:
    taste.remove(0)
elif  N + L <= 0:
    taste.pop(-1)
else:
    taste.pop(0)
print(sum(taste))

Solution (Python):
n,l=map(int,input().split())
a=[i for i in range(l,l+n)]
if l>=0:
    eat=min(a)
elif l+n>0:
    eat=0
elif l+n<=0:
    eat=max(a)
    
print(sum(a)-eat)

Solution (Python):
n, l = list(map(int, input().split()))
t = []
for i in range(n):
    t.append(l + i)
sum_t = sum(t)
abs_diff = float('inf')
idx = 0
for i in range(n):
    if abs(sum_t - (sum(t[:i]) + sum(t[i + 1:]))) <= abs_diff:
        abs_diff = abs(sum_t - (sum(t[:i]) + sum(t[i + 1:])))
        idx = i
del t[idx]
print(sum(t))

Solution (Python):
n, l = list(map(int, input().split()))

c = ((l) + (l+n-1)) * n // 2

if 0 < l:
    c -= l
elif l <= 0 <= l + n - 1:
    pass
else:
    c -= (l+n-1)

print(c)

Solution (Python):
N, L = map(int,input().split())

aji = 1000
sum = 0

for i in range(N):
    sum += L+i
    aji = min(aji, abs(L+i))
    if aji == abs(L+i):
        eat = i

print(sum - (L+eat))

Solution (Python):
def the_closest_number_to_zero(lst):
    positive_lst = []
    negative_lst = []
    zero_lst = []
    n = len(lst)

    for i in range(n):
        number = lst[i]

        if number == 0:
            zero_lst.append(number)
        elif number > 0:
            positive_lst.append(number)
        else:
            negative_lst.append(number)

    if len(zero_lst) != 0:
        the_closest_number = 0
    else:
        positive_lst = sorted(positive_lst)
        negative_lst = sorted(negative_lst)

        if len(positive_lst) == 0:
            the_closest_number = negative_lst[-1]
        elif len(negative_lst) == 0:
            the_closest_number = positive_lst[0]
        else:
            positive = positive_lst[0]
            negative = negative_lst[-1]
            if abs(positive) >= abs(negative):
                the_closest_number = negative
            else:
                the_closest_number = positive

    return the_closest_number


def main():
    n, l = map(int, input().split())
    taste_lst = []

    for i in range(n):
        taste_lst.append(l+i)

    taste_total = sum(taste_lst)
    taste_bite = the_closest_number_to_zero(taste_lst)
    taste = taste_total - taste_bite

    print(taste)


if __name__ == '__main__':
    main()

Solution (Python):
n, l = map(int, input().split())
a =  [l + i for i in range(n)]

a.sort(key=lambda x: abs(x))
del a[0]

print(sum(a))

Solution (Python):
n,l=map(int,input().split())
sum_t=sum(range(l,l+n))
min_t=1000
for i in range(n):
    if min_t>=abs(l+i):
        ans=sum_t-l-i
        min_t=abs(l+i)
print(ans)

Solution (Python):
n, l = map(int,input().split())
s = n*l - n + (1+n)*n//2 
if l < 1-n:
    print(s-n-l+1)
elif l <= 0:
    print(s)
else:
    print(s-l)

Solution (Python):
n,l = map(int,input().split())
small = 1000
sum = 0
for i in range(1,n+1):
    sum = sum + l + i - 1
    if abs(l+i-1) <= small:
        small = abs(l+i-1)
        
if sum > 0:
    print(sum-small)
else:
    print(sum+small)

Solution (Python):
N, L = map(int, input().split())
s = 0
min = 10**9
for i in range(N):
  s = s + i + L 
  if min > abs(i+L):
    min = abs(i+L)

if s > 0:
  print(s-min)
else:
  print(s+min)

Solution (Python):
n,l=map(int,input().split())
min =1000
ans = 0
for i in range(n):
    if(min > abs(i+l)):
        min = abs(i+l)
    ans = ans+i+l
if(ans < 0):
    print(ans+min)
else:
    print(ans-min)

Solution (Python):
n,l = map(int,input().split())
ans = list(i+l for i in range(n))
m = 10**10
for i in ans:
    if abs(m)>abs(i):
        m = i
print(sum(ans)-m)

Solution (Python):
n, l = map(int, input().split())
a = [k + l for k in range(n)]

a.sort(key = lambda x: abs(x))
del a[0]

print(sum(a))

Solution (Python):
N,L=list(map(int,input().split()))
l=list(range(L,N+L))
l_a=[abs(i) for i in l]
print(sum(l)-min(l_a)) if min(l_a) in l else print(sum(l)+min(l_a))

Solution (Python):
n,l=map(int,input().split())
A=[]
for i in range(n):
    A.append(l+i)
B=A.copy()
for j in range(len(B)):
    B[j]=abs(B[j])
print(sum(A)-A[B.index(min(B))])

Solution (Python):
from bisect import *
N, L = map(int, input().split())
A = list(range(L,L+N))
res = sum(A)
print(res - A[min(bisect_left(A,0),len(A)-1)])

Solution (Python):
n, l = list(map(int, input().split()))
left = l
right = l + n - 1
eat = 0
if left >= 0:
    eat = left
elif right <= 0:
    eat = right
t = 0
for i in range(n):
    t += i + l
print(t - eat)

Solution (Python):
N, L = map(int, input().split(' '))
ls = [i + L for i in range(N)]
if 0 in ls:
    print(sum(ls))
elif sum(ls) < 0:
    print(sum(ls) - max(ls))
else:
    print(sum(ls) - min(ls))

Solution (Python):
n,l = map(int, input().split())
tastes = [(i + l) for i in range(n)]
t = tastes.copy()
for j in range(n):
    t[j] = abs(t[j])
del tastes[t.index(min(t))]
print(sum(tastes))

Solution (Python):




n, l = map(int, input().strip().split())
res = n * (2 * l + n - 1) / 2
if l > 0:
    res -= l
elif l + n - 1 < 0:
    res -=  l + n - 1
print(int(res))

Solution (Python):
N, L = list(map(lambda x: int(x), input().split(" ")))
 
S = int(N * (N-1) / 2) + L * N
 
if L >= 0:
  print(S - L)
elif L + N - 1 <= 0:
  print(S - L - N + 1)
else:
  print(S)

Solution (Python):
n, l = map(int, input().split())
expected = sum([l+i-1 for i in range(1, n+1)])

diff = 10 ** 9
result = 10 ** 9

for i in range(1, n+1):
  reduced = expected - (l+i-1)
  if abs(expected - reduced) < diff:
    diff = abs(expected - reduced)
    result = reduced

print(result)

Solution (Python):
N,L = [int(i) for i in input().split()]

A = [i+L-1 for i in range(1,N+1)]
B = [abs(i+L-1) for i in range(1,N+1)]

print(sum(A)-A[B.index(min(B))])

Solution (Python):
N,L = map(int,input().split())
s = sum([L+i-1 for i in range(1,N+1)])
if L <= 0 and L+N-1 >= 0:
    print(s)
elif L > 0:
    print(s-L)
else:
    print(s-L-N+1)

Solution (Python):

n, l = map(int, input().split())
s = []

for i in range(1, n+1):
    s.append(l+i-1)

a = 10**19

h = 0
for i in range(n):
    
    if a > abs(s[i]):
        a = abs(s[i])
        h = s[i]

print(sum(s)-h)

Solution (Python):
n, l = map(int, input().split())
s = []
for i in range(1, n+1):
    s.append(l+i-1)
a = 10**19
h = 0
for i in range(n):
    
    if a > abs(s[i]):
        a = abs(s[i])
        h = s[i]
print(sum(s)-h)

Solution (Python):
n,l=map(int,input().split())
ls=range(l,n+l)
if 0 in ls:
    x=0
elif all(i>0 for i in ls):
    x=ls[0]
else:
    x=ls[n-1]
print(int((n*l+(n-1)*n/2-x)))

Solution (Python):
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
n, l = [int(num) for num in lines.pop(0).split(" ")]
lower = l
upper = l + n - 1
sum = (lower + upper) * n // 2
if lower * upper > 0: 
    if abs(lower) <= abs(upper):
        sum -= lower
    else:
        sum -= upper
print(sum)

Solution (Python):
n, l = map(int, input().split())
t = list(map(lambda x: l + x, range(n)))
r = sum(t)
dif = 10 ** 100
for i in range(n):
    tmp = sum(t[:i] + t[i + 1:])
    dif_t = abs(r - tmp)
    if dif_t < dif:
        ans = tmp
        dif = dif_t
print(ans)

Solution (Python):
n, l = map(int, input().split())

a = []

for i in range(n):
    a.append(i+l)

print(sum(a) - min(a, key = abs))

Solution (Python):
N, L = map(int,input().split())

apples = [L+i for i in range(N)]
total = sum(apples)

min_d, ans = 10**9, 0
for i in range(N):
    d = abs(apples[i])
    if d < min_d:
        min_d = d
        ans = total - apples[i]

print(ans)

Solution (Python):
N,L = map(int,input().split())
A = []

for n in range(1,N+1):
  A.append(L+n-1)
  
print(sum(A)-min(A,key=abs))

Solution (Python):
n, l = map(int, input().split())
x = [l+i for i in range(n)]
x = sorted(x, key=lambda x: abs(x))
print(sum(x[1:]))

Solution (Python):
n,l=map(int, input().split())
a=[l+i for i in range(n)]
value1=1000
value=0
for i in range(n):
  if abs(a[i])<value1:
    value1=abs(a[i])
    value2=a[i]
print(sum(a)-value2)

Solution (Python):
n,l=map(int,input().split())
t=[l+i for i in range(n)]
tot = sum(t)
ans = tot - t[0]
mn = float('inf')
for i in range(n):
	tmp = tot-t[i]
	if abs(tmp-tot)<mn:
		mn = abs(tmp-tot)
		ans = tmp
		
print(ans)

Solution (Python):
N, L = map(int, input().split())

taste = [L + i for i in range(N)]
taste_abs = [abs(i) for i in taste]
min_index = taste_abs.index(min(taste_abs))
eat = taste[min_index]

print(sum(taste) - eat)

Solution (Python):
n,l = map(int,input().split())

sumsum = sum(range(l,l+n))
if 0<l:
    print(sumsum - l)
elif l+n-1<0:
    print(sumsum -l-n+1)
else:
    print(sumsum)

Solution (Python):
num = 0
n,l = map(int, input().split())
if l <= 0 < l+n-1:
    for i in range(1,n+1):
        num += (l+i-1)
elif l > 0:
    for i in range(2,n+1):
        num += (l+i-1)
else:
    for i in range(1,n):
        num += (l+i-1)
print(num)

Solution (Python):








n,l = map(int, input().split())

taste = []
for i in range (1,n+1):
    taste.append(l+i-1)

if l < 0:
    if (-1)*l < n:
        print(sum(taste))
    else:
        del taste[-1]
        print(sum(taste))
else:
    
    del taste[0]
    print(sum(taste))

Solution (Python):
n, l = map(int, input().split())
apples = [l+i-1 for i in range(1, n+1)]
mn = float('inf')
idx = 0
for i in range(n):
    if mn>abs(apples[i]):
        mn = abs(apples[i])
        idx = i

print(sum(apples)-apples[idx])

Solution (Python):
MM = input().split()
N = int(MM[0])
L = int(MM[1])
list1 =[]
for i in range(N):
  a = L + i
  list1.append(a)

mini = 301
ans = 201
for i in range(N):
  if mini > abs(list1[i]):
    mini = abs(list1[i])
    ans = i
total = 0
for i in list1:
  total += int(i)
ans1 = total -list1[ans]
print(ans1)

Solution (Python):
n, l = map(int, input().split())
A = [l+i for i in range(n)]
num = float('inf')
for a in A:
    num = min(num, abs(a))
if num in A:
    print(sum(A) - num)
else:
    print(sum(A) - num*(-1))

Solution (Python):
N, L = [int(n) for n in input().split()]

total = (2*L + N - 1) * N / 2
app = [L + i -1 for i in range(1, N+1)]
app_ = [abs(n) for n in app]
idx = app_.index(min(app_))

print(int(total - app[idx]))

Solution (Python):
N, L = map(int, input().split())
ans = 0
for i in range(N):
    ans += i+L
if L < 0 and N+L-1 < 0:
    ans -= N+L-1
elif L > 0 and N+L-1 > 0:
    ans -= L
print(ans)

Solution (Python):
import math

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

sum = 0
minimum = 99999
for i in range(1,N+1):
    aji = L + i - 1
    sum += aji
    if (math.fabs(minimum) > math.fabs(aji)):
        minimum = aji

print(sum - minimum)

Solution (Python):
n,l = map(int, input().split())
a = 200
ans=0
for i in range(l,l+n):
  ans+=i
  if abs(i) < abs(a):
    a = i
print(ans-a)

Solution (Python):
n ,l = map(int, input().split())
apple = []
for i in range(n):
    apple.append(l + i)

if l - 1 + n - 1 < 0:
    print(sum(apple[:n - 1]))
elif l < 0 and  0 <= l - 1 + n - 1:
    print(sum(apple))
elif 0 <= l:
    print(sum(apple[1:]))

Solution (Python):
n ,l = map(int, input().split())
apple = []
for i in range(n):
    apple.append(l + i)

min_num = 10 ** 5
sum_num = sum(apple)
ans = 0
for i in range(n):
    tmp = abs(sum_num - (sum_num - apple[i]))
    if tmp < min_num:
        min_num = min(tmp, min_num)
        flag = apple[i]
        ans = sum_num - apple[i]

print(ans)

Solution (Python):
n ,l = map(int, input().split())
apple = []
for i in range(n):
    apple.append(l + i)

min_num = 10 ** 5
sum_num = sum(apple)
for i in range(n):
    tmp = abs(sum_num - (sum_num - apple[i]))
    if tmp < min_num:
        min_num = min(tmp, min_num)
        flag = apple[i]

if flag >= 0:
    print(sum(apple) - min_num)
else:
    print(sum(apple) + min_num)

Solution (Python):
N,L=map(int,input().split())
taste=[0]*N; abs_taste=[0]*N;
for i in range(N):
  taste[i]=L+i
  abs_taste[i]=abs(L+i)
for i in range(N):
  if abs_taste[i]==min(abs_taste) :
    min_i=i
    break
print(sum(taste)-taste[min_i])

Solution (Python):
n,k=map(int,input().split());a=[k+i for i in range(n)]
sumA=sum(a);min_num=float('inf');result=0
for i in a:
  if min_num > abs(sumA-(sumA-i)):
    min_num=abs(sumA-(sumA-i))
    result=sumA-i
print(result)

Solution (Python):
n, l = map(int, input().split())
s = n * (l-1) + n * (n+1) // 2
i = 1 - l
if i > n:
	i = n
elif i < 1:
  	i = 1
print(s - (l + i - 1))

Solution (Python):
import numpy as np

N, L = map(int, input().split())
taste = [L + i for i in range(N)]
remove = np.argmin(np.abs(taste))
taste_sum = 0
for i in range(N):
    if i == remove:
        continue
    else:
        taste_sum += taste[i]
print(taste_sum)

Solution (Python):
n, l = (int(xi) for xi in input().split())

a = int(n*(l-1)+n*(n+1)/2)


if 0<1-l<n+1: print(a)
if 1-l<1: print(a-(l+1-1))
if n<1-l: print(a-(l+n-1))

Solution (Python):
























































global FLAG_LOG
FLAG_LOG = False


def log(value):
    
    
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    
    
    N, L = list(map(int, lines[0].split()))
    
    
    
    
    
    
    
    

    mi = None
    su = 0

    for i in range(N):
        value = i + L
        if mi is None:
            mi = value
        if abs(mi) > abs(value):
            mi = value
        su += value

    return [su-mi]



def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['5 2']
        lines_export = [18]
    if pattern == 2:
        lines_input = ['3 -1']
        lines_export = [0]
    if pattern == 3:
        lines_input = ['30 -50']
        lines_export = [-1044]
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

Solution (Python):
n, l = map(int, input().split())
p = []
q = []
for i in range(n):
  p.append(abs(l + i))
  q.append(l + i)
a = 0
for i in range(n):
  if i != p.index(min(p)):
    a += q[i]
print(a)

Solution (Python):
N,L=map(int,input().split())
b=0
ans=0
for x in range(1,N+1):
  if b==0 and abs(L+x-1)<abs(L+x):
    b=1
  else:
    ans+=L+x-1
if b==0:
  ans -= L+N-1
print(ans)

Solution (Python):
def main():
  n,l = list(map(int,input().split()))
  ans=0
  if l>=0:
    for i in range(2,n+1):
      ans+= l+i-1
  elif n+l-1<0:
    for i in range(1,n):
      ans+=l+i-1
  else:
    for i in range(1,n+1):
      ans+=l+i-1
  print(ans)  
main()

Solution (Python):
N, L = map(int, input().split())

if L >= 1:
  eat = L
elif L+N-1 <= -1:
  eat = L+N-1
else:
  eat = 0

taste = eat*(-1)
for i in range(N):
  taste += L+i

print(taste)

Solution (Python):
n,l = map(int,input().split())
ans = 0
pie = l*n+(1+n)*n//2-n
max_a = l+n-1
min_a = l
if max_a<0:
    ans = pie-max_a
elif min_a<=0 and max_a>=0:
    ans = pie
elif min_a>0:
    ans = pie-min_a
print(ans)

Solution (Python):
N,L=map(int,input().split())
score = [L+i for i in range(N)]
SUM=sum(score)

MIN=10**9
argmin=-1
for i in range(N):
  res = abs(SUM - (SUM-score[i]))
  if res < MIN:
    MIN = res
    argmin=i

print(SUM-score[argmin])

Solution (Python):
N, L = map(int, input().split())
ans = 0

if L>0:
    for i in range(N-1):
        ans += L+i+1
    print(ans)
    exit()

if L<=0 and N+L-1 <= 0:
    for i in range(N-1):
        ans += L+i
    print(ans)
    exit()

for i in range(N):
    ans += L+i
print(ans)

Solution (Python):
n,l = map(int, input().split())

lst = []
for i in range(n):
    lst.append(l+i)
taste_total = sum(lst)
taste_pie = taste_total - min(lst, key = abs)

print(taste_pie)

Solution (Python):
N, L = map(int, input().split())
A = [0]*N
for i in range(N):
    A[i] = L + (i+1) - 1

ans = 0
if 0 in A:
    ans = sum(A)
else:
    if L < 0:
        ans = sum(A) - A[-1]
    else:
        ans = sum(A) - A[0]

print(ans)

Solution (Python):
N,L=map(int,input().split())
RES = 0
res = 100
mid = 0
List = []
for i in range(N):
  mid = L+i
  List.append(mid)
  if abs(mid)<abs(res):
    res = mid
for i in range(N):
  if res == List[i]:
    pass
  else:
    RES += List[i]
print(RES)

Solution (Python):

def pop_min_abs(l):
    abs_l = list(map(abs, l))
    l.pop(abs_l.index(min(abs_l)))
    return l



n, l = map(int, input().split())

apples = [l+i-1 for i in range(1,n+1)]
print(sum(pop_min_abs(apples)))

Solution (Python):
n,l = map(int,input().split())
count = 0
lists = [l+i-1 for i in range(1,n+1)]
x = 2000
for i in range(n):
  if abs(x)>abs(lists[i]):
    x = lists[i]
lists.remove(x)
print(sum(lists))

Solution (Python):
def main():
    N, L = map(int, input().split())
    tastes = []
    num = []
    perfectPie = 0
    for i in range(N):
        perfectPie += i + L
        tastes.append(i + L)
        num.append(abs(i + L))
    num.sort()
    if num[0] in tastes:
        print(perfectPie - num[0])
    else:
        print(perfectPie + num[0])
main()

Solution (Python):
N, L = map(int, input().split())

ans = 0
flag = False
for i in range(N):
    if L + i == 0:
        flag = True
    ans += (L + i)
if not flag:
    if ans < 0:
        ans -= (L+N-1)
    else:
        ans -= L
print(ans)

Solution (Python):
n, l = map(int, input().split())
tastes = [i for i in range(l, l + n)]
ans = sum(tastes) - min(tastes, key=abs)
print(ans)

Solution (Python):
N, L = map(int, input().split())
l = range(L, N + L)
a = [sum(l[1:]), sum(l[:-1]), sum(l), sum(l)]
print(a[((0 in l) << 1) + (L < 0)])

Solution (Python):
import sys
N,L = map(int,input().split())
apple = []
diff =1000000
num = 0
for i in range(N):
  value = i + L
  apple.append(value)
  if diff > abs(value):
    diff = abs(value)
    num = i
del apple[num]
print(sum(apple))

Solution (Python):
import numpy as np

n,l = map(int,input().split())
taste = []
taste_diff = []

for i in range(1,n+1):
    taste.append(l+i-1)


s = sum(taste)

for i in range(len(taste)):
    taste_diff.append(s-taste[i])



def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]

print(getNearestValue(taste_diff, s))

Solution (Python):
n, l = map(int, input().split())
a = [l + i for i in range(n)]
s = 1 if sum(a) >= 0 else -1 
print(sum(a) - s * min(abs(a[i]) for i in range(n)))

Solution (Python):
n,l = map(int,input().split())
m = 0
k = float("inf")
for i in range(n):
    m += l + i
    if k > abs(l + i):
        p = l + i
        k = abs(l + i)
print(m-p)

Solution (Python):
n, l = map(int, input().split())
a = []
b = []
for i in range(1,n+1):
    a.append(l+i-1)
    b.append(abs(l+i-1))
x = b.index(min(b))
print(sum(a)-a[x])

Solution (Python):
N, L = map(int, input().split())
A = [L+i for i in range(N)]
total = 0
min_abs = 301

for i in range(N):
    total += A[i]
    if min_abs > abs(A[i]):
        min_abs = abs(A[i])
        idx = i

print(total - A[idx])

Solution (Python):
n, L = map(int, input().split())
l = [0] * n
for i in range(n):
  l[i] = L + i
mins = 10 ** 10
for i in l:
  if abs(mins) > abs(i):
    mins = i
print(sum(l) - mins)

Solution (Python):
n,l = map(int,input().split(" "))
if l >= 0:
    a = int(((l+1)+(l+n-1))*(n-1)/2)
elif l+n-1 >= 0:
    a = int((l+(l+n-1))*n/2)
else:
    a = int((l+(l+n-2))*(n-1)/2)
print(a)

Solution (Python):
N, L = map(int, input().split())

low = L+1-1
high = L+N-1
total = (low+high)*N//2

min_diff = 10**4
min_total = -1
for i in range(N):
    diff = abs(L+i)
    if diff < min_diff:
        min_diff = diff
        min_total = total - (L+i)
print(min_total)

Solution (Python):
n,l=map(int,input().split())
if l <= 0 and l+n-1 >= 0:
  ate=0
elif l > 0:
  ate=l
else: 
  ate=l+n-1
  
print((l-1)*n+n*(n+1)//2-ate)

Solution (Python):
n,l = map(int,input().split())
al = [l+i for i in range(n)]
a = min(al,key=abs)
al.remove(a)
print(sum(al))

Solution (Python):
n, l = map(int, input().split())
a = []
b = []
for i in range(n):
    a.append(l+i)
    b.append(abs(l+i))
x = b.index(min(b))
print(sum(a)-a[x])

Solution (Python):
n,l=map(int,input().split())
li=[l+i for i in range(n)]
print(sum(li)-sorted(li,key=lambda x:abs(x))[0])

Solution (Python):
import sys
N,L = map(int,input().split())

if not ( 2 <= N <= 200 and -100 <= L <= 100 ): sys.exit()

array = [ L+x for x in range(N)]
before = 100
for I in array:
    if abs(I) <= before: before = abs(I);position = array.index(I)
print(sum(array) - array[position])

Solution (Python):
N, L = map(int, input().split())
if L >= 0:
    print(sum(range(L + 1, L + N)))
elif N + L - 1 >= 0:
    print(sum(range(L, L + N)))
else:
    print(sum(range(L, L + N - 1)))

Solution (Python):
N, L = map(int, input().split())
m, p = 100000, 0
A = [abs(L+i-1) for i in range(1, N+1)]
print(sum(L+i-1 for i in range(1, N+1)) -(L+A.index(min(A))))

Solution (Python):
a,b=map(int, input().split())
L = []

for i in range(1,a+1):
    L.append(b+i-1)

if L[0] >= 0:
    L[0] = 0
    print(sum(L))
if L[0] < 0 and L[a-1] > 0:
    print(sum(L))
if L[0] < 0 and L[a-1] <= 0:
    L[a-1] = 0
    print(sum(L))

Solution (Python):
N,L = map(int,input().split())

l = [i+L for i in range(N)]
_l= [abs(x) for x in l]
l_min_id = _l.index(min(_l))
print(sum(l)-l[l_min_id])

Solution (Python):
n, l = map(int, input().split())

T = [l+i for i in range(n)]
if T[-1] >= 0:
  m = min(i for i in T if i >= 0)
else:
  m = T[-1]
print(sum(T) - m)

Solution (Python):

N,L = map(int,input().split())
f = 0
k = 0
j = []
for i in range(1,N+1):
    f += L+i-1
for i in range(1,N+1):
    k = L+i-1
    n = f-k
    p = abs(f-n)
    j.append(p)
if f >0:
    print(int(f-min(j)))
else:
    print(int(f+min(j)))

Solution (Python):
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N, L = rl()

aji = [0]*N

minaji = float('inf')
for i in range(N):
	aji[i] = L+i
	if abs(minaji) > abs(aji[i]):
		minaji = aji[i]
print(sum(aji)-minaji)

Solution (Python):
n,l = map(int,input().split())
taste = [0]*n
for i in range(n):
    taste[i] = l+i
api = sum(taste)
eat = 0
sa = 10000
for i in range(n):
    if abs(taste[i]) < abs(sa):
        sa = taste[i]
print(api-sa)

Solution (Python):
n, l = map(int, input().split())
taste = [l+i for i in range(n)]
tmp = 9999
index = 0
for i in range(n):
  if abs(taste[i]) < tmp:
    tmp = abs(taste[i])
    index = i
res = sum(taste) - taste[index]
print(res)

Solution (Python):
n,l=map(int,input().split())
a=list(range(l,n+l))
m=list(map(abs,a))
print(sum(a)-a[m.index(min(m))])

Solution (Python):
N, L = map(int, input().split())

apples = []
for i in range(1, N+1):
    apples.append(L+i-1)

tast = sum(apples)
for i in range(500):
    if i in apples:
        tast -= i
        break
    elif -i in apples:
        tast += i
        break
print(tast)

Solution (Python):
N,L = map(int,input().split())
a = [0]*N
for i in range(N):
  a[i] = L+i
all_apple_pie = sum(a)
apple_pie = [0]*N
def_apple_pie = [0]*N
for i in range(N):
  t = a[i]
  a[i] = 0
  apple_pie[i] = sum(a)
  def_apple_pie[i] = abs(all_apple_pie-apple_pie[i])
  a[i] = t
index = def_apple_pie.index(min(def_apple_pie))
print(apple_pie[index])

Solution (Python):
n, l = map(int, input().split())

taste = [l + i - 1 for i in range(1, n + 1)]
taste_all = sum(taste)
if taste[n - 1] < 0:
    taste_min = taste[n - 1]
elif taste[0] > 0:
    taste_min = taste[0]
else:
    taste_min = 0
print(taste_all - taste_min)

Solution (Python):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque, defaultdict


from collections import Counter

from itertools import accumulate,combinations,permutations,product

from heapq import heapify,heappop,heappush


from functools import reduce,lru_cache

from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    

    
    N, L = map(int, input().split())
    
    
    
    tot=0
    ma=100000
    for i in range(N):
        tot+=L+i
        if abs(L+i)<abs(ma):
            ma=L+i
    print(tot-ma)




if __name__ == "__main__":
    main()

Solution (Python):
N,L = map(int,input().split())
ans = 0
for i in range(N):
  ans += i+L
if L>0:
  ans -= L
elif N <= abs(L):
  ans -= L+N-1
print(ans)

Solution (Python):
N,L = map(int,input().split())
R = L+N-1
if L <= 0 <= R:
    print(sum(range(L,R+1)))
elif L > 0:
    print(sum(range(L+1,R+1)))
else:
    print(sum(range(L,R)))

Solution (Python):
N, L = map(int, input().split())

A = (2 * L + N - 1)*N // 2
if L*(L+N-1) <= 0:
  print( A )
elif L+N-1 < 0:
  print( A - (L+N-1) )
else:
  print( A - L )

Solution (Python):
N,L=map(int,input().split())
a=[]
for i in range(1,N+1):
    a.append(L+i-1)
A=list(map(abs,a))
print(sum(a)-a[A.index(min(A))])

Solution (Python):
N,L = map(int,input().split())

taste = [0]*N
for i in range(N):
  taste[i] = L + i

min_val = 10**3
min_idx = 0
for i in range(N):
  if min_val > abs(taste[i]):
    min_val = abs(taste[i])
    min_idx = i

ans = sum(taste)-taste[min_idx]
print(ans)

Solution (Python):
n,l=map(int,input().split())
apple=list(range(1,n+1))
aji=[l+i-1 for i in apple]
sum_num=sum(aji)
sa=10000
for i in range(len(aji)):
    if abs(aji[i])<sa:
        sa=abs(aji[i])
        ans=aji[i]
print(sum_num-ans)

Solution (Python):
n,l = map(int,input().split())
m = 10**5
for i in range(n):
    if abs(m) > abs(i+l):
        m = abs(i+l)
        ans = i
s = l*n+n*(n-1)/2
print(int(s-(ans+l)))

Solution (Python):
N, L = map(int,input().split())
T = []
A = 0
for i in range(N):
    T.append(L + i)

if T[0] <= 0 and T[-1] >= 0:
    A = sum(T)

elif T[-1] < 0:
    A = sum(T[:-1])

else:
    A = sum(T[1:])

print(A)

Solution (Python):
n,l = map(int,input().split())
m = list(range(l,l+n))
if m[-1] < 0:
    m.pop(-1)
    print(sum(m))
elif m[0] > 0:
    m.pop(0)
    print(sum(m))
else:
    print(sum(m))

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, l = rm()
li = np.arange(n) + l
if l > 0:
  print(sum(li[1:]))
elif l <= -n:
  print(sum(li[:-1]))
else:
  print(sum(li))

Solution (Python):
N,L = map(int,input().split())

diffabs = 99999
taste = 0

for i in range(N):
    taste += L+i
    if abs(L+i)<diffabs:
        diffabs = abs(L+i)
        diff = L+i
print(taste-diff)