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:
a,b=map(int,input().split())
if b>=0:
  print(int((a+2*b)*(a-1)/2))
elif a+b>=0:
  print(int((a+2*b-1)*a/2))
else:
  print(int((a+2*b-2)*(a-1)/2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
ans = l 
k = 0
sum = 0
for i in range(1,n):
    if abs(ans) > abs(l + i):
        k = i
for i in range(n):
    if i != k:
        sum += l + i
print(sum)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#ABC131 B

N,L = map(int,input().split())
aji = []
delta = []
for i in range(N):
    aji.append(L + i)
for j in range(N):
    delta.append(abs(aji[i]))
print(sum(aji) - min(delta))

Submission status: Wrong Answer

Solution code:
#ABC131 B

N,L = map(int,input().split())
aji = []
delta = []
for i in range(N):
    aji.append(L + i)
for j in range(N):
    delta.append(abs(aji[i]))
print(sum(aji) - min(aji))

Submission status: Wrong Answer

Solution code:
#ABC131 B

N,L = map(int,input().split())
aji = []
delta = []
for i in range(N):
    aji.append(L + i)
for j in range(N):
    delta.append(abs(aji[i]))
print(min(delta))

Submission status: Wrong Answer

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

# 0があれば0を選ぶ
# すべて正またはすべて負 > 絶対値の一番小さいものを選ぶ
ans = 0

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

    if L + N < 0:
        print(((2 * L + N - 1) * N) // 2 - (L + N - 1))

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

Submission status: Wrong Answer

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

# 0があれば0を選ぶ
# すべて正またはすべて負 > 絶対値の一番小さいものを選ぶ
ans = 0

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
 
# 元々の味: s
s = (N-1)*(2*L+N-1) // 2
l = [abs(L+i) for i in range(N)]

print(s - (L+l.index(min(l))))

Submission status: Wrong Answer

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

print(s-m)

Submission status: Wrong Answer

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

s = (N-1)*(2*L+N-1)/2
m = s
for i in range(N):
  m = min(m, abs(s-(L+i)))
  
print(m)

Submission status: Wrong Answer

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

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

for i in range(n):
  t = s - (l-1+i)
  T = abs(s-t)
  if T < c:
    c = T
    j = i
    
ans = s -(l+j)
print(int(ans))

Submission status: Wrong Answer

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

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

for i in range(n):
  t = s - ((l-1)-1)
  T = abs(s-t)
  if T < c:
    c = T
    j = i
    
e = l+j
print(int(s-e))

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
tastes = [ L+x for x in range(N) ] 

if 0 in tastes:
    print(sum(tastes))

if L<0:
    absmin = max(tastes)
    print(sum(tastes)-absmin)
elif L>0:
    absmin = min(tastes)
    print(sum(tastes)-absmin)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
lst = input()
lst = lst.split()


for i in range(len(lst)):
    lst[i]= int(lst[i])
N = lst[0]
L = lst[1]
q = L
l = 0
lste = [abs(L)]
tlst = []
for i in range(2,N+1):
    t = L+i-1
    q += t
    tlst.append(t)
    t = abs(t)
    lste.append(t)


slst = sorted(lste)
print(slst)
l = slst[0]
if tlst.count(-l) > 0:
    print('ok')
    print(q+l)
else:
    print(q-l)

Submission status: Wrong Answer

Solution code:
lst = input()
lst = lst.split()


for i in range(len(lst)):
    lst[i]= int(lst[i])
N = lst[0]
L = lst[1]
q = L
l = 0
lste = [abs(L)]
tlst = []
for i in range(2,N+1):
    t = L+i-1
    q += t
    tlst.append(t)
    t = abs(t)
    lste.append(t)


slst = sorted(lste)
l = slst[0]
if tlst.count(-l) > 0:
    print(q+l)
else:
    print(q-1)

Submission status: Wrong Answer

Solution code:

N,L=map(int,input().split())
#L+i-1,i>=1
nin=10**6
for i in range(N):
    if abs(L+i)<nin:
        nin=abs(L+i)
        nn=L+i

ans=N*(L-1)+N*(N+1)*0.5-(nn)

print(ans)

Submission status: Wrong Answer

Solution code:
n, l =list(map(int, input().split()))
arr = []
for k in range(1, n+1):
  arr.append(l + k - 1)
print(arr)
arr.remove(min(arr))
print(arr)
print(sum(arr))

Submission status: Wrong Answer

Solution code:
N,L=map(int,input().split())
s=0
l=[]
for i in range(N):
    s+=L+i
    l.append(abs(L+i))
l=sorted(l)
if l[0]<L:
    s-=l[0]
else:
    s+=l[0]
print(s)

Submission status: Wrong Answer

Solution code:
N,L=map(int,input().split())
s=0
l=[]
for i in range(N):
    s+=L+i
    l.append(abs(L+i))
l=sorted(l)
print(l)
s-=abs(l[0])
print(s)

Submission status: Wrong Answer

Solution code:
r=input().split()
N=int(r[0])
L=int(r[1])
ans=0
ans_li=[]
for i in range(N):
    ans+=L-(i+1)-1
    ans_li.append(L-(i+1)-1)
if 0 in ans_li:
    print(ans)
elif max(ans_li)>0:
    print(ans-min(ans_li))
else:
    print(ans-max(ans_li))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

ans = float("inf")

for apple in apples:
  ans = min(ans,abs(apple))
  
print(sum(apples) - ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

min = abs(taste_lists[0])
index = 0
for i in range(n):
    if abs(taste_lists[i]) < min:
        index = i

taste_lists.pop(index)

ans = 0
for i in taste_lists:
    ans += i

print(ans)

Submission status: Wrong Answer

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

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

min = abs(taste_lists[0])
index = 0
for i in range(n):
    if abs(taste_lists[i]) <= min:
        index = i

taste_lists.pop(index)

ans = 0
for i in taste_lists:
    ans += i

print(ans)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
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(taste)

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

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

c = 0

if l > 0:
    c = ((l+1) + (l+n-1)) * (n-1) // 2
elif l <= 0 <= l + n - 1:
    c = ((l) + (l+n-1)) * (n-1) // 2
else:
    c = ((l) + (l+n-2)) * (n-1) // 2

print(c)

Submission status: Wrong Answer

Solution code:
def abs_minimum_extraction(lst):
    lst1 = []
    n = len(lst)

    for i in range(n):
        lst1.append(abs(lst[i]))

    lst1.sort()
    abs_minimum = lst1[0]

    return abs_minimum


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 = abs_minimum_extraction(taste_lst)
    taste = taste_total - taste_bite

    print(taste)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
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 <= 1:
    print(s)
else:
    print(s-l)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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
print(ans-min)

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
a = list([k + l for k in range(n)])
sum_ = sum(a)
min_ = float("inf")

for j in range(n):
    min_ = min(min_, abs(a[j]))
print(sum_ - min_)

Submission status: Wrong Answer

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

min_ = float("inf")
ans = 0
for j in range(n):
    aji = l + j
    min_ = min(min_, aji)
    ans += aji
ans = ans - min_

print(ans)

Submission status: Wrong Answer

Solution code:
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])
sum(A)-A[B.index(min(B))]

Submission status: Wrong Answer

Solution code:
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(n*l+(n-1)*n/2-x)

Submission status: Wrong Answer

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

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

print(sum(taste) - eat)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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<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()

Submission status: Wrong Answer

Solution code:
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<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()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
  n,l = list(map(int,input().split()))
  ans=0
  if l>0:
    for i in range(2,n+1):
      print(l+i-1)
      ans+= l+i-1
  elif n+l<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()

Submission status: Wrong Answer

Solution code:
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:
    ans = sum(A) - A[0]

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
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]

print(sum(lists))

Submission status: Wrong Answer

Solution code:
from collections import deque

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

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

Submission status: Wrong Answer

Solution code:
N,L = map(int,input().split())
LL =[]
for i in range(1,N+1):
  LL.append(L+i-1)
LLL=[]
for j in LL:
  LLL.append(abs(sum(LL)-j))
LLLL=sorted(LLL)
print(sum(LL)-LLLL[0])

Submission status: Wrong Answer

Solution code:
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:
  mins = min(mins, abs(i))
print(sum(l) - mins)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
taste = [l+i-1 for i in range(n)]
eaten = 9999
for t in taste:
  if abs(t) < eaten:
    eaten = t
res = sum(taste) - eaten
print(res)

Submission status: Wrong Answer

Solution code:
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
print(min(def_apple_pie))

Submission status: Wrong Answer

Solution code:
N,L = map(int,input().split())
a = [0]*N
for i in range(N):
  a[i] = L+i
all_apple = sum(a)
apple_pie = [0]*N
for i in range(N):
  t = a[i]
  a[i] = 0
  apple_pie[i] = sum(a)
  a[i] = t
print(max(apple_pie))

Submission status: Wrong Answer

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

taste = [l + i - 1 for i in range(1, n + 1)]
taste_all = sum(taste)
taste_min = min([abs(t) for t in taste])
print(taste_all - taste_min)

Submission status: Wrong Answer

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

all=0
for i in range(N):
    all =all +L+(i+1)-1
 
dif=all
for i in range(N):
    if abs(all-dif) <= abs(all-(L+(i+1)-1)):
        dif =L+(i+1)-1
 
print(all-dif)

Submission status: Wrong Answer

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

all=0
now=0
for i in range(N):
    all =all +L+(i+1)-1

dif=0
for i in range(1,N+1):
    if abs(all-dif) >= abs(all-L+i-1):
        dif =L+i-1



print(all-dif)

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
a=[]
cnt=100
index=-1
for i in range(n):
  a.append(l+i)
for i in range(n):
  if cnt>=abs(0-a[i]):
    cnt=abs(0-a[i])
    index+=1
print(sum(a)-a[index-1])

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
a=[]
cnt=100
index=0
for i in range(n):
  a.append(l+i)
for i in range(n):
  if cnt>abs(0-a[i]):
    cnt=abs(0-a[i])
    index+=1
print(sum(a)-a[index-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

apple = [L+i for i in range(N)]
print(apple)
min = 500
for k in range(len(apple)):
    if abs(apple[k])<abs(min):
        min = apple[k]

apple.remove(min)
print(sum(apple))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, k = map(int, input().split())
print(k * (n - 1) + n * (n - 1) // 2 + k * (k < 0) - (k + n - 1) * (-n > k))

Submission status: Wrong Answer

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

if abs(L-1) <= N:
  i = abs(L - 1)
else:
  i = N

A = (N-1)*(L-1) + sum([n for n in range(1, N+1)]) - i
print(A)

Submission status: Wrong Answer

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

if abs(L-1) <= N:
  i = abs(L - 1)
else:
  i = N

A = (N-1)*(L-1) + sum([n for n in range(N+1)]) - i
print(A)

Submission status: Wrong Answer

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

if abs(L-1) < N:
  i = abs(L - 1)
else:
  i = N

A = (N-1)*(L-1) + sum([n for n in range(N+1)]) - i
print(A)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, L = map(int, input().split())
S = np.arange(1,N+1)
S = S + (L-1)
print(sum(S)-min(abs(S)))

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
S = []
for i in range(N):
    S.append(i+1)
S2 = list(map(lambda x:x+(L-1), S))
print(sum(S2)-abs(min(S2)))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,L  = map(int,input().split())
L_list=np.array(range(1,N+1))+L-1
print(sum(L_list))
if (0 in L_list):
    print(sum(L_list))
    exit()
if(N<=abs(L) and L<0):
    print(sum(L_list)-L_list[N-1])
    
    exit()
else:
    print(sum(L_list)-L_list[0])
    exit()

Submission status: Wrong Answer

Solution code:
import numpy as np
N,L  = map(int,input().split())
L_list=np.array(range(1,N+1))+L-1
if (0 in L_list):
    print(sum(L_list))
    exit()
if(N<abs(L) and L<0):
    print(sum(L_list)-L_list[N-1])
    exit()
else:
    print(sum(L_list)-L_list[0])
    exit()

Submission status: Wrong Answer

Solution code:
import numpy as np
N,L  = map(int,input().split())
L_list=np.array(range(1,N+1))+L-1
if (0 in L_list):
    print(sum(L_list))
    exit()
if(N<abs(L)):
    print(sum(L_list)-L_list[N-1])
    exit()
else:
    print(sum(L_list)-L_list[0])
    exit()

Submission status: Wrong Answer

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

li.sort()
S=sum(li)
for j in range(N-1):
    if abs(li[j])<=abs(li[j+1]):
        S-=li[j]
        print(li[j])
        break

if j==N-2:
    S-=li[N-1]

print(S)

Submission status: Wrong Answer

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

tot=N*L+(N-1)*N/2
ans=[]


for i in range(N):
    ans.append(abs(L+i))

a=ans.index(min(ans))

print(tot-(a+L))

Submission status: Wrong Answer

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

tot=N*L+(N-1)*N/2
ans=[]


for i in range(N):
    ans.append(abs(L+i))

print(tot-min(ans))

Submission status: Wrong Answer

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

tot=N*L+(N-1)*N/2
ans=[]


for i in range(N):
    ans.append(abs(tot-(L+i)))

print(int(max(ans)))

Submission status: Wrong Answer

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

tot=N*L+(N-1)*N/2
ans=[]


for i in range(N):
    ans.append(abs(tot-(L+i)))

print(max(ans))

Submission status: Wrong Answer

Solution code:
N,L = list(map(int,input().split()))
app_taste = list(range(L,L+N))
bite_apple=200
for i in app_taste:
    if abs(bite_apple) > abs(i):
        bite_apple = i
print(sum(app_taste) - i)

Submission status: Wrong Answer

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

del ans[ans.index(min(ans))]
print(sum(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 131 B

n, l = map(int, input().split())
cmin = float('inf')
sum = 0

for i in range(1, n+1):
    f = l + i - 1
    sum += f
    if f >= 0:
        cmin = min(cmin, f)
    else:
        cmin = max(cmin, f)

print(sum - cmin)

Submission status: Wrong Answer

Solution code:
import math
import datetime
from math import fabs
inp,var = map(int, input().split())
var3 = [var+i-1 for i in range(1,inp+1)]
for i in var3:
    i=fabs(i)
var2 = min(var3)
x=sum(var3)-var2
print(x)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
total=a*(a+2*b-1)//2
x=b
y=a+b-1
z=min(abs(x),abs(y))
if x<=0 and y>=0:
  print(total)
else:
  print(total-z)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
total=a*(a+2*b-1)//2
if a<0 and (a+2*b-1)>0:
  print(total)
else:
  print(total-min(abs(b),abs(a+b-1)))

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
a = [l+i for i in range(n)]
ans = 10000
for i in a:
  if abs(i) < ans:
    ans = abs(i)
print(sum(a)-ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
no=1000
num=0
for i in range(n):
    if abs(l+i)<no:
        no=abs(l+i)
        num=i
ans=0
for i in range(n):
    ans+=abs(l+i)
ans=ans-abs(l+num)
print(ans)

Submission status: Wrong Answer

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

min1 = 100
min2 = 10000

for j in a_l:
    if j ** 2 <= min2:
        min2 = j **2
        min1 = j
print(sum(a_l) - j)

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
ans=float('inf')
for i in range(1,n+1):
  ans=min(ans,abs(l+i-1))
  
#print(ans)
print((l*n+n*(n-1)//2)+1*ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l = 0
m = 10000
for i in range(1,N+1):
  l += L+i-1
  m = min(m,abs(L+i-1))

l -= m
print(l)

Submission status: Wrong Answer

Solution code:
n,l = map(int, raw_input().split(' '))
m = (+float('inf'), -1)
cumul = 0
for a in range(1, n + 1):
  	cumul += l + a -1 
	m = min(m, (l + a - 1, a))
print cumul - m[0]

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

r = [l+i for i in range(n)]
min_r = 1000000000
for i in r:
    if min_r > abs(i):
        min_r = abs(i)
        ans = i
print(sum(r)-i)

Submission status: Wrong Answer

Solution code:
def resolve():
    N, L = map(int, input().split())
    list = []
    for i in range(N):
        list.append(L+i)
    if list.count("0") != 0:
        print(sum(list))
    elif min(list) > 0:
        print(sum(list) - min(list))
    else:
        print(sum(list) - max(list))
resolve()

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
tast = list(range(1,n+1))
tast = list(map(lambda x: l+x-1,tast))
s = sum(tast)
ans = 10**12

for i in range(n):
    tmp = sum([y if tast[i]!=y else 0 for y in tast])
    if ans >= abs(s -tmp):
        ans = abs(s -tmp)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3


def main():
    N, L = map(int, input().split())
    if L >= 1:
        # L + 1 から L + N - 1 の和
        print((N - 1) * (2 * L + N) // 2)
    elif L <= - N + 1:
        # L から L + N - 2 の和
        print((N - 1) * (2 * L + N - 2) // 2)
    else:
        # L から L + N - 1 の和
        print((N - 1) * (2 * L + N - 1) // 2)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3


def main():
    N, L = map(int, input().split())
    if L >= 0:
        # L + 1 から L + N - 1 の和
        print((N - 1) * (2 * L + N) // 2)
    elif L <= - N + 1:
        # L から L + N - 2 の和
        print((N - 1) * (2 * L + N - 2) // 2)
    else:
        # L から L + N - 1 の和
        print((N - 1) * (2 * L + N - 1) // 2)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3


def main():
    N, L = map(int, input().split())
    if L >= 0:
        # L + 1 から L + N - 1 の和
        print((N - 1) * (2 * L + N) // 2)
    elif L <= -N:
        # L から L + N - 2 の和
        print((N - 1) * (2 * L + N - 2) // 2)
    else:
        # L から L + N - 1 の和
        print((N - 1) * (2 * L + N - 1) // 2)


if __name__ == '__main__':
    main()