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())

tst_l = []

for i in range(1, n+1) :
    tmp = l + i - 1
    tst_l.append(tmp)

n_tst = sum(tst_l)

tmp_tst = sum(tst_l[1:n])
ans = n_tst - tmp_tst
ansi = tmp_tst

for i in range(1, n) :
    tmp_tst = 0
    tmp_tst += sum(tst_l[0:i])
    tmp_tst += sum(tst_l[i+1:n])

    near = n_tst - tmp_tst

    if abs(ans) >= abs(near) :
        ansi = tmp_tst

print(ansi)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

taste = [(L + i - 1) + 1 for i in range(N)]
#print(taste)
pie = {}
for i in range(N-1):
  tmp = taste[:]
  tmp0 = tmp[i]
  tmp.pop(i)
  tmp1 = sum(tmp)
  pie[i] = abs(tmp0 - tmp1)
  print(pie)
  
print(pie[min(pie)])

Submission status: Wrong Answer

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

apple_pi = sum(taste)

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

print apple_pi - taste[idx]

Submission status: Wrong Answer

Solution code:
ls = []

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

for i in range(N):
  ls.append(L)
  L += 1

if ls[0] + ls[-1] ==0:
    print(0)
elif ls[0] > 0:
    del ls[0]
    print(sum(ls))
else:
    del ls[-1]
    print(sum(ls))

Submission status: Wrong Answer

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

flavors = 0
min_data = 10000000000000000
flag = False

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

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

Submission status: Wrong Answer

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

apple_pi = sum(taste)

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

print "{0}".format(apple_pi - taste[idx])

Submission status: Wrong Answer

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

R=[0]*N

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


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

Submission status: Wrong Answer

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

print(d)

Submission status: Wrong Answer

Solution code:
ls = []

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

for i in range(N):
  ls.append(L)
  L += 1

if ls[-1] >= 0:
    del ls[0]
else:
    del ls[-1]
print(ls)
print(sum(ls))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
ls = []

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

for i in range(N):
  ls.append(L)
  L += 1

if ls[-1] > 0:
    del ls[0]
else:
    del ls[-1]
print(ls)
print(sum(ls))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

L = int(L)

taste = []

total = 0


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

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

Submission status: Wrong Answer

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

g = []
for i in range(1, a[0]+1):
    g.append(i)
L = a[1]

x = a[0]*(L-1)+sum(g)

d = set()
e =0

for b in range(a[0]):
    f=0
    f = b+L
    if f==0:
        e+=1
    d.add(abs(f))
c = min(d)
if e>=1:
    print(x)
else:
    print(x-c)

Submission status: Wrong Answer

Solution code:
a,b = (int(x) for x in input().split())
ap_list = []
for i in range(a):
    val = b + (i + 1) -1
    ap_list.append(val)
max_sum = sum(ap_list)
maxx = 0
num_1 = 0
num_2 = 0
flag = 0
for y in range(a):
    for i in range(len(ap_list)):
        if i != flag:
            num_2 += ap_list[i]
    z = max_sum - num_2
    if z <= maxx:
        num_1 = num_2
    num_2 = 0
    flag += 1
print(num_1)

Submission status: Wrong Answer

Solution code:
from functools import reduce
# リンゴN個から1個リンゴを抜いたときの和と抜かないときの和の差を最小にする、その時の値を求める
Input = input()

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

# i個目の味を出す関数
def ni_taste(i,l=l):
    return l+i-1

taste_list = [ni_taste(i) for i in range(1, n+1)] # リンゴは1, 2, 3, ...と数えられる
taste_abs_list = [abs(abs_taste) for abs_taste in taste_list]
print( reduce((lambda x, y: x + y), taste_list) - min(taste_abs_list)  )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(n):
    apple.append(l+i)

if l <= 0:
    if n >= abs(l):
        print(0)
    else:
        print(sum(apple[:-1]))
else:
    print(sum(apple[1:]))

Submission status: Wrong Answer

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

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

sm = sum(taste_lst)
ans = 0

if sm > 0:
    ans = sm - abs(min(taste_lst))
elif sm < 0:
    ans = sm - max(taste_lst)
else:
    pass

print(ans)

Submission status: Wrong Answer

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

for i in range(n):
    apple.append(l+i)

if l <= 0:
    if n > abs(l):
        print(0)
    else:
        print(sum(apple[:-1]))
else:
    print(sum(apple[1:]))

Submission status: Wrong Answer

Solution code:
import numpy as np
N, L = input().split(" ")
N, L  = int(N), int(L)
apple = np.arange(L, L + N)
apple_pie = apple.sum()

if L >= 0:
  i = apple[0]
elif L < 0:
  if N + L >= 0:
    i = apple[N + L - 1]
  else:
    i = apple[-1]
  
print(apple_pie - i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(n):
    apple.append(l+i)

if l <= 0:
    if l > abs(n):
        print(0)
    else:
        print(sum(apple[:-1]))
else:
    print(sum(apple[1:]))

Submission status: Wrong Answer

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

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

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

	print(taste)
else:
	for i in range(N):
		taste+=LA
		LA+=1
		#print("taste",taste)
		#print("LA",LA)
	print(taste)

Submission status: Wrong Answer

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

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

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

print(int(taste))

Submission status: Wrong Answer

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

intSum = 0
# everythins is minus
if intBase + intCount -1 < 0:
    intSum += -1 * (intBase + intCount -1)
# everything is plus
elif intBase > 1:
    intSum -= intBase

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

print(intSum)

Submission status: Wrong Answer

Solution code:
from sys import stdin

# N, L = stdin.readline().rstrip()
N, L = map(int, input().split(' '))
print(N, L)
# N, L = 5, 2
# N, L = 3, -1
# N, L = 30, -50

min_value = L
max_value = L + N - 1

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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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

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

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

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

Submission status: Wrong Answer

Solution code:
a,b = (int(x) for x in input().split())
ap_list = []
for i in range(a):
    val = b + (i + 1) -1
    ap_list.append(val)
num_1 = 0
num_2 = 0
flag = 0
for y in range(a):
    for i in range(len(ap_list)):
        if i != flag:
            num_2 += ap_list[i]
    if num_2 >= num_1:
        num_1 = num_2
    num_2 = 0
    flag += 1
print(num_1)

Submission status: Wrong Answer

Solution code:
n,l=map(int, input().split())
i=1
a=0
while(i<=n):
  a=a+l+i-1
  if(l<=0):
     al=-l
     if(n>=al):
       b=0
     if(n<al):
       b=l+n-1
  else:
    b=l
  i+=1
print(a-b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(n):
    apple.append(l+i)

if l <= 0:
    if l > abs(n):
        print(0)
    else:
        print(sum(apple[:-1]))

    
else:
    print(sum(apple[1:]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
t = input().split()
n = int(t[0])
l = int(t[1])
taste = l + 0 - 1
small = abs(taste)
small_idx = 0
for i in range(1,n):
    apple = l + i -1
    taste = taste + apple
    if small > abs(apple):
        small = abs(apple)
        small_idx = i
print(taste - (l + small_idx -1))

Submission status: Wrong Answer

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

for i in range(n):
    apple.append(l+i)

if l <= 0:
    if l < abs(n):
        print(sum(apple[:-1]))
    else:
        print(0)
    
else:
    print(sum(apple[1:]))

Submission status: Wrong Answer

Solution code:
import numpy as np
N, L = input().split(" ")
N, L  = int(N), int(L)
apple = np.arange(L, L + N)
apple_pie = apple.sum()

if L >= 0:
  i = apple[0]
elif L < 0:
  if N + L > 0:
    i = apple[N + L - 1]
  else:
    i = apple[-1]
  
print(apple_pie - i)

Submission status: Wrong Answer

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

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

elif L<-3:
	for i in range(N-1):
		taste+=LA
		LA+=1

	print(taste)
else:
	for i in range(N):
		taste+=LA
		LA+=1
		#print("taste",taste)
		#print("LA",LA)
	print(taste)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
m=100
s=10000
Q=0

for j in range(0,n):
    i=n-j
    if m>abs(l+i-1):
        m=abs(i+l-1)
        s=i
    Q=Q+i

Q=Q+(n-1)*(l-1)-s

print(Q)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


apple_pie = sum(apple)
for i in range(N):
    if i == 0:
        apple = apple[:i] + apple[i+1:]
        ans = sum(apple)
        gap = (apple_pie - sum(apple))**2
    else:
        apple = apple[:i] + apple[i+1:]
        if apple_pie >= 0:
            if gap > (apple_pie - sum(apple))**2:
                ans = sum(apple)
        else:
            if gap > (apple_pie - sum(apple))**2:
                ans = sum(apple)


print(ans)

Submission status: Wrong Answer

Solution code:
import sys

B, A = map(int, input().split())  # list() を使っても構いません

abs_A=abs(A)
#print (abs_A)

if A > 1:  ##Aは正か否か
    flag=True
else:
    flag=False

result=0
temp=A
for i in range(B):
    result = result + temp
    temp= temp + 1

#print("first result---")
#print(result)

#print("flag---")
#print(flag)

if B==2:
    if A>0:
        result=A + 1
        print(result)
        sys.exit()
    elif A==0:
        result=A+1
        print(result)
        sys.exit()
    else:
        result=A
        print(result)
        sys.exit()

if abs_A > B:
    if flag:
        result=result-A
        print("pattern A")
        print(result)
    else:
        print("pattern B")
        result=result-temp+1
        print(result)
elif abs_A == B:
    if flag:
        result=result-A
        print("pattern C")
        print(result)
    else:
        print("pattern D")
        print(result)
else:
    if flag:
        print("pattern E")
        result=result-A
        print(result)
    else:
        print("pattern F")
        print(result)

Submission status: Wrong Answer

Solution code:
x = list(map(int,input().rstrip().split(" ")))
N,L=x[0],x[1]
aplist = []
imin = 100
ix = 0
for i in range(N):
  aplist.append(L+i)
for i in range(N):
  if abs(L+i) < imin:
    imin = L+i
    ix = i
aplist.pop(ix)
print(sum(aplist))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N+L<0:
  print(sum(LL)+min(LLL))
elif N+L ==0:
  print(sum(LL))
else:
  print(sum(LL)-min(LLL))

Submission status: Wrong Answer

Solution code:
import sys

B, A = map(int, input().split())  # list() を使っても構いません

abs_A=abs(A)
#print (abs_A)

if A > 1:  ##Aは正か否か
    flag=True
else:
    flag=False

result=0
temp=A
for i in range(B):
    result = result + temp
    temp= temp + 1

#print("first result---")
#print(result)

#print("flag---")
#print(flag)

if B==2:
    if A>0:
        result=A + 1
        print(result)
        sys.exit()
    elif A==0:
        result=A
        print(result)
        sys.exit()
    else:
        result=A
        print(result)
        sys.exit()


if abs_A > B:
    if flag:
        result=result-A
        print("pattern A")
        print(result)
    else:
        print("pattern B")
        result=result-temp+1
        print(result)
elif abs_A == B:
    if flag:
        result=result-A
        print("pattern C")
        print(result)
    else:
        print("pattern D")
        print(result)
else:
    if flag:
        print("pattern E")
        result=result-A
        print(result)
    else:
        print("pattern F")
        print(result)

Submission status: Wrong Answer

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

g = []
for i in range(a[0]+1):
    g.append(i)
L = a[1]

x = a[0]*(L-1)+sum(g)

d = set()
e =0

for b in range(a[0]):
    f=0
    f = b+L
    if f==0:
        e+=1
    d.add(abs(f))
c = min(d)
print(e)
if e>=1:
    print(x)
else:
    print(x-c)

Submission status: Wrong Answer

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

apples = [i for i in range(1, n+1)]

taste = [apple+l-1 for apple in apples]

taste_sum = sum(taste)

min_diff = abs(taste_sum)
min_index = 0
for i in range(len(taste)):
    if abs(taste[i]) < min_diff:
        min_diff = abs(taste[i])
        min_index = i
        
print(taste_sum - taste[min_index])

Submission status: Wrong Answer

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

if N+L<0:
  print(sum(LL)+min(LLL))
else:
  print(sum(LL)-min(LLL))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum = 0
for i in range(N):
    sum += R[i]

sums = []
for i in range(N):
    sums.append(sum-R[i])

approximation = sums[0]
for i in range(1,N):
    if sum == abs(sum)-abs(sums[i]):
        approximation = sums[i]
        break
    elif abs(sum)-abs(approximation) > abs(sum)-abs(sums[i]):
            approximation = sums[i]

print(approximation)

Submission status: Wrong Answer

Solution code:
n,l=map(int, input().split())
res_sum = sum(range(l,l+n))

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

Submission status: Wrong Answer

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

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

elif L<-3:
	for i in range(N-1):
		taste+=LA
		LA+=1

	print(taste)
else:
	for i in range(N):
		taste+=LA
		LA+=1
	#	print("taste",taste)
	#	print("LA",LA)
	print(taste)

Submission status: Wrong Answer

Solution code:
n,l=map(int, input().split())
res_sum = sum(range(l,l+n))

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

else:  # 両方マイナス
    s = sum(range(L, A))
print(s)

Submission status: Wrong Answer

Solution code:

N,L = map(int,input().split())
L2 = L
count=0
while L2 < 0:
    L2+=1
    count+=1

sum =0
if L < -1:
    j = N
else:
    j = N+1
for i in range(1,j):
    if i-1 != count:
        sum += L+i-1
print(sum)

Submission status: Wrong Answer

Solution code:
N,L = map(int,input().rstrip().split(' '))
apple_pie = 0
ex = abs(L * N)
apple = []
for i in range(N):
    a = L + i 
    apple.append(a)
    apple_pie += a
print(apple)
for i in range(len(apple)):
    if abs(ex) > abs(apple[i]):
        ex = apple[i]
print(ex)
apple_pie-= ex
print(apple_pie)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Nazi=[]

for i in range(N+1):
    azi=L+i-1
    Nazi.append(azi)
del Nazi[0]

if L>0:
    del Nazi[0]
    print(sum(Nazi))

else:
    print(sum(Nazi))

Submission status: Wrong Answer

Solution code:

N,L = map(int,input().split())
L2 = L
count=0
while L2 < 0:
    L2+=1
    count+=1

sum =0
if L < -1:
    j = N
else:
    j = N+1
for i in range(1,j):
    if i-1 != count:
        sum += L+i-1
        print(sum)
print(sum)

Submission status: Wrong Answer

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

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
    
if l<0:
  if n%2==1:
    print(0)
  else:
    for i in range(n):
        Tmp[i] = abs(N)-abs(L[i])
    print(-Tmp[n-1])
else:
    for i in range(n):
        Tmp[i] = abs(N)-abs(L[i])
    print(Tmp[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

B, A = map(int, input().split())  # list() を使っても構いません

abs_A=abs(A)
#print (abs_A)

if A > 1:  ##Aは正か否か
    flag=True
else:
    flag=False

result=0
temp=A
for i in range(B):
    result = result + temp
    temp= temp + 1

#print("first result---")
#print(result)

#print("flag---")
#print(flag)

if abs_A > B:
    if flag:
        result=result-A
        #print("pattern A")
        print(result)
    else:
        #print("pattern B")
        result=result-temp+1
        print(result)
elif abs_A == B:
    if flag:
        result=result-A
        #print("pattern C")
        print(result)
    else:
        #print("pattern D")
        print(result)
else:
    if flag:
        #print("pattern E")
        result=result-A
        print(result)
    else:
        #print("pattern F")
        print(result)

Submission status: Wrong Answer

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

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

print(listSum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

elif L<-4:
	for i in range(N-1):
		taste+=LA
		LA+=1

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

Submission status: Wrong Answer

Solution code:
30 -50

Submission status: Wrong Answer

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

tst_l = []

for i in range(1, n+1) :
    tmp = l + i - 1
    tst_l.append(tmp)

n_tst = sum(tst_l)

tmp_tst = sum(tst_l[1:n])
ans = n_tst - tmp_tst
ansi = tmp_tst

for i in range(1, n) :
    tmp_tst = 0
    tmp_tst += sum(tst_l[0:i])
    tmp_tst += sum(tst_l[i+1:n])

    near = n_tst - tmp_tst

    if abs(ans) > abs(near) :
        ansi = tmp_tst

print(ansi)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

B, A = map(int, input().split())  # list() を使っても構いません

abs_A=abs(A)
#print (abs_A)

if A > 1:  ##Aは正か否か
    flag=True
else:
    flag=False

result=0
temp=A
for i in range(B):
    result = result + temp
    temp= temp + 1

#print("first result---")
#print(result)

#print("flag---")
#print(flag)

if abs_A > B:
    if flag:
        result=result-A
        #print("pattern A")
        print(result)
    else:
        #print("pattern B")
        result=result-temp+1
        print(result)
elif abs_A == B:
    if flag:
        result=result-A
        #print("pattern A")
        print(result)
    else:
        #print("pattern B")
        print(result)
else:
    if flag:
        #print("pattern C")
        result=result-A
        print(result)
    else:
        #print("pattern D")
        print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

elif L<-4:
	for i in range(N-1):
		taste+=LA
		LA+=1

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

Submission status: Wrong Answer

Solution code:
import sys

B, A = map(int, input().split())  # list() を使っても構いません

abs_A=abs(A)
#print (abs_A)

if A > 1:  ##Aは正か否か
    flag=True
else:
    flag=False

result=0
temp=A
for i in range(B):
    result = result + temp
    temp= temp + 1

#print("first result---")
#print(result)

#print("flag---")
#print(flag)

if abs_A > B:
    if flag:
        result=result-A
        #print("pattern A")
        print(result)
    else:
        #print("pattern B")
        result=result-temp+1
        print(result)
else:
    if flag:
        #print("pattern C")
        result=result-A
        print(result)
    else:
        #print("pattern D")
        print(result)

Submission status: Wrong Answer

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

sum = n * (l - 1) + (n * (n + 1)) / 2.0

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

Submission status: Wrong Answer

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

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

elif L<-4:
	for i in range(N-1):
		taste+=LA
		LA+=1

	print(taste)
else:
	for i in range(N-1):
		taste+=LA
		LA+=1
		print("taste is",taste)
		print("LA is",LA)
	print(taste)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

i = range(a[0])
L = a[1]

x = L+sum(i)-1

d = set()
e =0

for b in range(a[0]):
    if b==0:
        e+=1
    d.add(abs(b))
c = min(d)
if e==1:
    print(x)
else:
    print(x-c)

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