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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N,L=map(int,input().split())
a=[]
for i in range(1,N+1):
  b=L+i-1
  a.append(b)
c=sum(a)
if L>0:
  d=min(a)
  print(c-d)
elif 0<=L and L>-N:
  print(c)
elif L<=-N:
  d=max(a)
  print(c-d)

Submission status: Wrong Answer

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

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

B = list(map(lambda x: abs(x), A))
print (A)
print (B)
print (sum(A) - A[B.index(min(B))])

Submission status: Wrong Answer

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

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

A = list(map(lambda x: abs(x), A))
print (sum(A) - min(A))

Submission status: Wrong Answer

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

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

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

A_abs = [abs(x) for x in A]
abs_min = min(A_abs)
index = A_abs.index(abs_min)
eat = A[index]
print(sum(A))

ans = sum(A) - eat
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
    N, L = map(int, input().split())
    apple = np.zeros(N)
    R = L + N - 1
    eat = 0
    if R <= 0:
        eat = R
    elif L >= 0:
        eat = L
    print((R + L) * (R - L + 1)/2 - eat)



       

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

s = int((l + l + n - 1) * n / 2)
if l <= 0 and l + n >= 0:
    # eat 0
    print(s)
elif l > 1:
    # eat first
    print(s - l)
else:
    # eat last
    print(s - (l + n - 1))

Submission status: Wrong Answer

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

s = int((l + l + n - 1) * n / 2)
if l <= 0 and l + n > 0:
    # eat 0
    print(s)
elif l > 1:
    # eat first
    print(s - l)
else:
    # eat last
    print(s - (l + n - 1))

Submission status: Wrong Answer

Solution code:
N,L=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき

aji_sum=0
eat=99999

for i in range(1,N+1):
    
    aji_sum=aji_sum+i+L-1
    print(aji_sum,i+L-1)
    if abs(i+L-1) < abs(eat):
        eat = i+L-1

print(aji_sum-eat)

Submission status: Wrong Answer

Solution code:
N,L=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき

aji=0
eat=99999

for i in range(1,N+1):
    aji=aji+i+L-1
    if abs(aji) < abs(eat):
        eat = aji
        

print(aji-eat)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

edge=[L, L+N-1]
if edge[0]*edge[1]<=0:
  ans=sum(edge)*N/2
elif edge[0]>0:
  ans=(L+1+L+N-1)*(N-1)/2
else:
  ans=(L+L+N-2)*(N-1)/2
  
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,L = map(int, input() . split())
x=[]
M = 0
N_list = np.array([])

for i in range(N):
  M += L + (i+1) - 1
  N_list = np.append(N_list, L + (i+1) - 1)
  
m = np.abs(N_list).argmin()

#M - N_list[m]
print(M - N_list[m])

Submission status: Wrong Answer

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

print(sum(x))

Submission status: Wrong Answer

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

print(sum(x))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if L >= 0:
    for i in range(1,N):
        sum += L + i
elif 1 - N < L < 0:
    for i in range(1,N + 1):
        print('roop:' + str(i))
        sum += L + i - 1
        print('total:' + str(sum))
else:
    for i in range(1,N):
        print('roop:' + str(i))
        sum += L + i - 1
        print('total:' + str(sum))

print(sum)

Submission status: Wrong Answer

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

count = 0
min = None
sum = 0
for i in range(N):
  i += 1
  num = abs(L + i - 1)
  if min == None:
    min = num
    continue
  if min > num:
    min = num
    count = i

for i in range(N):
  i += 1
  if i == count:
    continue
  num = L + i - 1
  sum += num
print(sum)

Submission status: Wrong Answer

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

count = 0
min = None
sum = 0
for i in reversed(range(1, N+1)):
  num = abs(L + i - 1)
  if min == None:
    min = num
    continue
  if min > num:
    min = num
    count = i

for i in range(1, N+1):
  if i == count:
    continue
  num = L + i - 1
  sum += num
print(sum)

Submission status: Wrong Answer

Solution code:

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

t = map(lambda i: L + i, range(N))

targ = sum(t)
res = 0
for c in t:
    now = targ - c
    if m > abs(targ - now):
        m = abs(targ - now)
        res = now

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if l>=0:
    for val in range(n-1):
        s += val+l+1
        


elif l < 0 and n >= -l:
    for val in range(n):
        s += val + l
        
else:
    for val in range(n-1):
        s += val + l



print(s)

Submission status: Wrong Answer

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

if l>=0:
    for val in range(n-1):
        s += val+l+1
        


elif l < 0 and l >= -l:
    for val in range(n):
        s += val + l
        
else:
    for val in range(n-1):
        s += val + l



print(s)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, L = map(int,input().split())
tast_list = [L + i for i in range(N)]
print(tast_list)
drop_iter = np.argmin(np.abs(tast_list))
del tast_list[drop_iter]
print(sum(tast_list))

Submission status: Wrong Answer

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

taste_list = [l+i-1 for i in range(1,n+1)]
abs_taste_list = [abs(i) for i in taste_list]
min = min(abs_taste_list)
print(sum(taste_list)-min)

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)
res = float('inf')
for i in X:
  res = min(abs(res),abs(i))
print(sum(X)-res)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
mx = 100000000
sum = 0
for i in range(1,a+1):
  mx = min(mx,abs(b+i-1))
  sum+=b+i-1
print(sum-mx)

Submission status: Wrong Answer

Solution code:
n, a = map(int, input().split())
L = a
R = a + n - 1
print(L)
print(R)
eat = 0
if R <= 0:
    eat = R
elif L >= 0:
    eat = L

ans = (R+L) * (R-L+1) / 2 - eat
print(int(ans))

Submission status: Wrong Answer

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

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

if tastes[0] * tastes[-1] < 0:
    ans = sum(tastes)
elif tastes[0] > 0:
    ans = sum(tastes) - tastes[0]
else:
    ans = sum(tastes) - tastes[-1]

print(ans)

Submission status: Wrong Answer

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

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

if tastes[0] * tastes[-1] < 0:
    ans = sum(tastes) - min(map(abs, tastes))
elif tastes[0] > 0:
    ans = sum(tastes) - tastes[0]
else:
    ans = sum(tastes) - tastes[-1]

print(ans)

Submission status: Wrong Answer

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

for i in range(2, N+1):
    taste = L + i - 1
    print(taste)
    if abs(taste) < abs(eatable_taste):
        eatable_taste = taste

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

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
eatable_taste = L - 1
eatable_index = 0

for i in range(1, N):
    taste = L + i - 1
    if abs(taste) < abs(eatable_taste):
        eatable_index = i
        eatable_taste = taste

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

Submission status: Wrong Answer

Solution code:
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


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


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
5 2
'''


def MAIN():
  # T_IN()
  A()


def A():
  n, l = IN_L_I()
  li = list([ i + l for i in range(0,  n)])
  # print(li)
  if li.count(0) == 0:
    if abs(li[0]) > abs(li[-1]):
      li.pop(-1)
    else:
      li = li[0:-1]
  # print(li)
  print(sum(li))

  return None
 

def B():
  return None


def C():
  return None


MAIN()

Submission status: Wrong Answer

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

l = [L + i for i in range(N)]
item = min([(v, i) for i, v in enumerate(l)])[1]

ans = 0
for i, v in enumerate(l):
    if i == item:
        continue
    ans += v

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def apple_aji(i):
  return int(l) + int(i) - 1

def apple_pie(n):
  ajis = [apple_aji(x) for x in n]
  return sum(ajis)

print(apple_pie(range(1, int(n))))

Submission status: Wrong Answer

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

def apple_aji(i):
  return int(l) + int(i) - 1

def apple_pie(n):
  ajis = [apple_aji(x) for x in n]
  mini = min(list(map(abs, ajis)))
  mini = mini * -1
  if mini in ajis:
    pass
  else:
    mini = mini * -1
  print(ajis)
  ajis.remove(mini)
  print(ajis)
  return sum(ajis)

print(apple_pie(range(1, int(n))))

Submission status: Wrong Answer

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

def apple_aji(i):
  return int(l) + int(i) - 1

def apple_pie(n):
  ajis = [apple_aji(x) for x in n]
  mini = min(list(map(abs, ajis)))
  if mini in ajis:
    pass
  else:
    mini = mini * -1
  ajis.remove(mini)
  return sum(ajis)

print(apple_pie(range(1, int(n))))

Submission status: Wrong Answer

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

def apple_aji(i):
  return int(l) + int(i) - 1

def apple_pie(n):
  ajis = [abs(apple_aji(x)) for x in n]
  ajis.sort()
  return sum(ajis[1:])

print(apple_pie(range(1, int(n))))

Submission status: Wrong Answer

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

def apple_aji(i):
  return int(l) + int(i) - 1

def apple_pie(n):
  ajis = [abs(apple_aji(x)) for x in n]
  ajis.sort()
  return sum(ajis[1:])

print(apple_pie(range(int(n))))

Submission status: Wrong Answer

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

def apple_aji(i):
  return int(l) + int(i) - 1

def apple_pie(n):
  ajis = [apple_aji(x) for x in n]
  ajis.sort()
  return sum(ajis[1:])

print(apple_pie(n))

Submission status: Wrong Answer

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

ans = float("inf")

for i in range(1, N+1):
    before = sum([L+k-1 for k in range(1, N+1)])
    after = sum([L+j-1 for j in range(1, N+1) if j != i])

    ans = min(ans, abs(before-after))
    
print(ans)

Submission status: Wrong Answer

Solution code:
import math

def main():
    N, L  = list(map(int, input().split(" ")))
    minimum = abs(L-1+1)
    argmin = 1
    for i in range(2, N+1):
        value = abs(L-1+i)
        if value < minimum:
            argmin = i
    ans = (N-1)*(L-1) + N*(N+1)/2 - argmin
    print(int(ans))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if all(map(lambda x: x < 0, a)):
    ans = sum(a[:-1])
elif all(map(lambda x: x > 0, a)):
    ans = sum(a[1:])
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,L=map(int,input().split())
Taste=list(int(i) for i in range(L+1-1,L+N-1+1) )
MaxTaste=[sum(Taste)]*N
print(sum(Taste)-Taste[np.argmax(np.abs(np.array(Taste)-np.array(MaxTaste)))])

Submission status: Wrong Answer

Solution code:
import numpy as np
N,L=map(int,input().split())
Taste=list(int(i) for i in range(L+1-1,L+N-1+1) )
MaxTaste=[sum(Taste)]*N
print(Taste)
print(MaxTaste)
print(sum(Taste)-Taste[np.argmax(np.abs(np.array(Taste)-np.array(MaxTaste)))])

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
mina = 300
s = 0
for  i in range(1,n+1):
    if mina > abs(i+l-1):
        mina = i+l-1
    s += i+l-1
print(s-mina)

Submission status: Wrong Answer

Solution code:
N,L=list(map(int,input().split()))
taste=[]
taste1=[]
sum=0
for i in range(N):
    tasty=abs(L+i)
    taste.append(tasty)
    taste1.append(L+i)
    sum+=taste1[i]
tasteab=sorted(taste)
pie=(sum-tasteab[0])
print(pie)

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+N-1 < 0:
  print(int((2*L+N-2)*(N-1)/2))

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

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

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

print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

for k in range(1, N+1):
    ab = []
    ab.append(abs(L + k - 1))
print(apple_pie - (L + ab.index(min(ab))  ))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

list = [abs(l+i) for i in range(n)]
min_taste = min(list)

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

Submission status: Wrong Answer

Solution code:
import math
x =  [int(s) for s in input().split()]
aji = [x[1]+i-1 for i in range(1,x[0]+1)]
sum = 0
if(0 in aji):
    for i in range(0,len(aji)):
        sum += aji[i]
else:
    for i in range(1,len(aji)):
        sum += aji[i]
print(sum)

Submission status: Wrong Answer

Solution code:
import math
x =  [int(s) for s in input().split()]
aji = [x[1]+i-1 for i in range(1,x[0]+1)]
print(aji)
sum = 0
if(0 in aji):
    for i in range(0,len(aji)):
        sum += aji[i]
else:
    for i in range(1,len(aji)):
        sum += aji[i]
print(sum)

Submission status: Wrong Answer

Solution code:
import math
x =  [int(s) for s in input().split()]
aji = [x[1]+i-1 for i in range(x[0])]
sum = 0
for i in range(1,len(aji)):
    sum += aji[i]
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
taste = [l + i for i in range(n)]
min_abs = None
for i in taste:
    if min_abs == None or min_abs > abs(i):
        min_abs = i

print(sum(taste)-min_abs)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

val = (N - 1) * (L - 1) + (sum - 1)

print(val)

Submission status: Wrong Answer

Solution code:
import numpy as np

# S = list(input())
n, l = list(map(int, input().split()))

RINGO = list(np.array(list(range(1, n+1))) + l - 1)
AJI = list(map(abs, RINGO))

AJI.remove(min(AJI))
print(sum(AJI))

Submission status: Wrong Answer

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

apple_taste = [int(x+L) for x in range(N)]
all_applepie_taste = sum(apple_taste)
dif_taste_min = abs(all_applepie_taste)
num_min = 0

for i in range(N):
  dif_taste = abs(all_applepie_taste)
  dif_taste -= abs(all_applepie_taste - apple_taste[i])
  
  if dif_taste_min >= abs(dif_taste):
    dif_taste_min = dif_taste
    num_min = i
  
applepie_taste_min = all_applepie_taste - apple_taste[num_min]  
print(applepie_taste_min)

Submission status: Wrong Answer

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

mi=l
ma=l+n-1

if mi <= 0 and 0 <= ma:
    print(int((mi+ma)*n/2))
else:
    print(int((mi+ma)*n/2-abs(min(mi, ma))))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,L = map(int,input().split())
N=0
G=0
for i in range(1,n):
    N +=(i+L-1)
NN = N
for i in range(1,n):
        DD = NN - (L+i-1)
        if DD>G :
            G = DD
print(G)

Submission status: Wrong Answer

Solution code:
nl=list(map(int,input().split()))
a=[i+nl[1] for i in range(nl[0])]
 
a_sum = sum(a)
abs_ = []
for i in range(nl[0]):
  abs_.append(abs(a_sum - a[i]))
idx=abs_.index(min(abs_))
print(a_sum-a[idx])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

# N 個のりんごがあって、それ一つ一つの味はL + i - 1 で表される（i = 1,2,...,n）
total = n * (l + l + n - 1) // 2

# ひとつめのりんごの味はL, N個目のりんごの味はL+N-1
first, last = l, l + n - 1
# 1. 美味しいりんごだけで作る場合、もっともおいしくないりんごなら食べてもいい
if first >= 0:
  taste = total - first
# 2. まずいりんごが混ざっている時、全体が美味しければまずいものを、全体がまずければ美味しいものを食べるべき
elif first < 0 and last >= 0: 
  if total == 0:
    taste = total - 0
  elif total < 0:
    taste = total - last
  else:
    taste = total - first
# 3. まずいりんごだけで作る場合、もっともまずくないりんごを食べたほうがいい
else:
  taste = total - last  

print(taste)

Submission status: Wrong Answer

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

# N 個のりんごがあって、それ一つ一つの味はL + i - 1 で表される（i = 1,2,...,n）
total = n * (l + l + n - 1) // 2

# ひとつめのりんごの味はL, N個目のりんごの味はL+N-1
first, last = l, l + n - 1
# 1. まずいりんごが混ざっている時、うまくもまずくもないりんごを食べるのがいい
if first * last < 0:
  if total == 0:
    taste = total - 0
  elif total < 0:
    taste = total - last
  else:
    taste = total - first
# 2. 美味しいりんごだけで作る場合、もっともおいしくないりんごなら食べてもいい
elif (first < 0 and last <= 0) or first == 0:
  taste = total - last
# 3. まずいりんごだけで作る場合、もっともまずくないりんごを食べたほうがいい
else:
  taste = total - first

print(taste)

Submission status: Wrong Answer

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

# N 個のりんごがあって、それ一つ一つの味はL + i - 1 で表される（i = 1,2,...,n）
total = n * (l + l + n - 1) // 2

# ひとつめのりんごの味はL, N個目のりんごの味はL+N-1
first, last = l, l + n - 1
# 1. まずいりんごが混ざっている時、うまくもまずくもないりんごを食べるのがいい
if first * last <= 0:
  if total == 0:
    taste = total - 0
  elif total < 0:
    taste = total - last
  else:
    taste = total - first
# 2. 美味しいりんごだけで作る場合、もっともおいしくないりんごなら食べてもいい
elif first < 0 and last <= 0:
  taste = total - last
# 3. まずいりんごだけで作る場合、もっともまずくないりんごを食べたほうがいい
else:
  taste = total - first

print(taste)

Submission status: Wrong Answer

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

# N 個のりんごがあって、それ一つ一つの味はL + i - 1 で表される（i = 1,2,...,n）
total = n * (l + l + n - 1) // 2

# ひとつめのりんごの味はL, N個目のりんごの味はL+N-1
first, last = l, l + n - 1
# 1. まずいりんごが混ざっている時、うまくもまずくもないりんごを食べるのがいい
if first * last < 0:
  if total == 0:
    taste = total - 0
  elif total < 0:
    taste = total - last
  else:
    taste = total - first
# 2. 美味しいりんごだけで作る場合、もっともおいしくないりんごなら食べてもいい
elif first < 0 and last <= 0:
  taste = total - last
# 3. まずいりんごだけで作る場合、もっともまずくないりんごを食べたほうがいい
else:
  taste = total - first

print(taste)

Submission status: Wrong Answer

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

# N 個のりんごがあって、それ一つ一つの味はL + i - 1 で表される（i = 1,2,...,n）
total = n * (l + l + n - 1) // 2

# ひとつめのりんごの味はL, N個目のりんごの味はL+N-1
first, last = l, l + n - 1
# 1. まずいりんごが混ざっている時、うまくもまずくもないりんごを食べるのがいい
if first * last < 0:
  if total == 0:
    taste = total - 0
  elif total < 0:
    taste = total - last
  else:
    taste = total - first
# 2. 美味しいりんごだけで作る場合、もっともおいしくないりんごなら食べてもいい
elif first < 0 and last < 0:
  taste = total - last
# 3. まずいりんごだけで作る場合、もっともまずくないりんごを食べたほうがいい
else:
  taste = total - first

print(taste)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

aji = list(map(lambda x: L + x - 1, range(1, N + 1)))

print(aji)

if (aji[0] <= 0 and aji[N - 1] >= 0) :
    print(sum(aji))
elif (aji[0] < 0 and aji[N - 1] < 0):
    print(sum(aji) - aji[N -1])
else:
    print(sum(aji) - aji[0])

Submission status: Wrong Answer

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

aji = list(map(lambda x: L + x - 1, range(1, N + 1)))

if (aji[0] < 0 and aji[N - 1] > 0) :
    print(sum(aji))
elif (aji[0] < 0 and aji[N - 1] < 0):
    print(sum(aji) - aji[N -1])
else:
    print(sum(aji) - aji[0])

Submission status: Wrong Answer

Solution code:
n, l = map(int,input().split())
#ls = list(map(int,input().split()))
#r = int(input())
#s = input()

ans = 0

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

if l <= 0:
  if abs(n) < abs(l):
    print(ans - (n + l + 1))
    quit()
  print(ans)
  quit()
else :
  print(ans - l)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    N, L = map(int, input().split())
    all_list = list(range(L, N + L))
    if L >= 0:
        all_list.pop(0)
    elif L + N < 0:
        all_list.pop()
    print(sum(all_list))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if -l > n:
    apples[-1] = 0
elif l > 0:
    apples[0] = 0
print(sum(apples))