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 = [int(s) for s in input().split(" ")]

rng = list(range(l, l+n))

min_abs = 0
val = 0
for r in rng:
  if min_abs > abs(r):
    min_abs = abs(r)
    val = r

print(sum(rng) - val)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input().split()
N = int(s[0])
L = int(s[1])
sum = N * (L + (N-1)/2)
if L + N -1 < 0:
  print(int(sum - (L+N-1)))
elif L-1 > 0:
  print(int(sum - L))
else:
  print(int(sum))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if 0 < l :
	result = taste_int - l
elif l < -1 * n :
	result = taste_int - (n + l -1 )
else:
	result = taste_int

print( result)

Submission status: Wrong Answer

Solution code:
import math

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

apple_azi = [L + (x + 1) - 1 for x in range(N)]

original_pai = sum(apple_azi)

# tabeta_azi = [abs(original_pai - i) for i in apple_azi]

if original_pai > 0:
    tabeta_azi = min(apple_azi)
elif original_pai == 0:
    kirisute_tabeta_azi = apple_azi[math.floor(len(apple_azi) / 2)]
    kiriage_tabeta_azi = apple_azi[math.ceil(len(apple_azi) / 2)]
    tabeta_azi = min(abs((original_pai - kiriage_tabeta_azi)), abs(original_pai - kirisute_tabeta_azi))
else:
    tabeta_azi = max(apple_azi)

print(original_pai - tabeta_azi)

Submission status: Wrong Answer

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

elif L+N<=1:
    for i in range(N-1):
        X=X+L+i

else:
    if (N-1)%4==0:
        X=(L+L+N-1)*(N-1)/4+(L+L+N-1)/2
    else:
        for i in range(N):
            X=X+L+i
        X=X/2

print(X)

Submission status: Wrong Answer

Solution code:
N,L =  map(int, input().split())
saisyou = 10**8
goukei = 0
a = 0

for i in range(1,N+1):
    if(abs(saisyou) > abs(L+i-1)):
        saisyou = L+i-1
    goukei += L+i-1
    print(abs(L+i-1))

print(goukei - saisyou)

Submission status: Wrong Answer

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

sum = 0
lower = 100
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

print(sum - lower)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sumaji = (2*L+N-1)*N/2

if L > 0:
    print(sumaji-L)
elif L+N-1 < 0:
    print(sumaji-(L+N-1))
else:
    print(sumaji)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

if l >= 0:
  print(total2-l)
elif abs(l) <= n:
  print(total2)
elif abs(l) > n:
  print(total2 - (l+n-1))

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
count = 0
if l == 0:
    for i in range(1, n+1):
        count += i + l - 1

    print(count)

if l > 0:
    for i in range(2, n+1):
        count += i + l -1

    print(count)

if (l < 0) and (n >= 1 - l):
    for i in range(1, n+1):
        count += i + l - 1

    print(count)
    
if (l < 0) and (n <= 1 - l):
    for i in range(1, n):
        count += i + l -1
        
    print(count)

Submission status: Wrong Answer

Solution code:
import copy

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

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

pie_taste = sum(apple_taste)

min_diff = 100000
for i in range(N):
    ap = copy.deepcopy(apple_taste)
    ap[i] = 0

    pie_taste2 = sum(ap)
    diff = abs(pie_taste - pie_taste2)

    min_diff = min(min_diff, diff)

print(pie_taste - min_diff)

Submission status: Wrong Answer

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

a = 0
if L < 0 and N + L < 0:
    a = N + L - 1
elif N + L == 0 or (L < 0 and N + L >= 0):
    a = 0
else:
    a = N - L - 1
n = sum(range(L, N + L)) - a
print(n)

Submission status: Wrong Answer

Solution code:
tmp = input().split()
N = int(tmp[0])
L = int(tmp[1])

s = 0
# if N==2:
#     if L>0:
#         print(L+2-1)
#     elif L<0 and abs(L)>N:
#         print(L+1-1)
#     else:
#         print(L+1-1)
#     exit()

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

Submission status: Wrong Answer

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

if l>=0:
    print(int((2*l+n)*(n-1)/2))
else:
    if abs(l)<=n:
        print(int((2*l+n-1)*n/2))
    else:
        print(int((2*l+n-2)*(n-1)/2))

Submission status: Wrong Answer

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

apple =[]

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

print(apple)
pie = 0
flag = 1
min = abs(L)
for i in range(N):
    pie = pie + apple[i]
    if abs(apple[i]) < min:
        min = abs(apple[i])
        if apple[i]<0:
            flag = -1
        else:
            flag = 1

print(min)
pie = pie - flag * min

print(pie)

Submission status: Wrong Answer

Solution code:
def main(str):
    input = str.split()
    n = int(input[0])
    l = int(input[1])
    apples = [l + i for i in range(n)]
    abs_apples = list(map(lambda x: abs(x), apples))
    return sum(apples) - apples[abs_apples.index(min(abs_apples))]


if __name__ == "__main__":
    str = input()
    main(str)

Submission status: Wrong Answer

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

al = []
for i in range(n):
    aji = l + i
    aji_ = abs(aji)
    al += [aji_]

x = abs(l)
an = 0
for i in range(n):
    if al[i] < x:
        x = al[i]
        an = i

ans = (l + l+n-1)*n/2 - (l+an)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
min = L + N
ans = 0
for n in range(N):
    tmp = L+n
    ans += tmp
    if abs(min) > abs(tmp):
        min = tmp

print(ans-min)

Submission status: Wrong Answer

Solution code:
import copy

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

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

pie_taste = sum(apple_taste)

min_diff = 100000
for i in range(N):
    ap = copy.deepcopy(apple_taste)
    ap[i] = 0

    pie_taste2 = sum(ap)
    diff = abs(pie_taste - pie_taste2)

    min_diff = min(min_diff, diff)

print(pie_taste - min_diff)

Submission status: Wrong Answer

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

first = L
end = N + L -1
 

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

Submission status: Wrong Answer

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

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

else:
   if N+L >= 0:
       aji = L
       ajiTotal = 0
       for i in range(N):
           ajiTotal = ajiTotal + aji
           aji = aji + 1
       print(ajiTotal)
   else:
       aji = L
       ajiTotal = 0
       for i in range(N - 1):
           ajiTotal = ajiTotal + aji
           aji = aji + 1
       print(ajiTotal)

Submission status: Wrong Answer

Solution code:
a = input().split()
num = int(a[0])
L = int(a[1])
apple = dict()
orig_taste = 0
for i in range(1, num + 1) :
    apple[i] = L + i - 1
    orig_taste += L + i - 1

if(L + num - 1 > 0 and L > 0):
    print(orig_taste - L)
elif(L + num - 1 > 0 and L < 0):
    print(orig_taste)
elif(L + num - 1 < 0 and L < 0):
    print(orig_taste - L - num - 1)
else:
    print(orig_taste)

Submission status: Wrong Answer

Solution code:
N, L = map(int,input().split(' '))
l=list(range(L,N+L,1))
minabs = min([abs(x) for x in l])
if N+L+1<=0:
    print(sum(l)+minabs)
else:
    print(sum(l)-minabs)

Submission status: Wrong Answer

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


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

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

print(ans)

Submission status: Wrong Answer

Solution code:
x = input()
x = str(x).split(" ")
print(x)
x[0] = int(x[0])
x[1] = int(x[1])
if(x[1] >= 0):
  x[0] -= 1
  if(x[0]%2 == 1):
    print( (1+x[0])*2+x[0]/2+1 + x[1]*x[0] )
  else:
    print( (1+x[0])*2 + x[1]*x[0] )
    
else:
  hu = 0
  sei = 0
  x[1] *= -1
  sein = x[0] - x[1] - 1
  if(x[1]%2 == 1):
    hu = (1+x[1])*2+x[1]/2+1
  else:
    hu = (1+x[1])*2
  
  if( sein % 2 == 1):
    sei = (1+sein)*2+sein/2+1
  else:
    sei = (1+sein)*2
  print(int(sei - hu))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

n,l = map(int,input().split())
num = 1
sa = l+1-1
for i in range(1,n+1):
    if (l+i-1)**2 < sa**2:
        num = i

sum = 0
f = False
for i in range(1,n+1):
    if i == num and f == False:
        f = True
    else:
        sum += l+i-1

print(str(sum))

Submission status: Wrong Answer

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

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

sm = sum(taste_lst) 
ans = 0
for i in taste_lst:
    if i == 0:
        print(0)
        exit()
    elif sm < 0:
        ans = sm - max(taste_lst)
    else:
        ans = sm - min(taste_lst)

print(ans)

Submission status: Wrong Answer

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

apple_azi = [L + (x + 1) - 1 for x in range(N)]

original_pai = sum(apple_azi)

# tabeta_azi = [abs(original_pai - i) for i in apple_azi]

if original_pai > 0:
    tabeta_azi = min(apple_azi)
elif original_pai == 0:
    tabeta_azi = apple_azi[int(len(apple_azi)/2)]
else:
    tabeta_azi = max(apple_azi)

print(sum(apple_azi) - tabeta_azi)

Submission status: Wrong Answer

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

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

if(l<0<l+n):
    print(int(maxt))
elif(l+n<0):
    print(int(maxt-(l+n-1)))
else:
    print(int(maxt-(l)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

eatApple = 0

# マイナス始まり
if L < 0:
    # マイナスで止まる
    if abs(L) - N > 0:
        print(0)
        eatApple = L + N - 1
# プラス始まり
elif L > 0:
    eatApple = L

applePie = 0
i = 1
while i <= N:
    applePie += L + i - 1
    i += 1

print(applePie - eatApple)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, L = map(int,input().split(' '))
l=list(range(L,N+L,1))
minabs = min([abs(x) for x in l])
if N+L+1<0:
    print(sum(l)+minabs)
else:
    print(sum(l)-minabs)

Submission status: Wrong Answer

Solution code:
N, L =  (int(j) for j in input().split())  

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

if L > 0:
  print(sum(taste)-taste[0])
else:
  print(sum(taste))

Submission status: Wrong Answer

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

apple = float('inf')
for i in taste:
    if i == 0:
        apple = i
        break
    elif (apple < i < 0) or (0 < i < apple):
        apple = i
        
pie = abs(sum(taste) - apple)
    
print(pie)

Submission status: Wrong Answer

Solution code:
tmp = input().split()
N = int(tmp[0])
L = int(tmp[1])

s = 0
if N==2:
    if L>0:
        print(L+2-1)
    elif L<0 and abs(L)>N:
        print(L+1-1)
    else:
        print(L+1-1)
    exit()

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

Submission status: Wrong Answer

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

eatApple = 0

# マイナス始まり
if L < 0:
    # マイナスで止まる
    if abs(L) - N > 0:
        eatApple = L + N - 1
# プラス始まり
elif L > 0:
    eatApple = L

applePie = 0
i = 1
while i <= N:
    applePie += L + i - 1
    i += 1

print(applePie - eatApple)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

else:
   if N+L >= 0:
       aji = L + 1
       ajiTotal = 0
       for i in range(N - 1):
           ajiTotal = ajiTotal + aji
           aji = aji + 1
       print(ajiTotal)
   else:
       aji = L
       ajiTotal = 0
       for i in range(N - 1):
           ajiTotal = ajiTotal + aji
           aji = aji + 1
       print(ajiTotal)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,L=(int(i) for i in input().split())

list=np.arange(L,N+L,1)
score=np.sum(list)-np.min(np.abs(list))
print(score)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

# 自然数の和を用いる
# 初項Lで，N個の自然数の和
total = N*(2*L + N-1)/2

# 味がなるべく変わらないには，途中の項で絶対値が一番小さいものを選べば良い
aji_list = range(L, L+N, 1)
aji_abs_list = list(map(abs, aji_list))
aji_abs_list.sort()
min = aji_abs_list[0]

if not (L < min < L+N):
    min = min * -1

# 上記を選んでtotalから弾く
print(int(total - min))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

lst = list()
for i in range(0, n):
    if i == 0:
        lst.append(l)
    else:
        lst.append(lst[i-1]+1)

ans = 0
if 0 in lst:
    ans = sum(lst)
else:
    index = np.argmax(lst)
    del lst[index]
    ans = sum(lst)

print(ans)

Submission status: Wrong Answer

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

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

total = 0
if L + N < 0:
    arr.sort(reverse=True) 
if 0 in arr:
    arr.remove(0)
else:
    arr.pop(0)

print(sum(arr))

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
n_flavor = []
for i in range(1,n+1):
  flavor = l + i - 1
  n_flavor.append(flavor)
rem_abs = abs(n_flavor[0])
rem = n_flavor[0]
for j in range(1,n):
  if rem_abs > abs(n_flavor[j]):
    rem = abs(n_flavor[j])
    rem = n_flavor[j]
  else:
    continue
n_flavor.remove(rem)
print(sum(n_flavor))

Submission status: Wrong Answer

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

if L >= 1:
    X = L
elif (L + N - 1) < 0:
    X = L+N
else:
    X = 0

print(L*N + int(N*(N-1)/2) - X)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
import numpy as np
n,l  = map(int, input().split())
a = np.arange(l,l + n, 1)
amax = l + n -1
amin = l
if amax * amin >0:
    if abs(amax) - abs(amin):
        print(sum(a) - (amax))
    else:
        print(sum(a) - (amim))
elif amax * amin <= 0:
    print(sum(a))
else:
    pass

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
a =abs( L)
ans = 1
for i in range(1, N+1):
  if a > abs(L-1+i):
    ans = i


pi = [(L-1+i) for i in range(1, N+1)]
print(sum(pi) - pi[ans-1])

Submission status: Wrong Answer

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

aji = 0  
mini = l + n
for i in range(0, n) :
    aji = aji + i + l
    if (abs(mini) > abs(i + l)) :
        mini = (i + l)

print(aji-mini)

Submission status: Wrong Answer

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

N = 0
tmp = 10000
L = [0]*n
Tmp = [0]*n

for i in range(1,n+1):
    N += l+i-1
    L[i-1] = l+i-1
    
for i in range(n):
    Tmp[i] = N-L[i]
    
for i in range(1,n+1):
    tmp = min(abs(N-Tmp[i-1]),tmp)

print(N-tmp)

Submission status: Wrong Answer

Solution code:

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

taste_all = N*L + int((N - 1)*N/2)
ans = 0

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



print(ans)

Submission status: Wrong Answer

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

a = 0
if N+L == 0:
    a = 0
elif N+L > 0:
    a = N - L - 1
else:
    a = N + L - 1
n = sum(range(L, N+L)) - a
print(n)

Submission status: Wrong Answer

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

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

sa=1000000000
for i in range(N):
    a = (L+i)
    if(a<0):
      a=-a
    if(sa > a):
        sa=a

print(Nsum-sa)

Submission status: Wrong Answer

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

elif L+N<=1:
    for i in range(N-1):
        X=X+L+i

else:
    if N%2==0 :
        X=L+L+N-1

    else:
        X=(L+L+N-1)*(N-1)/4+(L+L+N-1)/2

print(X)

Submission status: Wrong Answer

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

apple_pi = sum(taste)

diff = 0
idx = 0
for i in range(N):
    if i == 0:
        diff = abs(apple_pi - (apple_pi - taste[i]))
        idx = i
    else:
        tmp = abs(apple_pi - (apple_pi - taste[i]))
        if diff > tmp:
            idx = i
print "{0}".format(apple_pi - taste[idx])

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
ans=888
SUM=0
s=0
for i in range(l,l+n):
        SUM+=i
        s=i
        if i<0:
                s=1
                i*=-1
        else:
                s=-1
        if ans>i:
                ans=i
        print(i,ans)
y=range(l,l+n)
ANS=SUM+s*ans
print(ANS)

Submission status: Wrong Answer

Solution code:
N,L=map(int,input().split())
val=val=L*N+0.5*N*(N+1)-N
if L>0:
    val-=(L-1)
elif L+N-1<0:
    val-=(L+N-1)

print(int(val))

Submission status: Wrong Answer

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

arr = []
tmp = L
for i in range(N):
    arr.append(tmp)
    tmp += 1

total = 0
if L + N < 0:
    arr.sort(reverse=True) 
if 0 in arr:
    arr.remove(0)
else:
    arr.pop(0)

print(sum(arr))

Submission status: Wrong Answer

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

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

aji_list = sorted(aji_list)
aji_list = set(aji_list)
print(aji_list)

aji_list.remove(min(aji_list))
print(aji_list)

print(sum(aji_list))

Submission status: Wrong Answer

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

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

elif L <= 0 and N + L >= 0:
    s = ( (L+1-1) + (L+N-1) )*( (N)/2 )
    print(int(s))

else:
    s = ( (L+1-1) + (L+N-1-1) )*( (N-1)/2 )
    print(int(s))

Submission status: Wrong Answer

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

find = 10**9
data = 0
for i in x:
    if abs(i)<find:
        find = abs(i)
        data = i

print(s-find)

Submission status: Wrong Answer

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

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

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

s -= ax

print(int(s))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

    m = INF
    ind=0
    s = l*n + sum(list(range(1, n + 1))) - n
    #print(s)
    
    for i in range(1, n + 1):
        if m>abs(s -(l+i-1)*2):
            m = min(m, abs(s - l - i + 1 - (l + i - 1)))
            ind=i
        #print(ind, s - l -  i + 1,l+i-1,m)

    print(s - l - ind + 1)

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

sa=1000000000
for i in range(N):
    a = (L+i-1)
    if(a<0):
      a=-a
    if(sa > a):
        sa=a

print(Nsum-sa)

Submission status: Wrong Answer

Solution code:
N, L = map(int,input().split())
import statistics
S = []
for i in range(L,N+L):
    S.append(i)
ans = []
p = []
mini = False
plu = False
for j in S:
    ans.append(sum(S) - sum(S) - j)
    p.append(sum(S)-j)

    if sum(S) - j > 0:
        plu = True
    if sum(S) - j < 0:
        mini = True
if plu and mini:
    print(p[ans.index(statistics.median(ans))])       
elif plu:
    print(p[ans.index(max(ans))])
elif mini:
    print(p[ans.index(min(ans))])

Submission status: Wrong Answer

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

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
#        print(i)
else:
    if(abs(L)>N):
        for i in range(1,N):
            sum += L+i-1
#            print("i=",i,"L+i-1=",L+i-1)
            #print(i)
    else:
        for i in range(1,N+1):
            sum += L+i-1
#            print("i=",i,"L+i-1=",L+i-1)

print(sum)

Submission status: Wrong Answer

Solution code:
def input_nums():
    return [ int(i) for i in input().split(" ") ]

nums = input_nums()

N = nums[0]
L = nums[1]

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

if(sum >0):
    sum -= (L+1)-1
elif(sum<0):
    sum -= (L+N)-1
elif(sum == 0):
    sum -= min-1

print(sum)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
a = L
ans = 1
for i in range(1, N+1):
  if a > abs(L-1+i):
    ans = i

pi = [(L-1+i) for i in range(1, N+1)]
print(sum(pi) - pi[ans-1])

Submission status: Wrong Answer

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

apple =[]

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

pie = 0
min = abs(L)
for i in range(N):
    pie = pie +apple[i]
    if abs(apple[i])< min:
        min = apple[i]

pie = pie - min

print(pie)

Submission status: Wrong Answer

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

arr = []
tmp = L
for i in range(N):
    arr.append(tmp)
    tmp += 1

total = 0
if L + N < 0:
    arr.sort(reverse=True) 
if 0 in arr:
    arr.remove(0)
else:
    arr.pop(0)

for i in arr[:]:
    total += i
print(total)

Submission status: Wrong Answer

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

value_list = [L + i + 1 - 1 for i in range(N)]
total_value = sum(value_list)

minimum_value = -1 << 20
for v in value_list:
    tmp_value = total_value - v
    if total_value - tmp_value == 0:
        minimum_value = tmp_value
        break
    if total_value - tmp_value >= minimum_value:
        minimum_value = tmp_value

print(minimum_value)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,L=map(int,input().split())
ans=0
min=10000
for i in range(1,N+1):
    tmp=L+i-1
    ans+=tmp
    if abs(tmp) < min:
        min = abs(tmp)
ans-=min
print(ans)

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
list1 = [0] * n
list2 = [0]*n
for i in range(n):
  list1[i]=l+i
  list2[i]=abs(l+i)
if list1[0]<=0 and list1[n-1]<=0 or list1[0]>=0 and list1[n-1]>=0:
  if list1[0]<=0:
    print(sum(list1)-max(list1))
  else:
    print(sum(list1)-min(list1))
else:
  print(sum(list1))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

print(taste)

Submission status: Wrong Answer

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

apples = [x+1 for x in range(N)]
tastes =  [L+i-1 for i in apples]
#print(apples,tastes)
pie = sum(tastes)
absmin = max(tastes[-1],tastes[0])
for i in tastes:
    if abs(i) < absmin:
        absmin = i
print(pie-absmin)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, L = map(int, input().split())
if L > 0:
    s = np.sum(np.arange(L+1, L+N))
elif L < -N:
    s = np.sum(np.arange(L, L+N-1))
else:
    s = np.sum(np.arange(L, L+N))
print(s)

Submission status: Wrong Answer

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

if l < 0 and n+l < 0:
    kei = sum(list(x for x in range(l,l+n-1)))
if l < 0 and n+l >= 0:
    kei = sum(list(x for x in range(l,l+n)))
if l >= 0:
    kei = sum(list(x for x in range(l+1,l+n)))

print(kei)

Submission status: Wrong Answer

Solution code:
tmp = input().split()
N = int(tmp[0])
L = int(tmp[1])

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

Submission status: Wrong Answer

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

arr = []
tmp = L
for i in range(N):
    arr.append(tmp)
    tmp += 1

total = 0
if L + N < 0:
    arr.sort(reverse=True) 
print(arr)
if 0 in arr:
    arr.remove(0)
else:
    arr.pop(0)

for i in arr[:]:
    total += i
print(arr)
print(total)

Submission status: Wrong Answer

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

apple =[]

for i in range(N):
    apple.append(L + i)
print(apple)

pie = 0
min = abs(L)
for i in range(N):
    pie = pie +apple[i]
    if abs(apple[i])< min:
        min = apple[i]

pie = pie - min

print(pie)

Submission status: Wrong Answer

Solution code:
import numpy as np

N,L = [int(i) for i in input().split()]
L = np.arange(L,L+N)
print(L)

if 0 in L:
  print(sum(L))
else:
  if min(L) > 0:
    print(sum(L)-min(L))
  else:
    print(sum(L)-max(L))

Submission status: Wrong Answer

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

ls1 = [abs(l+i) for i in range(0,n)]
maxt = n*l+(n-1)*n/2
print(int(maxt- min(ls1)))

Submission status: Wrong Answer

Solution code:
import numpy as np

def acinput():
    return list(map(int,input().split(" ")))


N,L=acinput()


aji=L+np.arange(1,N+1)-1
sm=np.sum(aji)

arg=np.argmin(np.abs(aji))
if aji[arg]>=0:
        print(sm-aji[arg])
else:
        print(sm-aji[arg])


print(aji)

Submission status: Wrong Answer

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

N = 0
tmp = 10000
L = [0]*n

for i in range(1,n+1):
    N += l+i-1
    L[i-1] = l+i-1
    
for i in range(1,n+1):
    tmp = min(abs(N-L[i-1]),tmp)

print(N-tmp)

Submission status: Wrong Answer

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

T = []

for i in range(N):
    T.insert(i, L+i-1+1)

for i in range(N):
    if T.count(i) != 0:
        T.remove(i)
        break
    elif T.count(-i) != 0:
        T.remove(-i)
        break

print(sum(T))

Submission status: Wrong Answer

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

ls1 = [abs(l+i) for i in range(0,n)]
maxt = n*l+(n-1)*n/2
print(maxt- min(ls1))

Submission status: Wrong Answer

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

taste = 0
judge = True
for i in range(n):
	taste_i = l + (i + 1) - 1 
	print(taste_i)
	if taste_i == 0:
		judge = False
	taste += l + (i + 1) - 1

if judge:
	if taste_i < 0:
		taste = taste - taste_i
	else:
		taste = taste - (l + 1 - 1)
		
print(taste)

Submission status: Wrong Answer

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