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:
# -*- coding: utf-8 -*-
import sys

import fractions
import copy
import bisect
import math
import numpy as np
import itertools
from itertools import combinations_with_replacement
#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
from operator import itemgetter
from sys import stdin
#input = sys.stdin.readline#こっちの方が入力が早いが使える時に使っていこう
from operator import mul
from functools import reduce
from collections import Counter
#from collections import deque

#input = stdin.readline


j=0
k=0
n=3
r=1
a=[0]
#n=int(input())
#r=int(input())
#print(M)
#A=int(input())
#B=int(input())
#print(N)
"1行1つの整数を入力を取得し、整数と取得する"


#number_list=list(map(int, input().split(" ")))#数字の時
#print(number_list)
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#メモ
for i in number_list:#こっちの方がrage使うより早いらしい
    print(number_list[i-1])#

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''
#array=[input().split()for i in range(N)]
#print(type(array[0][0]))
#print(array)
"正方行列にstr型の値を入力"
'''

#brray=[list(map(int, input().split(" ")))for i in range(N)]
#print(type(brray[0][0]))
#print(brray)
'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"
#以下に別解を記載
#N, M = [int(i) for i in input().split()]
'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''




#s=input()
#a=[int(i) for i in s]
#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ
#intを取ると文字列分解に使える
'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()#str style 何個でもいけることが多い
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''


#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"


#a,b=map(int, input().split())  #int style 複数数値入力　「A B」みたいなスペース空いた入力のとき

#なんかうまく入力されるけど
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
#複数行の数値を入力して正方行列を作成


##############################################################################################
##############################################################################################
#under this line explains example calculation



'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''

#nCr combination
'''
def cmb(n,r):
    #When n < r , this function isn't valid
    r= min(n-r,r)
    #print(n,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    #flochart mul(n,n-1)=x
    #next     mul(x,n-2)........(n-r+1,n-r)
    #mul read a,b and returns a*b

    under = reduce(mul, range(1, r+1))
    #print(over, under)
    #reduce is applied mul(1,2)=2
    #next   mul(2,3)=6
    #next   mul(6,4)=4.........last(r!,r+1)=r+1!

    return over // under
    #// is integer divide
    #calc example 5C2
    #over=5*4*3
    #under=3*2*1
a = cmb(n, r)
#print(a)
'''

'''
import itertools
from itertools import combinations_with_replacement

combinationについて
以下の違いを意識しよう
combinations() p, r 長さrのタプル列、ソートされた順で重複なし

combinations_with_replacement() p, r 長さrのタプル列、ソートされた順で重複あり


使用例 　　　　　　　　　　　                  出力　　
combinations('ABCD', 2)　　　　　　　　　　　　AB AC AD BC BD CD

combinations_with_replacement('ABCD', 2)　　 AA AB AC AD BB BC BD CC CD DD
'''



'''
#集計
#example
#a=[2,2,2,3,4,3,1,2,1,3,1,2,1,2,2,1,2,1]
#a=Counter(a)
for i in a.most_common(n):print(i)
#most_common()メソッドは、出現回数が多い要素順にCounterオブジェクトを並び替えます。
#引数にint型の数字nを設定した場合は、出現回数が高い上位ｎ個の要素を返します。
#何も設定しなければ、コンテナ型にあるすべての要素を出現回数の順番に並び替えたタプル型オブジェクトを返します。
#out put
#(2, 8)
 #(1, 6)
#(3, 3)
#(4, 1)
'''


#二部探索(binary search)
#A = [1, 2, 3, 3, 3, 4, 4, 6, 6, 6, 6]
#print(A)
#index = bisect.bisect_left(A, 5) # 7 最も左(前)の挿入箇所が返ってきている
#A.insert(index, 5)
#print(index)
#print(A)
'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''

'''
素数の判定
'''


def is_prime(n):
    if n == 1: return False

    for k in range(2, int(np.sqrt(n)) + 1):
        #sqrt(n)+1以上は考えて約数はないので却下
        if n % k == 0:
            return False
            #割り切れたらFalse
    return True


'''
npのmaxとmaximumの違い
xs = np.array([1, -2, 3])
np.max(xs, 0)
この出力は3となります．[1, -2, 3]と0の4つの数字のうち，最も大きい値を出力します．

一方で，[max(1, 0), max(-2, 0), max(3, 0)]を出力したい時があります．
その時は，numpyのmaximum関数を用います．

xs = np.array([1, -2, 3])
np.maximum(xs, 0)  # [1, 0, 3]

'''

def factorial(x, mod=10**9+7):
    # x!
    # 階乗
    # ex) factorial(5) = 120
    tmp = 1
    for i in range(1, x+1):
        tmp = (tmp * i) % mod
    return tmp
    '''
    Basically, when you do a**d % n, you actually have to calculate a**d, which could be quite large.
    But there are ways of computing a**d % n without having to compute a**d itself, and that is what pow does.
    '''


########################################################################
########################################################################
#b2=a[:]  #1次元のときはコピーはこれで良い
#print(b2)

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b3=copy.deepcopy(a)  #2次元配列はこうコピーする
#print(b3)

'''
ascii_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
digits = '0123456789'
hexdigits = '0123456789abcdefABCDEF'
letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv...\xaf\xb0...
lowercase = 'abcdefghijklmnopqrstuvwxyz'
octdigits = '01234567'
printable = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTU...
punctuation = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
whitespace = '\t\n\x0b\x0c\r '
'''
'''
引数endに任意の文字列を指定すると、その文字列が改行の代わりに最後に挿入される。例えば連続するprint()の出力を改行なしで単純に連結したい場合は空文字列''を指定すればよい。

print('abc', end='---')
print('xyz')
# abc---xyz

print('abc', end='')
print('xyz')
# abcxyz
source: print_basic.py
なお、デフォルトで改行されるのは引数endのデフォルト値が改行文字'\n'に設定されているから。
'''

def main():
    n=3
    steps=0
    state=0
    w=1
    j=0
    k=0
    #lenを変数に置くと事故るから注意
    #n=int(input())
    #a,b=input().split(" ")#a,bがともに文字列のとき
    n,l=map(int, input().split(" "))
    c=[0]*n
    csum=0
    d=[10000000000]*n
    for i in range(n):
        c[i]=l+i
    csum=sum(c)
    #for i in range(n):
    #    d[i]=csum-c[i]
    #print(d)
    if l<=0 and n>=abs(l):
     print(csum)
    elif l>0:
     print(csum-min(c))
    elif l<0:
     print(csum-max(c))

    #mapでとってもstrで変換すればappend可能
    #s=input()
    #a=[i for i in s]#int(i)にすれば数字も行ける
    #nl=list(map(int, input().split(" ")))#数字の時
    #print(a)
    #brray=[list(map(int, input().split(" ")))for i in range(N)]
    #print(brray)


    for i in range(1,n+1,2):#これで1個飛ばしループになる
     pass
     #print(i)

    l = ['aaa', 'bbb', 'ccc']
    x=l.index('aaa')#ある要素のインデックス番号を取得
    #s = ''.join(l)
    #s = " ".join(map(str,a))#スペースを空ける時はこう
    #print(s)
    # aaabbbccc

    #if state in known_states and not flag: # state => 2 steps => 5
        #こうやってある要素がリストの中にあるか探すのか
    #print(f'steps: {steps}, state: {state}')
    #こう書いてあるとデバックしやすい

    #dp= [[0]*3 for i in range(5)]#列　行
    #dp用の0の入ったやつ
    #dp= [[0]*(w+1) for i in range(n+1)]#0からwまでのw+1回計算するから
    #print(dp)＃初期条件が入る分計算回数+1列分必要(この場合は判断すべきものの数)
    DP = np.zeros(w+1, dtype=int)#これでも一次元リストが作れる
    exdp=np.zeros((3,4)) # ３×４の２次元配列を生成。2次元ならこう
    #dtypeは指定しないとfloatになる
    #for i in range(n):#ちょっとした入力に便利
    #    a, b = map(int, input().split())
        #dp[i][0] += [a]
        #これだとintとlistをつなぐことになって不適
    #    dp[i] += [a]
    #    dp[i] += [b]
        #これはうまくいく
        #やり方はいろいろあるということ
    #print(dp)


    #brray=[list(map(int, input().split(" ")))for i in range(N)
    #print(brray)



    '''
    入力
    1234
    出力
    [1, 2, 3, 4]
    '''
    pin_l=["x" for i in range(10)]#内包表記に慣れろ
    #print(pin_l)

    ls = ["a", "b", "c", "d", "e"]


    #print(ls[2:5])
    #スライスでの取得

    #print(ls[:-3])
    #一番左端から右から3番目より左まで取得

    #print(ls[:4:2])
    #スライスで1個飛ばしで取得
    #ないときは左端スタート
    #始点のインデックス番号 : 終点のインデックス番号 : スキップする数+1
    #print(ls[::2])
    '''
    lsというリストの場合に、1つ飛びの値を取得したい場合には
    ls[::2]
    のようにします。こうすると、
    ["a", "c", "d"]と出力される
    '''

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

for i in range(1, n+1):
    ll.append(i + l - 1)

if ll[0]>= 0:
    ans = sum(ll) - ll[0]
elif ll[n-1]<=0:
    ans = sum(ll) - ll[n-1]
else:
    if n != 3:
        for i in range(1, n-1):
            if abs(ll[i-1]) < abs(ll[i]) < abs(ll[i+1]):
                ans = sum(ll) - ll[i]
    else:
        ans = sum(ll) - ll[1]

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if(l < 0 and n + l < 0):
  print(sum(L) - L[n-1])
elif(l < 0 and n + l > 0):
  print(sum(L))
else:
  print(sum(L) - L[0])

Submission status: Wrong Answer

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

print(b)

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
n_l = []
for i in range(n):
    n_l.append(i+l)
min_a = 1000
for i in n_l:
    min_a = min(abs(i),abs(min_a))

print(sum(n_l)-min_a)

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
n_l = []
for i in range(n):
    n_l.append(i+l)
print(n_l)
min_a = 1000
for i in n_l:
    min_a = min(abs(i),abs(min_a))

print(sum(n_l)-min_a)

Submission status: Wrong Answer

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

min_a = 1000
for i in n_l:
    min_a = min(abs(i),min_a)


print(sum(n_l)-min_a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, L = map(int,input().split())
A = [0] * N
B = [0] * N
for i in range(N):
  A[i] = L + i

ans = 0
diff = 10 ** 10
for j in range(N):
  B[j] = sum(A) - A[j]

print(max(B))

Submission status: Wrong Answer

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

ans = 0
diff = 10 ** 10
for j in range(N):
  diff = min(diff, sum(A)-A[j])
  if diff != diff:
    ans = A[j]

print(ans)

Submission status: Wrong Answer

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

diff = 10 ** 10
for j in range(N):
  diff = min(diff, sum(A)-A[j])

print(diff)

Submission status: Wrong Answer

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

print(sum(A)-min(A))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,l=map(int, input().split())
t=0
c=0
for i in range(n):
  if i==0:
    t=abs(l+(i+1)-1)
    c=0
  else:
    t=min(t, abs(l+(i+1)-1))
    if t==abs(l+(i+1)-1):
      c=i+1
g=0
for i in range(n):
  g+=(l+(i+1)-1)
print(g-l-c)

Submission status: Wrong Answer

Solution code:
n,l=map(int, input().split())
t=0
for i in range(n):
  if i==0:
    t=abs(l+(i+1)-1)
  else:
    t=min(t, abs(l+(i+1)-1))
print(t)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

aji=[]
for i in range(1,n+1):
    aji.append(l+i-1)
sum=sum(aji)
print(aji)
print(sum)
p=1000
for i in range(n):
    if abs(aji[i])<=abs(aji[i-1]):
        p=aji[i]
        print(aji[i])
print(sum-p)

Submission status: Wrong Answer

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

aji=[]
for i in range(1,n+1):
    aji.append(l+i-1)
sum=sum(aji)
#print(aji)
p=1000
for i in range(n):
    if p<=aji[i]<=0 or 0<=aji[i]<=p:
        p=aji[i]
print(sum-p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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)]
print(sum(tastes) - min(map(abs, tastes)))

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)]
print(min(map(lambda x: abs(sum(tastes) - x), tastes)))

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
n_l = [0]*n
for i in range(n):
    n_l[i] = l + (i+1) - 1
n_l_min = min(n_l)
if n_l_min < 0 :
    print(sum(n_l)-max(n_l))
    exit()
print(sum(n_l)-n_l_min)
#print(n_l)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
pie = 0
comp = 300

for i in range(1, n+1):
    pie = pie + l + i - 1
    if abs(l + i -1) < comp:
        comp = l + i -1

print(pie - comp)

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
pie = 0
comp = 300

for i in range(1, n+1):
    pie = pie + l + i - 1
    if abs(l + i -1) < comp:
        comp = l + i -1
        print(comp)

print(pie - comp)

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
avemoto=l-1+(n+1)/2
motomoto=n*avemoto
zettaisa=1000
keep=0
for i in range(1,n+1):
  aji=l+i-1
  if zettaisa>=abs(avemoto-aji):
    zettaisa=abs(avemoto-aji)
    keep=aji

print(int(motomoto-aji))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
list = [L+i for i in range(N)]
p = float("inf")
q = -float("inf")

for j in range(N):
  if list[j] >= 0 and list[j] < p:
    p = list[j]
  elif list[j] <= 0 and list[j] > q:
    q = list[j]


if sum(list) > 0:
  print(sum(list) - p)
elif sum(list) < 0:
  print(sum(list) - q)
else:
  if abs(p) > abs(q):
    print(sum(list) - q)
  else:
    print(sum(list) - p)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
list = [L+i for i in range(N)]
p = float("inf")
q = -float("inf")

for j in range(N):
  if list[j] >= 0 and list[j] < p:
    p = list[j]
  elif list[j] <= 0 and list[j] > q:
    q = list[j]
if sum(list) >= 0:
  print(sum(list) - p)
else:
  print(sum(list) - q)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
s=0
list=[]
for i in range(1,n+1):
  s+=i
  list.append(abs(l+i-1))
sum=n*(l-i)+s
m=list.index(min(list))
print(sum-l-m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
s=0
list=[]
for i in range(1,n+1):
  s+=i
  list.append(abs(l+i-1))
sum=n*(l-i)+s
if l-1<-n:
  print(sum+min(list))
else:
  print(sum-min(list))

Submission status: Wrong Answer

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

#ringo goto aji dasu
for i in range(N):
  a.append(L+ i+1 -1)

  #eikyou sukunai mono sagasi
for j in range (N):
  b.append(abs(a[j]))

if max(a) < 0:
  print(sum(a)-max(a))
elif max(a) > 0 and min(a) < 0:
  print(sum(a))
else:
  print(sum(a)-min(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b = map(int, input().split())
tmp = []
for i in range(a):
  tmp.append(b+i)
if b < 0 and a <= abs(b):
  tmp = tmp[:-1]
elif b >= 0:
  tmp = tmp[1:]
print(tmp)

Submission status: Wrong Answer

Solution code:
a,b = map(int, input().split())
tmp = []
for i in range(a):
  tmp.append(b+i)
if b < 0 and a < abs(b):
  tmp = tmp[:-1]
elif b >= 0:
  tmp = tmp[1:]
print(sum(tmp))

Submission status: Wrong Answer

Solution code:
import math
n, l = map(int, input().split())
t = []
for i in range(1, n+1):
    t.append(l+i-1)
fab = 0
if l >= 1:
    fab = math.fabs(sum(t)-t[0])

elif l < 1 and n%2 == 0 and n+l > 0:#-1 0 1 2
    fab = t[-1]
    #for i in range(1, n):
        #fab += t[i]

elif l < 1 and n%2 != 0 and n+l > 0:#-1 0 1
    #sum(t)==0
    fab = 0

elif n+l < 0:
    for i in range(n-1):
        fab += t[i]

print(int(fab))

Submission status: Wrong Answer

Solution code:
import math
n, l = map(int, input().split())
t = []
for i in range(1, n+1):
    t.append(l+i-1)
fab = 0

if l >= 1:
    fab = math.fabs(sum(t)-t[0])

elif l < 1 and n%2 == 0 and n+l > 0:
    for i in range(1, n):
        fab += t[i]
elif l < 1 and n%2 != 0 and n+l > 0:
    #sum(t)==0
    fab = 0

elif n+l < 0:
    for i in range(n-1):
        fab += t[i]

print(int(fab))

Submission status: Wrong Answer

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

print(n_l)
min_i = n_l[0]
for i in n_l:
    print(i)
    if abs(i) < abs(min_i):
        min_i = i

print(sum(n_l) - min_i)

Submission status: Wrong Answer

Solution code:
#入力
N, L = list(map(int,input().split()))
A = [None for _ in range(N)]
#食べるリンゴは絶対値が最も小さいリンゴであるので絶対値が最小のリンゴを求め、その味をMに記録
m = float('inf')
M = 0
for i in range(N):
  A[i] = L + i
  if m > abs(A[i]):
    m = abs(A[i])
    M = A[i]
print(M)    
#結果
print(sum(A) - M)

Submission status: Wrong Answer

Solution code:
#入力
N, L = list(map(int,input().split()))
A = [None for _ in range(N)]
#食べるリンゴは絶対値が最も小さいリンゴであるので絶対値が最小のリンゴを求め、その味をMに記録
m = float('inf')
M = 0
for i in range(N):
  A[i] = L + i
  if m > abs(A[i]):
    M = A[i]
#結果
print(sum(A) - M)

Submission status: Wrong Answer

Solution code:
#入力
N, L = list(map(int,input().split()))
A = [None for _ in range(N)]
#食べるリンゴは絶対値の大きさが最も小さいもの。
m = float('inf')
for i in range(N):
  A[i] = L + i
  if m > abs(A[i]):
    m = abs(A[i])
#結果
print(sum(A) - m)

Submission status: Wrong Answer

Solution code:
def ll():
    return list(map(int,input().split()))
def l():
    return int(input())
n,l = ll()
x=[]
for i in range(1,n+1):
    x.append(l+i-1)
x = sorted(x)
if sum(x)<0:
    print(sum(x)-x[-1])
elif sum(x)>0:
    print(sum(x)-x[0])
elif sum(x)==0:print(0)

Submission status: Wrong Answer

Solution code:

n,l = map(int,input().split())
t = []
ans = []
w = []

for i in range(n):
    t.append(l+(i+1)-1)

for i in range(n):
    ans = t.copy()
    del ans[i]
    w.append(sum(ans))

print(max(w))

Submission status: Wrong Answer

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

for i in range(n):
    lt.append(abs(i+1+l-1))

lt.sort()

print(sum(lt[1:]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

taste = list(range(1, N+1))
for a in range(0, N):
    taste[a] = taste[a] + L - 1

abs_taste = copy.deepcopy(taste)

for a in range(0, N):
    abs_taste[a] = abs(abs_taste[a])

print(sum(taste))

Submission status: Wrong Answer

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

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

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

print(int(ans))

Submission status: Wrong Answer

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

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

if l >= 0 :
    ans = aji - l

elif abs(l)-n >= 0 :
    ans = aji - (l+n-1)
else :
    ans = aji

print(ans)

Submission status: Wrong Answer

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

aji = (l + l+n-1)*(n/2)
if l > 0 :
    ans = aji - l
elif l <= 0 and abs(l)-n > 0 :
    ans = aji - (l+n-1)
else :
    ans = aji

print(int(ans))

Submission status: Wrong Answer

Solution code:
N,L = map(int,input().split())
NL = [int(i)+L-1 for i in range(1,N+1)]
SNL = sum(NL)
ate = 10**18
for i in range(N):
  ate = min(ate,abs(NL[i]))
print(SNL-ate)

Submission status: Wrong Answer

Solution code:
def main():
  ans = 0
  maxl = 101
  n,l = map(int, input().split())
  t = []
  for i in range(l, l+n):
    t.append(i)
  for i in range(len(t)):
    if i != len(t) - 1 and maxl > abs(t[i]):
      maxl = abs(t[i])
    elif i == len(t) - 1:
      t.pop(i)
      break
    else:
      t.pop(i-1)
      break
  print(sum(t))
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
total = [l+(i+1)-1 for i in range(n)]
m = 100000000
for i in range(n):
    if abs(total[i]) < m:
        idx = i
        m = total[i]
total.pop(idx)
print(sum(total))

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
total = [l+(i+1)-1 for i in range(n)]
m = 100000000
for i in range(n):
    if abs(total[i]) < m:
        idx = i
total.pop(idx)
print(sum(total))

Submission status: Wrong Answer

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

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:
import math
N,L = map(int,input().split())
r = []
total=0
max = -100100100100
for i in range(1,N+1):
  r.append(L+i-1)
all_applepay=sum(r)
for i in range(N):
  for j in range(N):
    if j != i:
      total+=r[j]
  if max < abs(all_applepay-total):
    max = total
  total=0
print(max)

Submission status: Wrong Answer

Solution code:
import math
N,L = map(int,input().split())
r = []
total=0
max = -100100100100
for i in range(1,N+1):
  r.append(L+i-1)
for i in range(N):
  for j in range(N):
    if j != i:
      total+=r[j]
  if max < total:
    max = total
  total=0
print(max)

Submission status: Wrong Answer

Solution code:
import math
N,L = map(int,input().split())
r = []
total=0
ap=0
max = -100100100100
for i in range(1,N+1):
  r.append(L+i-1)
for i in range(N):
  for j in range(N):
    if j != i:
      total+=r[j]
  if max < total:
    ap = total
  total=0
print(ap)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if L+1-1 > 0:
    print(L+1-1)
else:
    if L+N-1 >= 0:
        print(s)
    else:
        print(s - (L+N-1))

Submission status: Wrong Answer

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

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

if L > 0:
    print(L+1-1)
else:
    if L+N-1 >= 0:
        print(s)
    else:
        print(s - (L+N-1))

Submission status: Wrong Answer

Solution code:
n,l = map(int, input().split())
ans = 0
m = float("inf")
for i in range(1,n+1):
    a = l + i -1
    if abs(a)<abs(m):
        m = a
    ans += a
print(ans + (-m if m<0 else m))

Submission status: Wrong Answer

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

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

if L > 0:
    print(s - 2)
else:
    if L+N-1 >= 0:
        print(s)
    else:
        print(s - (L+N-1))

Submission status: Wrong Answer

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

all_taste = 0
taste_list = []
minimum = L + N - 1

for i in range(1, N+1, 1):
  all_taste += L + i - 1
  taste_list.append(L + i - 1)
else:
  for i in range(N):
    if abs(taste_list[i]) < minimum:
      minimum = taste_list[i]
  else:
    print(all_taste - minimum)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
n, l = [int(i) for i in input().split()]
ans = (l-1)*n+n*(n+1)//2
if l-1<=0 and l-1+n>=0:
  print(ans)
elif l+n-1<0:
  print(ans-(l+n-1))
elif l-1 >0:
  print(ans-l+1)

Submission status: Wrong Answer

Solution code:
N, L=map(int, input().split())
SUM=0
now=1000
for i in range(N):
  SUM+=L+i
  now=min(now, abs(L+i))
  
print(SUM-now)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

else:
    for i in range(1,N):
        l.append(L+i-1)
    print(sum(l) if 0 not in l else 0)

Submission status: Wrong Answer

Solution code:
n , l =map(int, input().split())
apple = []
count = 0
for i in range(1,n+1):
    apple.append(l+i-1)
    #count += 1
apple_sum = sum(apple)
#print(apple_sum)

if l > 0 :
    count = l
elif apple.append == 0:
    count = 0
else :
    count = l+n-1
apple_sum = apple_sum - count
#print(abs(n))
#print(count)
print(apple_sum)

Submission status: Wrong Answer

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

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

for j in range(n):
    a.append(abs(taste[j]))
#print(a)

print(sum(taste) - min(a))

Submission status: Wrong Answer

Solution code:
N,L = map(int,input().split())
deri = [L]
for num in range(0,N):
    deri.append(num)

deri.sort()
aut = sum(deri,1)
print(aut)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

num=1+l-1
number=[]
for _ in range(n):
  number.append(num)
  num+=1
  
num=sum(number)
if num==0:
  if 0 in number:
    print(sum(number))
    
  else:
    print(sum(number)-min(number))  
    
else:
  if all(i<=0 for i in number):
    print(sum(number)-max(number))
    
  else:
    print(sum(number)-min(number))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
s = [i+l for i in range(n)] 
s_abs = list(map(lambda x:abs(x),s))
print(sum(s)-min(s_abs))

Submission status: Wrong Answer

Solution code:
n,l = list(map(int,input().split()))
total,total1,total2 = 0,0,0
ansi = 1

for i in range(1,n+1):
  total1 += l + i - 1
for i in range(2,n+1):
  total2 += l + i - 1
ans1 = abs(total1) - abs(total2)

for i in range(2,n+1):
  ans = abs(total1) - abs(l + i - 1)
  if ans < ans1:
    ans1 = ans
    ansi = i

for i in range(1,n+1):
  if ansi == i:
    continue
  else:
    total += l + i -1
print(total)