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());r=range(l,l+n);print(sum(r)-min(r,key=abs))

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

Solution (Python):
N, L = map(int, input().split())
apples = [i for i in range(L, L+N)]
apples_abs = [abs(i) for i in apples]
min_idx = apples_abs.index(min(apples_abs))

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

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

Solution (Python):
a,b=map(int,input().split())
x=[b+i for i in range(a)]
y=sum(x)
print(min([(abs(y-(y-i)),y-i) for i in x],key=lambda x:x[0])[1])

Solution (Python):
def solve(N, L):
  A = [L + x for x in xrange(N)]
  A.sort(key = abs)
  A.pop(0)
  return sum(A)
print solve(*map(int, raw_input().split()))

Solution (Python):
import numpy as np
 
 
def taste(N, L):
    all_abs = np.array([np.abs(L + i - 1) for i in range(1, N + 1)])
    all_base = np.array([L + i - 1 for i in range(1, N + 1)])
 
    return all_abs, all_base
 
N, L = map(int, input().split())
 
all_abs, all_base = taste(N, L)
 
N_1_all = all_base[np.min(all_abs) != all_abs]
 
re = np.sum(N_1_all)
print(re)

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

Solution (Python):
N , L = map(int, input().split())
 
list = [L + (i+1)-1 for i in range(N)]
 
list.sort(key=lambda x:abs(x))
 
del list[0]
print(sum(list))

Solution (Python):
a = input().split()
N = int(a[0])
L = int(a[1])
a = [0]*N
for i in range(N):
  a[i] = abs(L+i)
for i in range(N):
  if a[i] == min(a):
    c = int((L-1)*N+N*((N+1)/2)-(L+i))
    print(c)
    break

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

apples = []
zerochk = False
taste_sum = 0
for i in range(N):
    taste = L + i
    apples.append(taste)
    taste_sum += taste
    if taste == 0: zerochk = True


minval = 100

if zerochk:

    print('{}'.format(taste_sum))

elif L > 0:

    print('{}'.format(taste_sum - apples[0]))

else: 

    for i in range(1, len(apples)):
        minval = min(minval, abs(apples[i]))

    ans = 0
    if taste_sum < 0:
        ans = abs(taste_sum) - abs(minval)
        ans *= -1
    else: 
        ans = taste_sum - abs(minval)
    print('{}'.format(ans))

Solution (Python):
N, L = map(int, input().split())
pi = [L+i-1 for i in range(1, N+1)]
minval = 100 + 200 -1
minindex = 0
for o in range(N):

  if minval>abs(pi[o]):
    minval = abs(pi[o])
    minindex = o

print(sum(pi) - pi[minindex])

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

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

r = l + n -1
eat = 0

if r <= 0:
    eat = r
elif l >= 0:
    eat = l
else:
    eat = 0

ans = int((r+l)*(r-l+1)/2-eat)

print(ans)

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


R = l + n - 1


if R <= 0:
  eat = R
elif l >= 0:
  eat = l
else:
  eat = 0


answer = round((R+l) * (R-l+1) / 2 - eat)
print(answer)

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

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

Solution (Python):

import numpy as np





spline = input().split()
N = int(spline[0])
L = int(spline[1])


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



taste_max = sum(taste)




taste_any = []
for k in range(0,N):
    taste_any.append(sum(taste) - taste[k])




taste_any = np.asarray(taste_any)
diff = abs(sum(taste) - taste_any)

diff_list = diff.tolist()


coef = diff_list.index(min(diff_list))


print(taste_any[coef])

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

Solution (Python):
N,L = map(int,input().split())
sum = 0
min = 200

for i in range(1,N + 1):
    if abs(min) > abs(L + i - 1):
        min = L + i - 1
    sum += L + i - 1

sum -= min
print(sum)

Solution (Python):


import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,l=LI()

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

  sm=sum(a)

  mn=inf
  mn_i=-1
  for i in range(n):
    x=a[i]
    if mn>abs(x):
      mn=abs(x)
      mn_i=i

  return sm-a[mn_i]

print(main())

Solution (Python):
import numpy as np
N, L = map(int,input().split())

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

sum = 0
b= min(np.abs(taste))
for i in taste:
    if b != abs(i):
        sum += i

print(sum)

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

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

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

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

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

Solution (Python):
n,l=map(int,input().split())
li=[]
for i in range(1,n+1):
  li.append(l+i-1)
print(sum(li)-[i for i in li if abs(i)==min(list(map(abs,li)))][0])

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

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

Solution (Python):
import math
import re
import time

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

total=(L-1)*N+((1+N)/2)*N
mn=1e9
ans=1e9
for a in range(N):
    l=L+(a+1)-1
    if abs(l)<mn:
        mn=min([mn,abs(l)])
        ans=l
print(int(total-ans))

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

a = 10**6
b = 0
ans = 0
for i in range(1,N+1):
    if abs(L+i-1) < a:
        a = abs(L+i-1)
        b = i

for i in range(1,N+1):
    if i != b:
        ans += (L+i-1)

print(ans)

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

Solution (Python):
n , k = [int(x) for x in input().split()]
s = n * k + (n*(n-1))//2
g = 100000
v = 100000
for x in range(n):
    if(g > abs(k + x)):
      g = abs(k+x)
      v = k + x
    
print(s - v)

Solution (Python):
n , L = map(int, input().split())
taste = 0

if L >= 0:
    taste = L * (n-1) - n + n*(n+1)/2

elif -L >= n:
    taste = L * (n-1) - (n-1) + n*(n-1)/2

else:
    taste = L * n + n*(n+1)/2 - n

print(int(taste))

Solution (Python):
n, l = map(int, input().split())
apples = list(range(l, l + n))
print(sum(apples) - min(apples, key=abs))

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

def result(min_, max_):
  out = 0
  for i in range(min_, max_+1):
    out += i
  return out

min_taste = L
max_taste = L + N -1

if (min_taste <= 0) and (max_taste <= 0):
  print(result(min_taste, max_taste-1))
elif (min_taste <= 0) and (max_taste > 0):
  print(result(min_taste, max_taste))
else:
  print(result(min_taste+1, max_taste))

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

R=[0]*N

for kai in range(N):
    R[kai]=L+kai


kotoae=0
kotae=0
if(R[0]>0):
    for kai1 in range(N):
        kotoae=kotoae+R[kai1]
    print(kotoae-R[0])
elif(R[N-1]<0):
    for kai1 in range(N):
        kotae=kotae+R[kai1]
    print(kotae-R[N-1])
else:
    for kai in range(N):
        kotae=kotae+R[kai]
    print(kotae)

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

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

taste = [(L + i - 1) + 1 for i in range(N)]
pie = {}
ab, tas = 0, 0
for i in range(N):
    tmp0 = sum(taste)
    tmp = taste[:]
    tmp.pop(i)
    tmp1 = sum(tmp)
    if i == 0:
      ab, tas = abs(tmp0 - tmp1), tmp1
    else:
        if ab > abs(tmp0 - tmp1):
            ab, tas = abs(tmp0 - tmp1), tmp1
     	
print(tas)

Solution (Python):
N,L = input().split()
N,L = int(N),int(L)
print(sum(sorted([i for i in range(L,L+N)],key=abs)[1:]))

Solution (Python):
N, L = map(int, input().split())
T = [L+i-1 for i in range(1, N+1)]
T.sort(key=lambda x: abs(x))
print(sum(T[1:]))

Solution (Python):
n, l = map(int, input().split())
apple = []
for i in range(n):
        apple.append(l+(i+1)-1)
pie = sum(apple)
piev2 = []
abs_pie = []
for i in apple:
        piev2.append(pie - i)
        abs_pie.append(abs(i))
num = 0
print(piev2[abs_pie.index(min(abs_pie))])

Solution (Python):
N,L=map(int,raw_input().split())
def F(i):
    return L+i
m=114514
r=None
s=0
for i in range(N):
    if abs(F(i))<m:
        m=abs(F(i))
        r=F(i)
    s+=F(i)
print(s-r)

Solution (Python):
intCount, intBase = map(int, input().split())

intSum = 0

if intBase + intCount -1 < 0:
    intSum += -1 * (intBase + intCount -1)


elif intBase >= 1:
    intSum -= intBase

for intTmp in range(1, intCount+1):
    intSum += intBase + intTmp -1

print(intSum)

Solution (Python):
n, l = map(int, input().split())
tst_l = []
taste = 0

for i in range(1,n+1) :
    taste += l+i-1
    tst_l.append(l+i-1)
print(taste-min(tst_l, key=abs))

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

Solution (Python):
N, L = map(int,input().split())
i = 0
apple_taste = []
pi_taste = 0
while N > i:
    apple_taste.append(L + i)
    if(L>0):
        if i>0:
            pi_taste += apple_taste[i]
    elif(L+(N-1)>=0):
            pi_taste += apple_taste[i]
    elif(L<0):
        if i>0:
            pi_taste += apple_taste[i-1]
    i += 1 
print(pi_taste)

Solution (Python):
n,l = map(int,input().split())
aji=0
minaji=300
realaji=300
for i in range(1,n+1):
    apple=l+i-1
    if minaji> abs(apple):
        minaji=abs(apple)
        realaji=apple
    aji+=apple
print(aji-realaji)

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

max_taste = L + N - 1

if max_taste <= 0:
    eat_taste = max_taste
elif L >= 0:
    eat_taste = L
else:
    eat_taste = 0
print((L + max_taste) * (max_taste - L + 1) // 2 - eat_taste)

Solution (Python):
N,L = [int(x) for x in input().split()]
min_taste=float('inf')
x = 0
for i in range(N):
    if(min_taste>abs(L+i)):
        min_taste = abs(L+i)
        x = i
print((N+1)*N//2+(L-1)*N-(L+x))

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

Solution (Python):
N, L = map(int, raw_input().split())
taste = [L+i for i in range(N)]

apple_pi = sum(taste)

min_val = 0
idx = 0
for i in range(N):
    if i == 0:
        min_val = abs(taste[i])
        idx = i
    else:
        tmp = abs(taste[i])
        if min_val > tmp:
            min_val = tmp
            idx = i

print apple_pi - taste[idx]

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

s = sum(b)
k1 = 10000000000
k2 = 0
for i in range(n):
    s1 = s - b[i]
    
    if abs(abs(s)-abs(s1)) < k1:
        k1 = abs(abs(s)-abs(s1))
        k2 = s1


print(k2)

Solution (Python):
import numpy as p;n,l=map(int,input().split());m=p.arange(n)+l;print(p.sum(p.delete(m,p.abs(p.asarray(m)).argmin())))

Solution (Python):
line = input().strip()
N,K = line.split(" ")
N = int(N)
K = int(K)

flavors = 0
min_data = 10000000000000000
flag = False

for i in range(N):
    flavor = K  + i
    flavors += flavor
    if abs(min_data) > abs(flavor): min_data = flavor
    if flavor == 0: flag = True

if flag: print(flavors)
else: print(flavors - min_data)

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

Solution (Python):
import numpy as np;n,l=map(int,input().split());m=np.arange(0,n)+l;print(np.sum(np.delete(m,np.abs(np.asarray(m)).argmin())))

Solution (Python):

def main():
    n, l = list(map(int, input().rstrip().split()))
    lst = sorted([i for i in range(l, l + n)], key=abs)
    print(sum(lst[1:]))


if __name__ == "__main__":
    main()

Solution (Python):
n ,L = map(int, input().split())
s = []
for i in range(n):
    s.append(i+L)
if s.count(0) == 0:
    
    if sum(s)>0:
        print(sum(s)-min(s))
    else:
        print(sum(s)-max(s))
else:
    print(sum(s))

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

s = L
e = L + N - 1
t = (s + e) * N // 2

if s < 0 and e > 0:
    result = t
elif s >= 0:
    result = t - s
else:
    result = t - e

print(result)

Solution (Python):
def main():
    N, L = map(int, input().split())
    a = [L + n for n in range(N)]
    if L > 0:
        print(sum(a) - a[0])
    elif abs(L) >= N:
        print(sum(a) - a[-1])
    else:
        print(sum(a))


main()

Solution (Python):


N, L = map(int,input().split())
minval = 10**6
minindex = 0
for i in range(1,N+1):
    if abs(L+i-1) < minval:
        minval = abs(L+i-1)
        minindex = i
ans = 0
for i in range(1,N+1):
    if i != minindex:
        ans += (L+i-1)
print(ans)

Solution (Python):
N,L=map(int, input().split())
 
sum = 0
lower = 100000
for i in range(1, N+1):
    sum = sum + L + i -1
for i in range(1, N+1):
    s = abs(L + i -1)
    if s < lower:
        lower = s
        ij = i
 
print(sum - (L + ij -1))

Solution (Python):
n, l=map(int,input().split())
lists = []
taste = 0
for i in range(1,n+1):
	taste += l+i-1
	lists.append(l+i-1)
print(taste-min(lists, key=abs))

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

Solution (Python):
from functools import reduce

Input = input()

n, l = Input.split(' ')
n, l = int(n), int(l)


def ni_taste(i,l=l):
    return l+i-1

taste_list = [ni_taste(i) for i in range(1, n+1)] 
taste_abs_list = [abs(abs_taste) for abs_taste in taste_list]

print( reduce((lambda x, y: x + y), taste_list) - taste_list[taste_abs_list.index(min(taste_abs_list))] ,end='' )

Solution (Python):
N,L = (int(x) for x in input().split())
taste = []
for x in range(int(N)):
  taste.append(str(L+(x+1)-1))
p_taste = sum(int(x) for x in taste)
n_1_taste = []
t_taste= taste.copy()
t_i = 0
for y in t_taste:
  taste.remove(str(y))
  sum_taste = sum(int(x) for x in taste)
  n_1_taste.append(sum_taste)
  taste.append(str(y))
  t_i+=1
if p_taste in n_1_taste:
  print(p_taste)
elif str(L).startswith("-"):
  print(min(n_1_taste))
else:
  print(max(n_1_taste))

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

Solution (Python):
N, L = [int(x) for x in input().split()]
if L >= 0:
    print(L * N + sum(list(range(N))) - L)
elif L < 0 and N <= abs(L):
    print(sum(list(range(L, L + N -1))))
elif L < 0 and N > abs(L):
    print( L * N + sum(list(range(N))) )

Solution (Python):
N,L = [int(s) for s in input().split(' ')]
tastes = [(L + i -1) for i in range(1,N+1)]
tmp_tastes = [ abs(i) for i in tastes ]
min_index = tmp_tastes.index(min(tmp_tastes))
tastes.pop(min_index)
print(sum(tastes))

Solution (Python):
n, l = [ int(i) for i in input().split()]
nl = [l+i-1 for i in range(1,n+1)]
tmp = [-i if i<0 else i for i in nl]
min_index = tmp.index(min(tmp))
del nl[min_index]

print(sum(nl))

Solution (Python):
n, l = map(int, input().split())
tastes = range(l, n + l)
ijo = [taste for taste in tastes if taste >= 0]
under = [taste for taste in tastes if taste < 0]
if len(ijo) == 0:
    print(sum(under[:-1]))
elif len(under) == 0:
    print(sum(ijo[1:]))
else:
    print(sum(tastes))

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

Solution (Python):
string = input()
split = string.split(" ")
N = int(split[0])
L = split[1]

L = int(L)

taste = []

total = 0


for i in range(N):
  taste.append(L + i)
  total = total + taste[i]

mini = min(taste, key=lambda x: -x if x < 0 else x)
total = total - mini
print(total)

Solution (Python):
a = list(map(int,input().split()))
N=a[0]
L=a[1]

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

Solution (Python):
N,L = list(map(int,input().split()))
ate = 0
if 1-N > L :
    ate = L + N - 1
elif L > 0:
    ate = L
print(    (1+N)*N//2  - N + L*N -ate )

Solution (Python):
import numpy as np

nl = input().split(" ")
apple_aji = []


for tsumugi in range(int(nl[0])):
  apple_aji.append(int(nl[1]) + tsumugi)
  
apple_abs = np.abs(apple_aji)
apple_abs = apple_abs.tolist()
le_apple = apple_abs.index(min(apple_abs))

apple_aji[le_apple] = 0

aji = 0
for matsuri in range(len(apple_aji)):
  aji += apple_aji[matsuri]

print(aji)

Solution (Python):

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

Solution (Python):
N,L=map(int,input().split())
num=1-L
sum=(L-1)*N+((N+1)*N)//2
if 1<=num and N>=num:
    print(sum)
elif abs(L)<abs(L+N-1):
    print(sum-L)
else:
    print(sum-L-N+1)

Solution (Python):
n, l = map(int, input().split())
apples = [l + i for i in range(n)]
try:
    min_index = apples.index(min([abs(aps) for aps in apples]))
except ValueError:
    min_index = apples.index(-1*min([abs(aps) for aps in apples]))
print(sum(apples)-apples[min_index])

Solution (Python):



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

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


ab_te = []
for i in range(N):
    T = L + (i+1) -1
    ab_te.append(abs(T))

x = ab_te.index(min(ab_te))


al_te.pop(x)
print(sum(al_te))

Solution (Python):

def main():
    n, l = list(map(int, input().rstrip().split()))
    total = (n + 1) * n // 2 + (l - 1) * n
    first, last = 1 + l - 1, n + l - 1
    if first >= 0:
        print(total - first)
    else:
        if last >= 0:
            print(total)
        else:
            print(total - last)


if __name__ == "__main__":
    main()

Solution (Python):
input=input().split()

N=int(input[0])
L=int(input[1])
taste=0
if L>0:
	for i in range(N-1):
		L+=1
		taste+=L
		
	print(taste)

elif L<0 and -L>=N:
	for i in range(N-1):
		taste+=L
		L+=1

	print(taste)
else:
	for i in range(N):
		taste+=L
		L+=1
		
		
	print(taste)

Solution (Python):
N,L = map(int, input().split())
Taste = [0] * (N+1)
min = 999
mini = -999

for i in range(1,N+1):
    Taste[i] = L+i-1
for j in range(1,N+1):
    if min > abs(Taste[j]):
        min = abs(Taste[j])
        mini = j
s = sum(Taste) - Taste[mini]
print(s)

Solution (Python):
N,L= [int(i) for i in input().split()]
n=[]
for i in range(1,N+1):
    n.append(i)
taste=[]
for j in range(len(n)):
    taste.append(L+n[j]-1)
taste_a=[]
for x in range(len(taste)):
    taste_a.append(abs(taste[x]))
del taste[taste_a.index(min(taste_a))]
sum=0
for y in range(len(taste)):
    sum+=taste[y]
print(sum)

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

sum = 0
min = 300
for i in range(N):
  if abs(L+i) < abs(min):
    min = L+i
  sum += L+i
  
sum -= min

print(sum)

Solution (Python):
N,L=map(int,input().split())
fle=[]
a=L
for i in range(N):
    fle.append(L+i)
    if abs(a)>abs(fle[i]):
        a=fle[i]
print(sum(fle)-a)

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

l = [x for x in range(L, L+N)]

if 0 < L:
    print(sum(l) - l[0])
elif L <= 0 <= L+N-1:
    print(sum(l))
else:
    print(sum(l) - l[-1])

Solution (Python):
N = input().split()

num = int(N[0])

L = int(N[1])

taste = []

for i in range(num):
    taste.append(i+L)

sum_taste = sum(taste)


temp = 999
ans = 0

for index, j in  enumerate(taste):
    t_num = sum(taste[:index]) + sum(taste[index+1:])
    
    if abs(sum_taste - t_num) < temp:
        temp = abs(sum_taste - t_num)
        ans = t_num

print(ans)

Solution (Python):

n,l = map(int,input().split())
azi = 0
eat = -1

for i in range(n):
	ringo = l+i
	if (i == 0 and ringo >= 0):
		eat = ringo
	if (ringo == 0):
		eat = 0
	azi += ringo


if (eat < 0):
	eat = ringo

print(azi-eat)

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

if l+n-1 <=0:
    minL = l+n-1
elif l<=0 and l+n-1 >=0:
    minL = 0
elif l>=0:
    minL  = l

taste = n*(2*l+n-1)/2-minL

print(int(taste))

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

s = (N + 2*L - 1) / 2 * N
max_t = L + N - 1
if L >= 0:
    min_t = L
else:
    if max_t < 0:
        min_t = max_t
    else:
        min_t = 0

print(int(s - min_t))

Solution (Python):
a = [int(i) for i in input().split()]
diff = a[1]-1
taste = []
for i in range(1,a[0]+1):
    taste.append(diff+i)

all_t = sum(taste)
lists=[]
tmp = []
for i in range(a[0]):
    tmp = taste[:]
    del taste[i]
    lists.append(abs(all_t - sum(taste)))
    taste.clear()
    taste = tmp
    
del taste[lists.index(min(lists))]
print(sum(taste))

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

Solution (Python):
N,L =map(int, input().split())
goukei = 0
ans =0
agi_list=[]
for i in range(N):
    agi = L+i
    agi_list.append(agi)
    goukei = agi +goukei
    
if L>0:
    ans = goukei-min(agi_list)
elif L==0:
    ans =goukei
elif (N > abs(L)) :
    ans = goukei
else:
    ans = goukei-(max(agi_list))
print(ans)

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

N = int(n)
L = int(l)

lst = [x + L for x in range(0, N) ]

smallest = lst[0]
smallestIndex = 0;
for i in range(len(lst)):
  if lst[i]**2 < smallest**2:
    smallest = lst[i]
    smallestIndex = i;

lst.pop(smallestIndex)
result = sum(lst)
print(result)

Solution (Python):
from sys import stdin


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





min_value = L
max_value = L + N - 1

summation = L * N + sum(range(N))

if (min_value < 0) and (0 < max_value):
    pass
elif (min_value > 0):
    summation -= min_value
elif (max_value < 0):
    summation -= max_value
    
print(summation)

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

n, l = getList()












aji = [l + i for i in range(n)]
if 0 in aji:
    print(sum(aji))

elif min(aji) > 0:
    print(sum(aji[1:]))

else:
    print(sum(aji[:-1]))

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

Solution (Python):
import numpy as np

n, l = [int(i) for i in input().split(" ")]

nl = np.array([i for i in range(n)]) + 1
ll = nl + l - 1

mini = np.where(np.absolute(ll) == np.min(np.absolute(ll)))
ll = list(ll)
del ll[mini[0][0]]

print(np.sum(ll))

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

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

aji_pie = []
for i in range(0,n):
    v = abs(sum(aji_apple) - (sum(aji_apple) - aji_apple[i]))
    aji_pie.append(v)

min_index = aji_pie.index(min(aji_pie))

print(sum(aji_apple) - aji_apple[min_index])

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

Solution (Python):
N, L = list(map(int, input().split()))
resultList = []
tasteList = []
for i in range(N):
    x = int(L + i)
    resultList.append(x)
    tasteList.append(abs(x))

listMin = min(tasteList)
listNum = tasteList.index(listMin)

if resultList[listNum] > 0:
    listSum = sum(resultList) - listMin
else:
    listSum = sum(resultList) + listMin

print(listSum)

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

taste=l-1

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


plus=[]
for j in apples:
    if j>=0:
        plus.append(j)

minas=[]
for k in apples:
    if k<0:
        minas.append(k)

if len(plus)>0:
    print(sum(plus[1:])+sum(minas))

else:
    print(sum(minas[:-1]))

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


if __name__=="__main__": main()

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

min = abs(taste[0])
sum = taste[0]
index = 0
for i in range(1, N):
    if abs(taste[i]) < min: 
        index = i
        min = abs(taste[i])
    sum += taste[i]
sum = sum - taste[index]
print(sum)

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

APS = [L + i - 1 for i in range(1, N + 1)]

tstall = sum(APS)
TSTL = []
for nn in range(N):
    tst = APS[nn]
    TSTL.append((abs(tst), tstall - tst))

R = sorted(TSTL, key=lambda x: x[0])[0][1]

print(R)

Solution (Python):
N, L = (int(x) for x in input().split())




aji = [L+i for i in range(N)]



left = 0
while (aji[left] < 0):
    if left < N-1:
        left += 1
    else:
        break

ans = sum(aji) - aji[left]
print(ans)

Solution (Python):
N, L = map(int, input().split())
s = 0
A = L-1+N 
if L*A >=0 and L>0:
    s = sum(range(L+1, A+1))
    
elif L*A <= 0:
    s = sum(range(L, A+1))

else:  
    s = sum(range(L, A))
print(s)

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

Solution (Python):


N,L=map(int,input().split())
arr=[]
flg=0
sumall=0
for c in range(N):
    if(L+c==0):
        flg=1
    arr.append(L+c)
    sumall+=L+c
arr.sort()
sum=0

if(flg==0):
    if(sumall>0):
        for c in range(N-1):
           sum+=arr[c+1]
    else:
        for c in range(N-1):
            sum+=arr[c]
else:
    sum=sumall
print(sum)

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

if L>=0:
    for i in range(N):
        sum += i+L
    print(sum-L)
elif L<0 and N+L>0:
    for i in range(N):
        sum += i+L 
    print(sum)
else:
    for i in range(N-1):
        sum += i+L 
    print(sum)

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

ans = 0
min_abs = float('inf')

for i in range(1, n + 1):
   ans += l + i - 1 
   min_abs = min(min_abs, abs(l + i - 1))

if 0 < ans:
    ans -= min_abs
else:
    ans += min_abs

print(ans)

Solution (Python):
n,l= map(int, input().split())
ans=[l]
b=[]

    
if l > 0:
    for i in range(n-1):
        ans.append(l+1)
        l=l+1
    print(sum(ans)-ans[0])
        
        
        
if l == 0:
    for i in range(n-1):
        ans.append(l+1)
        l=l+1    
    print(sum(ans))
    
    
if l < 0:
    for i in range(n-1):
        ans.append(l+1)
        l=l+1
    
    for j in range(n-1):
        b.append(abs(ans[j]))
        
    m = min(b)
    if m == 0:
        print(sum(ans)+m)
    else:
        print(sum(ans)+m-1)

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

if L * (L + N - 1) <= 0:
    print((2 * L + N - 1) * N // 2)
else:
    print((2 * L + N - 1) * N // 2 - min([L, L + N - 1], key=abs))

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

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

aji_n = sum(aji)
diff_min = 9999
ans = 0
for li in aji:
    aji_n1 = aji_n - li
    diff = abs(aji_n - aji_n1)
    if diff < diff_min:
        ans = aji_n1
        diff_min = diff

print(ans)

Solution (Python):
num = list(map(int,input().split()))
apple=[]
for i in range(num[0]):
    apple.append(num[1]+i)
apple1=list(map(abs,apple))
apple.remove(apple[apple1.index(min(apple1))])
print(sum(apple))

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

orig = int((n*(n+1))/2) + (l-1)*n
min = 1000000
flag = 0
for i in range(1, n+1):
    temp = l + i - 1
    
    
    
    if abs(temp) < min:
        min = abs(temp)
        if temp < 0:
            flag = 1

if flag == 1:
    print(orig + min)
else:
    print(orig - min)

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

Solution (Python):
N,L = map(int,input().split())
p = N * L + N * (N - 1) / 2
l = list(range(L, L + N))
t = [(x, abs(x)) for x in l]
m = min(t, key=lambda x: x[1])
print(sum(l) - m[0])

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

s = 0
for n in range(1, N+1):
    s += L + n - 1

for n in range(1, N+1):
    if n == 1:
        m = abs(s - (s - (L + n - 1)))
        ans = s - (L+n-1)
    if m > abs(s - (s - (L+n-1))):
        m = abs(s - (s - (L + n - 1)))
        ans = s - (L+n-1)

print(ans)

Solution (Python):
n,l = map(int,input().split())
aji = []
for i in range(n):
    aji.append(l+i)
ap = sum(aji)
salist = []
salist2 = []
for j in range(len(aji)):
    ap2 = ap-aji[j]
    salist.append(ap2)

for l in range(len(salist)):
    sa = abs(ap-salist[l])
    salist2.append(sa)
print(salist[salist2.index(min(salist2))])

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

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

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