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:
# B
n,l = map(int,input().split())
ans=0
for i in range(1,n+1):
    if i == 1:
        continue
    else:
        ans+=(l+i-1)
print(ans)

Submission status: Wrong Answer

Solution code:
n,l =map(int,raw_input().split())
nl = [l+i-1 for i in xrange(1,n+1)]
 
if sum(nl) in nl:
    print sum(nl)
elif nl[-1]  > 0:
    print sum(nl[1:]) 
else:
    print sum(nl[:-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
A = list(range(1, N+1))
ans = 0
saisyo = float("inf")
saidai = -float("inf")
for i in range(N):
    x = A[i] + L-1 
    saisyo = min(x, saisyo)
    saidai  = max(x, saisyo)
    ans += x
if saidai < 0:
    print(ans-saidai)
else:
    print(ans-saisyo)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
A = list(range(1, N+1))
ans = 0
saisyo = float("inf")
saidai = -float("inf")
for i in range(N):
    x = A[i] + L-1 
    saisyo = min(x, saisyo)
    saidai  = max(x, saisyo)
    ans += x
if saisyo >=0:
    print(ans-saisyo)
else:
    print(ans-saidai)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
A = list(range(1, N+1))
ans = 0
saisyo = float("inf")
for i in range(N):
    x = A[i] + L-1 
    saisyo = min(abs(x), saisyo)
    if x != saisyo:
        ans += x
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
taste = l
num = 1
for i in range(1, n+1):
    if abs(taste) > abs(l+i-1):
        num = i
print((n*(2*l+n-1)//2) - l - num +1)

Submission status: Wrong Answer

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

apples = [l-i for i in range(n)]

eat = float('inf')
for a in apples:
  eat = a if abs(a)< abs(eat) else eat
  
print(sum(apples) - eat)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

n_sum = (l*n)+sum(list(range(1,n+1)))-n
ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:

n, l = map(int, input().split())
data = [l] * n
ans = 0

for i in range(n):
    data[i] += i
    ans += data[i]

mini = abs(data[0])
temp = data[0]
print(ans)
print(data)
for i in range(n):
    if mini > abs(data[i]):
        mini = abs(data[i])
        temp = data[i]

print(ans - temp)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

apple = [L + n for n in range(N)]
eat_apple = min(map(abs, apple))
print(sum(apple) + eat_apple)

Submission status: Wrong Answer

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

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

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

print(s-eat)

Submission status: Wrong Answer

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

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

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

print(s-eat)

Submission status: Wrong Answer

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

x =[]

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

for i in x:
  m = min(abs(m),abs(i))
  
sum_x = sum(x) - m  
  
print(sum_x)

Submission status: Wrong Answer

Solution code:
import numpy as np

N,L=map(int,input().split())
taste=list(range(L,L+N))
#print(sum(taste))
min_abs=10**5
for i in range(N):
    if abs(taste[i])<min_abs:
        min_abs=taste[i]
        #rec=taste[i]
        #print(rec)
        
        
print(sum(taste)-min_abs)

Submission status: Wrong Answer

Solution code:

N,L=map(int,input().split())
taste=list(range(L,L+N))
min_abs=10**5
for i in range(N):
    if abs(sum(taste)-taste[i])<min_abs:
        min_abs=abs(sum(taste)-taste[i])
        rec=taste[i]
        
        
print(sum(taste)-taste[i])

Submission status: Wrong Answer

Solution code:
#両端のりんごの味は、(L, L+N-1)
N, L = map(int, input().split())
sum_all = N*(L+((N+1)/2)-1)

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

Submission status: Wrong Answer

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

ans=10*6
s = sum(a)
for j in range(N):
  t = s - a[j]
  if abs(t-s) < abs(ans -s):
    ans = t
print(t)

Submission status: Wrong Answer

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

ans=10*6
for j in range(N):
  tmp = L+j
  if abs(tmp) < abs(ans):
    ans = tmp
print(taste - ans)

Submission status: Wrong Answer

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

ans=10*6
for j in range(N):
  tmp = L+j
  if abs(tmp) < abs(ans):
    ans = tmp
print(taste - tmp)

Submission status: Wrong Answer

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

ans=10*6
p=-1
for j in range(N):
  tmp = abs(L+j)
  if tmp < ans:
    ans = tmp
    p = j
print(taste -(L+p))

Submission status: Wrong Answer

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

ans=10*6
p=-1
for j in range(N):
  tmp = abs(L+i)
  if tmp < ans:
    ans = tmp
    p = i
print(taste -(L+p))

Submission status: Wrong Answer

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

diff=10*6
for j in range(N):
  if abs(L+j) < abs(diff):
    diff = L+j
print(taste - diff)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

diff=10*6
index=-1
for i in range(N):
  if abs(L+i) < diff:
    diff = abs(L+i)
    index = i
print(taste - (L+i))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
if L > 0:
    num = L
elif N + L >= 0:
    num = 0
else:
    num = N + L - 1
ans = 0

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

ans -= num
print(ans)

Submission status: Wrong Answer

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

m = max(taste)
for e in taste:
  if abs(e) < m:
    m = abs(e)
print(m,sum(taste) - m)

Submission status: Wrong Answer

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

m = max(taste)
for e in taste:
  if abs(e) < m:
    m = e
print(sum(taste) - m)

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
summation = (n - 2) * l + n * (n - 1) // 2
minimum = abs(summation)
applepie = summation + l
for i in range(1, n):
  diff = abs(summation - 2 * i)
  if diff < minimum:
    minimum = diff
    applepie = summation + l + i
print(applepie)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

sum_n = 0
min = 100
ans = 0

for i in range(1, n+1):
    sum_n += L + i -1

    if(abs(L+i-1) < min):
        min = abs(L+i-1)
        ans = L+i-1
print(sum_n-ans)

Submission status: Wrong Answer

Solution code:
a = input().split()
N, L = [int(i) for i in a]
for i in range(N):
  dif = abs(L+i-1)
  m = 0
  if dif < abs(L+m):
    m = i
  else:
    continue
sol = (N-1)*L + (N-1)*N/2 - (L+m-1)
print(int(sol))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
taste_abs = [abs(l + i) for i in range(n)]
index = taste_abs.index(min(taste_abs))
taste_abs.pop(index)
print(sum(taste_abs))

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
taste = [l+i for i in range(n)]
s=sum(taste)
for i in range(l+n+2):
  if i in taste:
    print(s-i)
    exit()
  if -i in taste:
    print(s+i)
    exit()

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
taste = [l+i for i in range(n)]
s=sum(taste)
for i in range(l+1):
  if i in taste:
    print(s-i)
    exit()
  if -i in taste:
    print(s+i)
    exit()

Submission status: Wrong Answer

Solution code:
#128 b むずい
n,l=map(int,input().split())
aji=[i+l for i in range(n)]
ans=sum(aji)-min(aji)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
listNL = [i for i in range(L, N+L)]
sumNL = sum(listNL)

minNL = 101

for j in range(N):
    if listNL[j] >= 0:
        minNL = min(minNL, listNL[j])
    else:
        minNL = (-1)*(min(abs(minNL), abs(listNL[j])))

print(sumNL - minNL)

Submission status: Wrong Answer

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

apples.sort()
print(sum(apples[1:]))

Submission status: Wrong Answer

Solution code:
import numpy as np

def LI():
  return [int(s) for s in input().split()]

N,L = LI()
ringo = np.array(list(range(1,N+1))) + L - 1

taste_all = sum(ringo)

min_index = 0
min_abs = abs(ringo[0])

for i in range(1,N):
  if min_abs < abs(ringo[i]):
    min_index = i
    min_abs = abs(ringo[i])

print(taste_all - ringo[min_index])

Submission status: Wrong Answer

Solution code:
m = input().split(" ")
n = int(m[0])
l = int(m[1])

taste = 0

for i in range(n):
    taste += l+i-1

if l >= 1:
    print(taste - l+1)
else:
    print(taste)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

i = min( 0, ( L - 1 ) )
print( N * ( L - 1 ) + N * ( N - 1 ) // 2 - i )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if L >= 0:
    print(sum([L + n for n in range(1, N)]))
elif abs(L) > N:
    print(sum([L + n for n in range(0, N-1)]))
else:
    print(sum([L + n for n in range(N)]))

Submission status: Wrong Answer

Solution code:
def main():
    n, l = map(int, input().split())
    m = sorted(list(range(1,n+1)))
    
    res = 0
    for i in m:
        res += l + i - 1 
    print(res)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

# import numpy as np
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, L = map(int, readline().split())
F = [L + i for i in range(N)]

ans = 1000
for i in itertools.combinations(F, N - 1):
    if abs(sum(F) - sum(i)) < ans:
        ans = sum(i)

print(ans)

Submission status: Wrong Answer

Solution code:
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

# import numpy as np
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, L = map(int, readline().split())
F = [L + i for i in range(N)]

ans = sum(F)
for i in itertools.combinations(F, N - 1):
    if abs(sum(F) - sum(i)) < ans:
        ans = sum(i)

print(ans)

Submission status: Wrong Answer

Solution code:
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

# import numpy as np
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, L = map(int, read().split())
F = [L + i for i in range(N)]

ans = 0
for i in itertools.combinations(F, N - 1):
    ans = min(abs(sum(F) - sum(i)), ans)
print(ans)

Submission status: Wrong Answer

Solution code:
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

# import numpy as np
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, L = map(int, read().split())
F = [L + i for i in range(N)]

ans = 0
for i in itertools.combinations(F,N-1):
    ans=max(sum(i),ans)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, L = [int(i) for i in input().split()]
tastes = []
total = 0
for i in range(N):
    tastes.append(L + i)
    total += L + i
if total > 0:
    print(total - tastes[0])
else:
    print(total - tastes[-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, L = map(int, input().split())
        total = N * L - N + N * (N + 1) // 2
        if L < 0:
            if L + N >= 0:
                print(total + 1)
            else:
                print(total - (L + N - 1))
        else:
            print(total - L)


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, L = map(int, input().split())
        total = N * L - N + N * (N + 1) // 2
        if L < 0:
            if L + N >= 0:
                print(total)
            else:
                print(total - (L + N - 1))
        else:
            print(total - L)


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Wrong Answer

Solution code:
def binary_search(x,li):
    low = 0
    high = len(li)-1
    mid = (low + high)//2
    while low <= high:
        if li[mid] == x:
            return True
        elif x < li[mid]:
            low = mid + 1
        else:
            high = mid - 1
        mid = (low + high)//2
    return False

n,l = map(int,input().split())
taste = [0 for i in range(n)]
check = len(taste)
for i in range(n):
    taste[i] = l + i
if taste[0]>0:
    ans = 0
    for i in range(1,len(taste)):
        ans+=taste[i]
    print(ans)
elif taste[0]<0:
    ans = 0
    for i in range(n):
        if taste[i] > 0:
            check = i
            break
    for i in range(n):
        if i != check-1:
            ans+=taste[i]
    print(ans)
elif binary_search(0,taste) == True:
    ans = 0
    for i in range(n):
        ans+=taste[i]
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
import bisect
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

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

Submission status: Wrong Answer

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

apple = min(range(l,l+n),key=abs)
print(sum(aji)-apple)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
s=[]
a=0
for i in range(n):
    a=i+l
    s.append(a)
if sum(s)<0:
    s.remove(max(s))
elif sum(s)==0:
    s.remove(0)
else:
    s.remove(min(s))
print(sum(s))

Submission status: Wrong Answer

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

tastes = [L + i - 1 for i in range(1, N+1)]
# ダサい解法...
# sum_taste = sum(tastes)
#
# prev_taste_diff = 10 ** 10
#
# ans = 0
# for i in range(N):
#     s = sum(tastes[:i] + tastes[i+1:])
#     curr_taste_diff = abs(s - sum_taste)
#     if curr_taste_diff < prev_taste_diff:
#         ans = s
#     prev_taste_diff = curr_taste_diff

# エレガント
ans = sum(sorted([abs(t) for t in tastes])[1:])
print(ans)

Submission status: Wrong Answer

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

apple = [i + l for i in range(n)]
aji = sum(apple)
print(apple, aji)

if 0 in apple:
    print(aji)
elif apple[0] > 0:
    print(aji - min(apple))
else:
    print(aji - max(apple))

Submission status: Wrong Answer

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

apple = [i + l for i in range(n)]
aji = sum(apple)

if 0 in apple:
    print(0)
elif apple[0] > 0:
    print(aji - min(apple))
else:
    print(aji - max(apple))

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

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

    ls = [i + l for i in range(1, n+1)]
    if l >= 0:
        ls = ls[1:]
    elif n + l < 0:
        ls = ls[:-1]

    print(sum(ls))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

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

    ls = [i + l for i in range(n)]
    if l >= 0:
        ls = ls[1:]
    elif n + l < 0:
        ls = ls[:-1]

    print(sum(ls))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Ans = L
ans = [Ans]  

for i in range(1,N):
    Ans =  L + i
    ans.append(Ans)
    
if ans.count(0) != 0:
    ans.remove(0)
    print(sum(ans))
else:
    print(sum(ans[1:]))

Submission status: Wrong Answer

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

tastes = [L + i for i in range(N)]
ans = sum(tastes[1:])
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b =map(int, input().split())
apple=[i for i in range(b,a+b)]

if b<0:
  print(sum(apple))
else:
  print(sum(apple)-b)

Submission status: Wrong Answer

Solution code:
a,b =map(int, input().split())
apple=[i for i in range(b,a+b)]

if b<=0:
  print(sum(apple))
else:
  print(sum(apple)-b)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
sum1=0
min1=1000

for i in range(a):
    if min1>abs(b):
        min1=abs(b)
    sum1+=b
    b+=1
print(sum1-min1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


i = 1
taste = []

while i <= N:
        taste.append(L + i - 1)
        i += 1


if L > 0 :
        print(sum(taste[1:N]))
elif L <= 0 and N + L < 0:
        print(sum(taste[0:N-1]))
elif L <= 0 and N + L >= 0:
        print(sum(taste[0:N-1]))

Submission status: Wrong Answer

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


i = 1
taste = []

while i <= N:
        taste.append(L + i - 1)
        i += 1


if L > 0 :
        print(sum(taste[1:N]))
elif L < N and N + L < 0:
        print(sum(taste[0:N-1]))
elif L <= 0 and N - L >= 0:
        print(sum(taste[0:N-1]))

Submission status: Wrong Answer

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


i = 1
taste = []

while i <= N:
        taste.append(L + i - 1)
        i += 1


if L > 0 :
        print(sum(taste[1:N]))
elif N + L == 0:
        print(sum(taste))
elif L < N and N + L < 0:
        print(sum(taste[0:N-1]))
elif L <= 0 and N - L >= 0:
        print(sum(taste))

Submission status: Wrong Answer

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


i = 1
taste = []

while i <= N:
        taste.append(L + i - 1)
        i += 1
print(taste)

if L > 0 :
        print(sum(taste[1:N]))
elif L < N and N + L < 0:
        print(sum(taste[0:N-1]))
elif L <= 0 and N - L >= 0:
        print(sum(taste))

Submission status: Wrong Answer

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


i = 1
taste = []

while i <= N:
        taste.append(L + i - 1)
        i += 1

if L > 0 :
        print(sum(taste[1:N]))
elif L < N and N + L < 0:
        print(sum(taste[0:N-1]))
elif L <= 0 and N - L >= 0:
        print(sum(taste))

Submission status: Wrong Answer

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


i = 1
taste = []

while i <= N:
        taste.append(L + i - 1)
        i += 1

print(taste)
      
if L > 0 :
        print(sum(taste[1:N]))
elif L < N and N + L < 0:
        print(sum(taste[0:N-1]))
elif L <= 0 and N - L >= 0:
        print(sum(taste))

Submission status: Wrong Answer

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


i = 0
taste = []

while i <= N:
        taste.append(L + i - 1)
        i += 1
      
if L <= 0:
        print(sum(taste))
elif L > 0:
        print(sum(taste[1:N]))

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
a =[]
for i in range(1,n+1):
  a.append(l+i-1)
b =10**10
for i in range(n):
    d = abs(sum(a)-(sum(a[:i])+sum(a[i+1:])))
    if b>d:
        c = sum(a[:i])+sum(a[i+1:])
        b = d

Submission status: Wrong Answer

Solution code:
N,L = map(int,input().split())
l = list(map(lambda x : L+x+1 , range(1,N+1)))
print(sum(l)-min(l,key=abs))

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
a=[l+n for i in range(n)]
dif = 10**18
for i in range(n):
  if dif > abs(a[i]):
    dif = abs(a[i])
    difr= a[i]
print(sum(a)-difr)

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
ringo=[0]*n
ringoz=[0]*n
min=1000000000000000
mini=0
for i in range(n):
    ringo[i]+=i+l
    if ringo[i]<0:
        ringoz[i]=-ringo[i]
    else:
        ringoz[i]=ringo[i]
    print(min)
    if ringoz[i]<min:
        min=ringoz[i]
        mini=i
ringo.pop(mini)

print(sum(ringo))

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
ringo=[0]*n
ringoz=[0]*n
min=1000000000000000
mini=0
for i in range(n):
    ringo[i]+=i+l
    if ringo[i]<0:
        ringoz[i]=-ringo[i]
    else:
        ringoz[i]=ringo[i]
    if ringoz[i]>min:
        min=ringoz
        mini=i
ringo.pop(mini)
print(sum(ringo))

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
ringo=[0]*n
ringoz=[100000000000]*n
for i in range(n):
    ringo[i]+=i+l
    if ringo[i]<0:
        ringoz[i]=-ringo[i]
    else:
        ringoz[i]=ringo[i]
print(sum(ringo)-min(ringoz))

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
ringo=[0]*n
ringoz=[0]*n
for i in range(n):
    ringo[i]+=i+l
    if ringo[i]>=0:
        ringoz[i]=ringo[i]
    else:
        ringoz[i]=-ringo[i]
print(sum(ringo)-min(ringoz))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(out)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

for i in range(l, l+n):
  ans += i

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


print(ans)

Submission status: Wrong Answer

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

ans = 0

for i in range(l, l+n):
  ans += i

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


print(ans)