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



Sample input:
5 2


Sample output:
18

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
flavor = []
import numpy as np
for i in range(1, N + 1):
    flavor.append(L + i - 1)
for j in flavor:
    if abs(j) == min(np.abs(flavor)):
        eat = j
print(sum(flavor) - j)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
flavor = []
import numpy as np
for i in range(1, N + 1):
    flavor.append(L + i - 1)
eat = min(np.abs(flavor))
print(sum(flavor) - eat)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
flavor = []
import numpy as np
for i in range(1, N + 1):
    flavor.append(L + i - 1)
eat = min(np.abs(flavor))
print(flavor - eat)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
flavor = 0
for i in range(1, N + 1):
    flavor += L + i - 1
print(flavor - abs(L))

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
flavor = 0
for i in range(1, N + 1):
    flavor += L + i - 1
print(flavor - L)

Submission status: Wrong Answer

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

if N+L-1<0:
  print(sum(list(range(N-1)))+(N-1)*L)
elif L<0 and N+L-1>0:
  print(sum(list(range(N)))+N*L)
else:
  print(sum(list(range(1,N)))+(N-1)*L)

Submission status: Wrong Answer

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

if N+L-1<0:
  print(sum(list(range(N-1)))+(N-1)*L)
elif L<0 and N+L-1>0:
  print(sum(list(range(N)))+(N-1)*L)
else:
  print(sum(list(range(1,N)))+(N-1)*L)

Submission status: Wrong Answer

Solution code:
N,L= map(int,input().split())
S = N*(L-1)+N*(1+N)/2
MIN = L+1-1
MAX = L+N-1
if abs(MIN) < abs(MAX):
    print(int(S-MIN))
elif abs(MIN) == abs(MAX):
    print(int(S))
elif abs(MIN) > abs(MAX):
    print(int(S-MAX))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 0

[n,l]=inpl()
lsum = n*(n-1)//2 + l*n
if l-1 <= 0 and l-1+n >= 0:
    ans = lsum
elif l-1+n < 0:
    ans = lsum - (l-1+n)
elif l-1 > 0:
    ans = lsum -(l-1)


print(ans)

Submission status: Wrong Answer

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

li = [x for x in range(l, l+n)]
abs_li = []
for i in li:
  abs_li.append(abs(i))
abs_li.sort()
n_sum = sum(li)

print(n_sum-abs_li[0])

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
ans=(((2*l)+n-1)*n)/2

if l>=0:
  ans-=2*l
elif l<0 and (l+n-1)>=0:
  ans+=0
else:
  ans-=(l+n-1)*2
  
print(ans)

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
ans=(((2*l)+n-1)*n)/2

if l>=0:
  ans-=l
elif l<0 and (l+n-1)>0:
  ans+=0
else:
  ans-=(l+n-1)
  
print(ans)

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
ans = 0
eat = 1+l-1

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

print(ans-eat)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
Taste = [0]*N
for i in range(N):
    Taste[i] = L + i 
print(sum(Taste) - min(map(abs, Taste)))

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
li = []
for i in range(1,N+1):
  li.append(L+i-1)

if min(li) < 0 and max(li) > 0:
  print(sum(li))
elif max(li) < 0:
  print(sum(li)-max(li))
else:
  print(sum(li)-min(li))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
T=[]
sum_t = 0

for n in range(N):
    taste = L + (n+1) -1
    sum_t += taste
    T.append(abs(taste))

x = min(T)
number = abs(min(T) - L)

ans = sum_t - L + (number + 1) -1
print(ans)

Submission status: Wrong Answer

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

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

print(taste)

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
print(n*(l-1)+n*(n+1)/2-l)

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
print((l-1+(n+1)/2)*(n-1))

Submission status: Wrong Answer

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

t_sum = 0
t_min = 1000
for i in range(1, n+1):
    t_min = min(t_min, abs(l+i-1))
    t_sum += l+i-1

print(t_sum - t_min)

Submission status: Wrong Answer

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

sum_all = 0
for i in range(N):
    sum_all += L + i

if L >= 0:
    ans = sum_all - L
elif N <= abs(L):
    ans = sum_all - (L + N - 1)
else:
    ans = sum_all

print(ans)
print(sum_all)

Submission status: Wrong Answer

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

sum_all = 0
for i in range(N):
    sum_all += L + i

if L >= 0:
    ans = sum_all - L
elif N + 1 <= abs(L):
    ans = sum_all - (L + N - 1)
else:
    ans = sum_all

print(ans)

Submission status: Wrong Answer

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

sum_all = 0
for i in range(N):
    sum_all += L + i

ans = 0    
for i in range(N):
    if L + i == 0:
        ans = 0
        break
    if abs(ans) - abs(sum_all - (L + i)) < 0:
        ans = sum_all - (L + i)

print(ans)

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
sum = 0.5 * n * (2 * l + n -1)

s = list(l+i-1 for i in range(n+1))
a = list(sum - int(abs(s[j])) for j in range(1,n+1))

if max(a) > 0:
        print(int(max(a)))
else:
        print(int(sum - max(s)))

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
sum = 0.5 * n * (2 * l + n -1)

s = list(l+i-1 for i in range(n+1))
a = list(sum - int(abs(s[j])) for j in range(1,n+1))

if max(a) > 0:
        print(max(a))
else:
        print(sum - max(s))

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
sum = 0.5 * n * (2 * l + n -1)

s = list(l+i-1 for i in range(n+1))
a = list(sum - int(abs(s[j])) for j in range(1,n+1))

print(max(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import copy

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

n_L = list(range(n))
a_L = list(map(lambda x:l+x,n_L))
# out of rangeを防ぐため
a_L.append(0)

allsum = sum(a_L)

result_L = []
print(a_L)

diff = abs(allsum-sum(a_L[1:]))

for val in range(n):
    b_L = copy.copy(a_L)
    b_L.pop(val)
    temp_sum = sum(b_L)

    if abs(allsum-temp_sum) <= diff:
        result = temp_sum
    diff = abs(allsum-temp_sum)

print(result)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
tmp = 0
i = L
for _ in range(N):
    tmp += i
    i += 1
if tmp == 0:
    print(0)
elif tmp > 0:
    if L < 1:
        print(tmp)
    else:
        print(tmp-L)
else:
    if N+L > -1:
        print(tmp)
    else:
        print(tmp - N - L + 1)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
tmp = 0
i = L
for _ in range(N):
    tmp += i
    i += 1
print(tmp)
if tmp == 0:
    print(0)
elif tmp > 0:
    if L < 1:
        print(tmp)
    else:
        print(tmp-L)
else:
    if N+L > -1:
        print(tmp)
    else:
        print(tmp - N - L + 1)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
tmp = 0
i = L
for _ in range(N):
    tmp += i
    i += 1
print(tmp)
if tmp == 0:
    print(0)
elif tmp > 0:
    if L < 1:
        print(tmp)
    else:
        print(tmp-L)
else:
    if N > L:
        print(tmp)
    else:
        print(tmp-(N+L-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
li = []
for i in range(n):
    li.append(i+l)
print(sum(li)-min(li))

Submission status: Wrong Answer

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

result = int((N + 2 * L - 1) / 2 * N)

if(L <= 0 and N + L >= 0): print(result)
elif(L > 0): print(result - L)
else: print(result - (N + L - 1))

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
aji=[]
for i in range(n):
    aji+=[l+i]
su=sum(aji)
c=[su]
c1=[su]
for i in range(n):
    c+=[su-aji[i]]
    c1+=[abs(su-aji[i])]
c.sort()
c1.sort()
print(c1[-2] if c1[-2]==c[-2] else -c1[-2] )

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
aji=[]
s=0
c=0
for i in range(n):
    aji+=[l+i]
su=sum(aji)
for i in range(n):
    s=su-aji[i]
    if su-c<su-s<su:
        c=s
print(c)

Submission status: Wrong Answer

Solution code:
N, L =map(int, input().split())
pie = L * N + N * (N - 1) * (1/2)
de = L
for i in range(1, N):
    if abs(de) > abs(L + i) :
        de = L + i
    if de == 0:
        break
print(pie - de)

Submission status: Wrong Answer

Solution code:
N, L =map(int, input().split())
pie = L * N + N * (N - 1) * (1/2)
de = L
for i in range(1, N):
    if de > L + i :
        de = L + i
    if de == 0:
        break
print(pie - de)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


A=[]
for i in range(N):
    a=L+i
    A.append(a)

T=0
for i in range(N):
    T+=A[i]

if T>0:
    A.pop(0)
elif T<0:
    A.pop(N-1)
    
    
T2=0
if T!=0:
    for i in range(N-1):
        T2+=A[i]
else:
    T2=T
        
print(T2)

Submission status: Wrong Answer

Solution code:
import math
N, L = map(int,input().split())
min = 1000
ans = 0
A = [0] * N
for i in range(N):
    A[i] = L + (i+1) - 1
    ans += A[i]

for i in range(N):
    a = math.fabs(A[i])
    if a < min:
        min = a
ans -= min
print(int(ans))

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,l = [int(x) for x in stdin.readline().rstrip().split()]
li = []
for i in range(1,n+1):
    aji = l + i -1
    li.append(aji)
li.sort(reverse=True)
li.pop()
print(sum(li))

Submission status: Wrong Answer

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

kind = [i + 1 for i in range( N )]
taste = [i + L for i in range( N )]
taste_abs = [abs(i+ L) for i in range( N )]


print(sum(taste) - min(taste_abs))

Submission status: Wrong Answer

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

kind = [i+1 for i in range(N )]
taste = [i+ L for i in range(N )]

print(sum(taste) - min(taste))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,L=map(int,input().split())
flag=0
judge=0
ans=[0]*N

for i in range(N):
    flag+=L+i

for i in range(N):
    ans[i]=abs(0-(L+i))

if (N+L)<0:
    print(flag-(N+L)+1)
else :
    print(flag-min(ans))

Submission status: Wrong Answer

Solution code:
N,L=map(int,input().split())
flag=0
ans=[0]*N

for i in range(N):
    ans[i]=abs(0-(i+L))
    
for i in range(N):
    flag+=L+i
    
print(flag-min(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,l=list(map(int, input().split()))
a=[l+i for i in range(n)]
absa=[abs(a[i]) for i in range(n)]
sum=0
for i in range(n):
	sum+=a[i]
print(sum-min(absa))

Submission status: Wrong Answer

Solution code:
N,L=map(int, input().split())
zenbu = N*(L-1) + (N*(N+1))/2

if L*(L+N-1) < 0:
    print(int(zenbu))
else:
    if L > 0:
        print(int(zenbu-L))
    else:
        print(int(zenbu-(L+N-1)))

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
dic = []
all_sum = sum([j + l -1 for j in range(1, n+1)])
for i in range(1, n+1):
  item = [j + l -1 for j in range(1, n+1) if j != i]
  dic.append(sum(item))
dist = abs(all_sum - dic[0])
for j in dic:
  tmp = abs(all_sum - j)
  if j < dist:
    dist = j
print(dist)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
ans=0
for i in range(b, b+a):
    ans+=i
if b<0 and a+b<0:
    ans-=i
elif b>0:
    ans-=b
print(ans)

Submission status: Wrong Answer

Solution code:
N,L =list(map(int, input().split()))
n = list(range(1,N+1))
tasteA = list(map(lambda x: x + L -1, n))
#tasteB = list(map(lambda x: x + L -1, tasteA))
tasteC = list(map(lambda x: abs(x), tasteA))
tasteD = sum(tasteA)-min(tasteC)
print(tasteD)

Submission status: Wrong Answer

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

total = N*(2*L+N-1)

if L>=0:
	small = L
elif L<0 and L+N-1>=0:
	small = 0
else:
	small = L+N-1
print(total - small)

Submission status: Wrong Answer

Solution code:
n,l=input().split(" ")
N=int(n)
L=int(l)
def sum(l,n):
    a=0
    for i in range (l,n+1):
        a+=i
    return a
def x(N,L):
    a=abs(L)
    b=1
    for i in range (1, N+1):
        if a>abs(L+i-1):
            b=i
            print(b)
            a=abs(L+i-1)
        else:
            print (b)
    print(a)
    return sum(L,L+N-1)-(L+b-1)
print (int(x(N,L)))

Submission status: Wrong Answer

Solution code:
n,l=input().split(" ")
N=int(n)
L=int(l)
def sum(l,n):
    a=0
    for i in range (l,n+1):
        a+=i
    return a
def x(N,L):
    a=abs(L)
    b=1
    for i in range (1, N+1):
        if a>abs(L+i-1):
            b=i
            a=L+i-1
    return sum(L,L+N-1)-(L+b-1)
print (int(x(N,L)))

Submission status: Wrong Answer

Solution code:
n,l=input().split(" ")
N=int(n)
L=int(l)
def sum(l,n):
    a=0
    for i in range (l,n+1):
        a+=i
    return a
def x(N,L):
    a=abs(L)
    for i in range (1, N+1):
        if a>abs(L+i-1):
            a=L+i-1
    return sum(L,L+N-1)-a
print (int(x(N,L)))

Submission status: Wrong Answer

Solution code:
n,l=input().split(" ")
N=int(n)
L=int(l)
def sum(l,n):
    a=0
    for i in range (l,n+1):
        a+=i
    return a
def x(N,L):
    a=L
    for i in range (1, N+1):
        if a>abs(L+i-1):
            a=L+i-1
    return sum(L,L+N-1)-a
print (int(x(N,L)))

Submission status: Wrong Answer

Solution code:
n,l=input().split(" ")
N=int(n)
L=int(l)
def x(N,L):
    if L+N-1<=0:
        return L*(N-1)+1/2*(N-1)*(N-2)
    elif (L-1)*(L+N-1)<=0:
        return L*N+1/2*(N-1)*N
    else:
        return L*N+1/2*(N-1)*N-L
print (int(round(x(N,L))))

Submission status: Wrong Answer

Solution code:
n,l=input().split(" ")
N=int(n)
L=int(l)
def x(N,L):
    if L+N-1<=0:
        return L*(N-1)+1/2*(N-1)*(N-2)
    elif (L-1)*(L+N-1)<=0:
        return L*N+1/2*(N-1)*N
    else:
        return L*N+1/2*(N-1)*N-L
print (int(x(N,L)))

Submission status: Wrong Answer

Solution code:
n,l=input().split(" ")
N=int(n)
L=int(l)
def x(N,L):
    if L+N-1<0:
        return L*(N-1)+1/2*(N-1)*(N-2)
    elif (L-1)*(L+N-1)<=0:
        return L*N+1/2*(N-1)*N
    else:
        return L*N+1/2*(N-1)*N-L
print (int(x(N,L)))

Submission status: Wrong Answer

Solution code:
N,L = map(int,input().split())
aji = [L+i for i in range(N)]
ate = 10000
for a in aji:
  if abs(ate) > abs(a):
    ate = a
print(sum(aji)-a)

Submission status: Wrong Answer

Solution code:
N,L = map(int,input().split())
aji = [L+i for i in range(N)]
ate = 10000
for a in aji:
  if abs(ate) > a:
    ate = a
print(sum(aji)-a)

Submission status: Wrong Answer

Solution code:
N,L=map(int,input().split())
sum=(L-1)*N+(N+1)*N//2
mi=1000
for i in range(1,N+1):
    temp=L+i-1
    if abs(temp)<mi:
        idx=i
        mi=abs(temp)

print(sum-L+idx-1)

Submission status: Wrong Answer

Solution code:
N,L=map(int,input().split())
sum=(L-1)*N+(N+1)*N//2
mi=1000
for i in range(1,N+1):
    temp=L+i-1
    if abs(temp)<mi:
        idx=i
        mi=temp

print(sum-L+idx-1)

Submission status: Wrong Answer

Solution code:
N,L=map(int, input().split())
Apple=list(range(L, L+N))

if min(Apple)<0:
    print(sum(Apple)-max(Apple))
else:
    print(sum(Apple)-min(Apple))

Submission status: Wrong Answer

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

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

if N > abs(L):
    if l[0] > 0:
        print(sum(l)-l[0])
    else:
        print(sum(l))
else:
    print(sum(l) - l[N-1])

Submission status: Wrong Answer

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

if l <= 0:
  if -1 * l >= n:
    n -= 1
else:
  l += 1
  n -= 1

print(int(n *(2+l+n-1)/2))

Submission status: Wrong Answer

Solution code:
i = list(map(int, input().split()))
n = i[0]
l = i[1]
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)

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
if 0<l:
  print(sum([l+i for i in range(n)][1:]))
elif l<0 and 0<=l+n:
  print(sum([l+i for i in range(n)]))
else:
  print(sum([l+i for i in range(n)][:-1]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, L = (int(a) for a in input().split())
if N + L < 0:
    x = N + L -1
elif L < 0 and N + L >= 0:
    x = 0
else:
    x = L
sum = 0
for i in range(1,N+1):
    if x == L + i - 1:
        continue
    sum += L + i - 1
print(sum)

Submission status: Wrong Answer

Solution code:

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

app = list(range(-1+a[1]+1,a[0]+a[1]-1+1))
apabs = list(range(-1+a[1]+1,a[0]+a[1]-1+1))

for i in range(len(app)):
    if app[i]<0:
        apabs[i]=app[i]*-1
    else:
        apabs[i]=app[i]
print(sum(app)-min(apabs))

Submission status: Wrong Answer

Solution code:

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

app = list(range(-1+a[1]+1,a[0]+a[1]-1+1))
apabs = app

for i in range(len(apabs)):
    if apabs[i]<0:
        apabs[i]=apabs[i]*-1
    else:
        apabs[i]=apabs[i]
print(sum(app)-min(apabs))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import bisect

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

L_list =[]

for i in range(1,N+1):
    L_list.append(L+i-1)

L_list.sort()

index = bisect.bisect_left(L_list, 0)

if index == N :
    L_list.pop(index-1)

print(sum(L_list))

Submission status: Wrong Answer

Solution code:
def choice(N,L):
    min = 99999
    for x in range(1,N+1):
        tmp = abs(L+x-1)
        if tmp < min:
            min = tmp
    return min
N,L = map(int,input().split())
t = N*L + N*N/2 - N/2
bite = choice(N,L)
t = int(t) - bite
print(t)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, L = input().split()
sum = 0
for i in range(1,int(N)+1):
    sum+=int(L)+i-1
if int(L) <= 0:
    if int(N) > -int(L):
        print(sum)
    else:
        print(sum-int(L)-int(N))
else:
    print(sum-int(L))
#print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, L = map(int,input().split())
A=0
if L > 0:
  for i in range(1,N):
    A += L + i
elif L*(-1) > N:
  for s in range(N-1):
    A += L + s
else:
  for w in range(N):
    A += L + w
print(A)

Submission status: Wrong Answer

Solution code:
N, L = map(int,input().split())
A=0
if L > 0:
  for i in range(1,N):
    A += L + i
elif L < 0 and L*(-1) > N:
  for s in range(N-1):
    A += L + s
else:
  for w in range(N):
    A += L + w
print(A)

Submission status: Wrong Answer

Solution code:
N,L = map(int,input().split())
inf = float('inf')
eat = inf
ans = 0
for i in range(N):
    eat = min(eat, abs(L+i))
if L > 0:
    s = eat - L + 1
else:
    s = abs(eat + L -1)
print(s)
for i in range(1,N+1):
    if s == i:
        continue
    ans += L + i -1
print(ans)

Submission status: Wrong Answer

Solution code:
N,L = map(int,input().split())
A = []
for i in range(N):
  A.append(L+i)
A.remove(min(A))
print(sum(A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,L=map(int, input().split())
j = 0 if L>0 else N-1 if -L>N else -L 
aji=0
for i in range(N):
  aji+=L+i
aji-=(L+j)
print(aji)

Submission status: Wrong Answer

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

A_list = []
aji = 0

for i in range(N):
    A_list.append(L + i -1)
    aji += (L + i - 1)

#print(A_list)

#絶対値が0に一番近いものを取り出す
x = min(A_list,key= lambda A_list:abs(A_list))
#print(x)

aji -= x
print(aji)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
total = 0
for i in range(1, N+1):
    val = L + i - 1
    total += val

if total < 0:
    print(total - (L + N - 1))
elif total == 0:
    print(total)
else:
    print(total-L)

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
lst_l = list(range(l, l + n))
if 0 in lst_l:
    print(sum(lst_l))
else:
    if lst_l[0] > 1:
        print(sum(lst_l[1:]))
    else:
        print(sum(lst_l[:-1]))

Submission status: Wrong Answer

Solution code:
n, l= map(int, input().split())
apple = range(l, l+n)
cnt = sum(apple)
ans = []
for i in apple:
    ans.append(abs(i))
print(cnt - min(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
a=0
b=1000
for i in range(l,l+n):
  a+=i
  if b>abs(i):
    b=i
print(a-b)

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
a=0
b=1000
for i in range(l,l+n):
  a+=i
  b=min(1000,abs(i))
print(a-b)

Submission status: Wrong Answer

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

pai = 0
for n in range(N):
    if L < 0:
        if L+n == 0:
            next

    pai = pai + L + n

if L+N < 0:
    pai = pai - (L + N - 1)

if L > 0:
    pai = pai - L

print(pai)

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
li = []
for i in range(1,n+1):
  li.append(abs(l+i-1))
m = min(li)
if l+i-1 >= 0:
  print(int((n*(l-1)+(n*(n+1)/2)-l-i+1)))
else:
  print(int((n*(l-1)+(n*(n+1)/2)+l+i-1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, l = list(map(int ,input().split()))
sumApple = sum(range(l,l+n))
aMin = 10000
for i in range(n):
    if abs(l + i) < aMin:
        aMin = abs(l + i)
print(sumApple - aMin)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
a = [L + i for i in range(N)]
b = list(map(lambda x:abs(x), a))
c = b.index(min(b))
del a[c]
print(sum(j) for j in a )

Submission status: Wrong Answer

Solution code:
N, L = [s for s in input().split()]


apples_taste = []
abs_apples_taste = []

for i in range(int(N)):
  apples_taste.append(i+int(L))
  abs_apples_taste.append(abs(i+int(L)))

abs_apples_taste.sort()
print(sum(apples_taste) - abs_apples_taste[0])

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
v=[l+i-1for i in range(1,n+1)]
print(n,l,v)
if l>=0:
  v.pop(0)
elif n<=abs(l): #v=0となるiがあるということ
  v.pop(n-1)
print(sum(v))

Submission status: Wrong Answer

Solution code:
import sys
N, L = map(int, sys.stdin.readline().split())
tastes= [L+i-1 for i in range(1, N+1)]

if 0 < L:
  tastes.pop(0)

elif L+N < 0:
  tastes.pop(-1)

print(sum(tastes))
exit()

Submission status: Wrong Answer

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

eat_taste = 99999
sum_taste = 0
for i in range(n):
  taste = l + i
  sum_taste += taste
  if abs(taste) < eat_taste:
    eat_taste = abs(taste)
print(sum_taste - eat_taste)

Submission status: Wrong Answer

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

eat_taste = 99999
sum_taste = 0
for i in range(n):
  taste = l + i
  sum_taste += taste
  if taste < eat_taste:
    eat_taste = taste
print(sum_taste - eat_taste)

Submission status: Wrong Answer

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

eat_taste = 99999
for i in range(n):
  taste = l + i
  if taste < eat_taste:
    eat_taste = taste
  if taste == 0:
    print(0)
    break
else:
  print(eat_taste)

Submission status: Wrong Answer

Solution code:
(N,L)=input().split(' ')
N = int ( N )
L = int ( L )
A=[]
B=[]
for i in range ( N ):
    A.append ( L+i )    
    B.append ( abs ( L+i ) )

B.sort ( )

if ( sum(A) < 0 ):    
    print ( -1*sum(B[1:]) )
else:
    print ( sum(B[1:]) )

Submission status: Wrong Answer

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

state = [0 for _ in range(N)]

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

tmp = 10 ** 9

for i in range(N):
    tmp = min(tmp, abs(sum(state) - sum(state)-state[i]))

print(sum(state)-tmp)

Submission status: Wrong Answer

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

state = [0 for _ in range(N)]

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

tmp = 10 ** 9

for i in range(N):
    tmp = min(tmp, sum(state)-state[i])
print(tmp)

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
min_abs = 10**9
ans = 0
for i in range(n):
    ans += l + i
    if abs(l + i) < min_abs:
        min_abs = abs(l+i)
print(ans-min_abs)

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
min_abs = 10**9
tmp = 10**9
for i in range(n):
    if abs(l + i) < min_abs:
        min_abs = abs(l+i)
        tmp = i
print(min_abs)
ans = 0
for i in range(n):
    if i == tmp:
        continue
    else:
        ans += l + i

print(ans)

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
min_abs = 99
tmp = 99
for i in range(n):
    if abs(l + i) < min_abs:
        min_abs = abs(l+i)
        tmp = i

ans = 0
for i in range(n):
    if i == tmp:
        continue
    else:
        ans += l + i

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n,l = map(int,input().split())

apple=np.array(list(range(1,n+1,1))) 
taste = np.array(list(range(1,n+1,1))) + l -1

if np.min(taste) > 0:
    ans =np.sum(taste) - taste[0]

elif np.min(taste)<0 and np.max(taste)>0 :
    ans =np.sum(taste)
else:
    ans =np.sum(taste) - np.max(taste) 

print(ans)

Submission status: Wrong Answer

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

if 0 in list_taste:
  ans = sum(list_taste)
else:
  ans = sum(list_taste) - min(list_taste)

print(ans)

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
s=int(n/2*(n-1+l+l))
m=[]
for i in range(n):
    m.append(abs(s-l+i))
print(min(m))

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
s=int(n*(n+l*2)/2)
m=[]
for i in range(n):
    m.append(abs(s-l+i))
print(min(m))

Submission status: Wrong Answer

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

A = []
B = []
for i in range(N):
    A.append(L+i-1)
    B.append(abs(L-i+1))
    if abs(L-i+1) == min(B):
        ans = sum(A)-(L-i+1)
        print(ans)
        break

Submission status: Wrong Answer

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

for i in range(N):
    A = [L+i-1]
    B = [abs(L-i+1)]
    if abs(L-i+1) == min(B):
        ans = sum(A)-(L-i+1)
        print(ans)
        break

Submission status: Wrong Answer

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

for i in range(N):
    A = [abs(L-i+1)]
    if abs(L-i+1) == min(A):
        ans = (N-1)*L+(N-1)*N/2-i+1
        print(ans)