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: Runtime Error

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

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

for i in taste_lists:
  if i<0:
    taste_lists[i] = abs(i)

taste_lists.sort()
taste_lists.pop(0)

ans = 0
for i in taste_lists:
  ans += i
  
print(ans)

Submission status: Runtime Error

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

D=[]
for i in range(n):
    d = l+i
    D.append(d)

if l>-1 :
    mind = D[0]
elif l+n<0:
    mind = D[n-1]
else:
    mind = 0


ans = sum(D)-mind
print(ans

Submission status: Runtime Error

Solution code:
n,l = int(input())
tastes = [(i + l) for i in range(n)]
t = tastes.copy()
for j in range(n):
    t[j] = abs(t[j])
del tastes[t.index(min(t))]
print(sum(tastes))

Submission status: Runtime Error

Solution code:
L, L+1, L+2, ..., L+N-1
N, L = list(map(lambda x: int(x), input().split(" ")))

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

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

Submission status: Runtime Error

Solution code:
n, l = map(int, input().split())
t = list(map(lambda x: l + x, range(n)))
r = sum(t)
for i in range(n):
    tmp = sum(t[:i] + t[i + 1:])
    dif_t = abs(r - tmp)
    if i == 0:
        dif = dif_t
    if dif_t < dif:
        ans = tmp
        dif = dif_t
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
def pop_min_abs(l):
    abs = map(abs, l)
    return l.pop(abs.index(min(abs)))



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

apples = [l+i-1 for i in range(1,n+1)]
print(sum(pop_min_abs(apples)))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

# l ~ l+n-1

min_abs=99999999999
min_abs_i=-1
n_aji=0
for i in range(1,n+1):
  aji=l+i-1
  aji_abs=abs(aji)
  if aji_abs < min_abs:
    min_abs = aji_abs
    aji_abs_i = i
  n_aji+=aji

print(n_aji-(l+aji_abs_i-1))

Submission status: Runtime Error

Solution code:
n,l=map(int,input().split())
a=list(range(l,l+n,1))
x=sum(a)
if(a in 0):
  a.remove(0)
  print(sum(a))
elif(x<0):
  a.remove(max(a))
  print(sum(a))
elif(x>0):
  a.remove(min(a))
  print(sum(a))

Submission status: Runtime Error

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

apple = [L+i for i in range(N)]
min = 500
for k in range(len(apple)):
    if abs(apple[k])<min:
        min = abs(apple[k])

apple.remove(min)
print(sum(apple))

Submission status: Runtime Error

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

apple = [L+i for i in range(N)]
print(apple)
min = 500
for k in range(len(apple)):
    if abs(apple[k])<min:
        min = abs(apple[k])

apple.remove(min)
print(sum(apple))

Submission status: Runtime Error

Solution code:
N,L = map(int,input())
A = list()
for i in range(N):
  A.append(L+i)
A.sort()
S = sum(A)
if min(A)*max(A)<=0:
  print(S)
else:
  if L>=0:
    print(S-min(A))
  else:
    print(S-max(A))

Submission status: Runtime Error

Solution code:
n,l= map(int,input().split())
aj=[l + i  for i in range(n)]
ajs = sum(aj)
resl = []
for i in range(n):
    aj2 = aj
    del aj2[i]
    resl += [sum(aj2)]
resl2 = [abs(ajs-resl[i]) for i in range(n)]
x = resl2.index(min(resl2))
print(aj[x])

Submission status: Runtime Error

Solution code:
N,L=map(int,input().split())
li=[]
for i in range(N):
    li.append(L+i+1-1)
A=True
li.sort()
for j in range(N-1):
    if abs(li[j])<=abs(li[j+1]):
        S-=li[j]
        A=False
        break

if A==True:
    S-=li[N-1]

print(S)

Submission status: Runtime Error

Solution code:
N, L = map(int, input().split())
s = []
for i in N:
  s.append(i+L)
t = abs(s)
del s[t.index(min(s))]
print(sum(s))

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
total=a*(a+2*b-1)//2
x=b
y=a+b-1
if (abs(x)<abs(y):
  z=x
else:
  z=y
if x<=0 and y>=0:
  print(total)
else:
  print(total-z)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np

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

A = np.arange(N)+L

if A[0] <= 0 and A[N] => 0:
    print(np.sum(A))
elif A[0] < 0 and A[N] < 0:
    print(np.sum(A)-A[N])
else:
    print(np.sum(A)-A[0])

Submission status: Runtime Error

Solution code:
import numpy as np

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

A = np.arange(N)+L
if A[0] < 0 and A[N] > 0:
    print(np.sum(A))
elif A[0] < 0 and A[N] < 0:
    print(np.sum(A)-A[N])
else:
    print(np.sum(A)-A[0])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
l=[]
for i in range(1,n+1):
  l.append(abs(l-1+i))
mi=l.index(min(l))
print(n*(l-1)+sum(range(1,n+1))-l-mi)

Submission status: Runtime Error

Solution code:
l=[]
for i in range(1,n+1):
  l.append(abs(l-1+i))
mi=l.index(min(l))
print(n*(l-1)+sum(range(1,n+1)-l-mi)

Submission status: Runtime Error

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: Runtime Error

Solution code:
# ABC131A

s = input()
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
    print('Bad')
else:
    print('Good')

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import jit#import numbaで関数前で@numba.jitでもok
@jit
n,l=map(int,input().split())
a = np.arange(l,l+n)
d = abs(a).argmin() # argmin: ndarrayで最小値の要素のインデックスを取得
print(a.sum() - a[d])

Submission status: Runtime Error

Solution code:
import numpy as np
a = np.arange(L, L + N)
d = abs(a).argmin() # argmin: ndarrayで最小値の要素のインデックスを取得
print(a.sum() - a[d])

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

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

print(sum(A)-A[0])

Submission status: Runtime Error

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


print(sum(l)-l[l.index(min(l_abs))])

Submission status: Runtime Error

Solution code:
import io
import math
# libraries

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

if m<=0<=m+n-1:
  print(sum(range(m,m+n)))

  elif m<0:
  print(sum(range(m,m+n-1)))

  else:
  print(sum(range(m+1,m+n)))

Submission status: Runtime Error

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

for n in deri[0:]:
    if n <= 0 : deru.append(n*(-1))
    elif n >= 0 : deru.append(n)
    else : deru.append(0)

deru.sort()
rmv = deru.pop(0)
deri.remove(rmv)
out = sum(deri)
print(out)

Submission status: Runtime Error

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

if 0 in m:
  print(sum(m))
  
else:
  if m[0] < 0:
    print(sum(m)-max(m))
  else:
    print(sum(m)-min(m))

Submission status: Runtime Error

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

total = (l - 1) * n + n * (n + 1) // 2
min_diff = abs(total)
for i in range(n):
  apple = l + i
  apple_pie = total - apple
  diff = abs(apple)
  if diff < min_diff:
    min_diff = diff
    min_apple_pie = apple_pie
print(min_apple_pie)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, L = gets.split.map(&:to_i)
value = []
buf = []

(1..N).each do |i|
  data = L + i - 1
  value << data
  buf << data.abs
end

value.delete_at(buf.index(buf.min))
puts value.inject(:+)

Submission status: Runtime Error

Solution code:
N, L = map(int,input())
l, r = L, L + N - 1
total = (L - 1) * N + N * (N + 1) // 2
if l <= 0 and r >= 0:
    print(total)
if l > 0:
    total -= l
    print(total)
if r < 0:
    total -= r
    print(total)

Submission status: Runtime Error

Solution code:
n,l=map(int,input().split())
lst_kazu=[i for i in range(1,n+1)]
lst_aji=[i-l+1 for i in range(1,n+1)]
lst_aji_sum=sum(lst_aji)
aji_ans=0
for i in range(n):
	if lst_aji[i]==int(lst_aji_sum/n):
    	aji_ans=(lst_aji_sum-lst_aji[i])
        break
    else:
      	aji_ans=min(aji_ans,abs(lst_aji[i]-(lst_aji_sum-lst_aji[i])/n))
print(aji_ans)

Submission status: Runtime Error

Solution code:
n,l=map(int,input().split())
lst_kazu=[i for i in range(1,n+1)]
lst_aji=[i-l+1 for i in range(1,n+1)]
lst_aji_sum=sum(lst_aji)
aji_ans=0
for i in range(n):
	if lst_aji[i]==int(lst_aji_sum/n):
    	print(lst_aji_sum-lst_aji[i])
        break
    else:
      	aji_ans=min(aji_ans,ans(lst_aji[i]-int(lst_aji_sum/n)))
print(aji_ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int n,l,ans=0,ab;
    cin >> n >> l;
    vector<int> app(n);
    rep(i,n) app[i] = l+i; 

    sort(app.begin(),app.end());

    ab = app[0];

    rep(i,n){
       ab = min(abs(ab),abs(app[i]));
       ans += app[i];
    }
    cout << ans-ab << endl;
    return 0;
}

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import math as m
import sys
a,b=map(int,input().split())
c=0
if a+b<0:
  for i in range(a-1):
    c+=m.sqrt(b)
    b+=1
  print(c)
  sys.exit()
else:
  for i in range(a-1):
    c+=(b+1)
    b+=1
  print(c)

Submission status: Runtime Error

Solution code:
N, L = (int(nl) for nl in input().split())
tastes = [L+i-1 for i in range(1, N+1)]
min_taste = 0
min_taste_abs = 100
for taste in tastes:
    if min_taste_abs > abs(taste):
        min_taste_abs = abs(taste)
        min_taste = taste

min_taste_index = tastes.index(min_taste)
if len(tastes) == min_taste_index+1:
    print(sum(tastes[:min_taste_index]))
else:
    print(sum(tastes[:min_taste_index]+tastes[min_taste_index+1:]))

Submission status: Runtime Error

Solution code:
N, L = (int(nl) for nl in input().split())
tastes = [L+i-1 for i in range(1, N+1)]
min_taste = 0
min_taste_abs = 100
for taste in tastes:
    if min_taste_abs > abs(taste):
        min_taste_abs = abs(taste)
        min_taste = taste
min_taste_index = tastes.index(min_taste)
print(sum(tastes[:min_taste_index]+tastes[min_taste_index+1:]))

Submission status: Runtime Error

Solution code:
N, L = (int(nl) for nl in input().split())
tastes = [L+i-1 for i in range(1, N+1)]
min_taste = 0
min_taste_abs = 100
for taste in tastes:
    if min_taste_abs > abs(taste):
        min_taste_abs = abs(taste)
        min_taste = taste

min_taste_index = tastes.index(min_taste)
print(sum(tastes[:min_taste_index]+tastes[min_taste_index+1:]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,L=map(int,input().split())
＃リンゴの味のリスト
s=[]
for i in range(1,N+1):
  s.append(L+i-1)
＃リンゴの味の絶対値のリスト
s.remove(min(abs(s[i-1])))
print(sum(s))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

A.remove(min([abs(a) for a in A]))
print(sum(A))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
l = int(input())
if 2 <= n and n <= 200 and -100 <= l and l <= 100:
    apples = [(i + l) for i in range(n)]
    eaten = min(apples)
    print(sum(apples) - eaten)

Submission status: Runtime Error

Solution code:

    n = int(input())
    l = int(input())
    if 2 <= n and n <= 200 and -100 <= l and l <= 100:
        apples = [(i + l) for i in range(n)]
        eaten = min(apples)
        print(sum(apples) - eaten)

Submission status: Runtime Error

Solution code:
def main() :
    n = int(input())
    l = int(input())
    if 2 <= n and n <= 200 and -100 <= l and l <= 100:
        apples = [(i + l) for i in range(n)]
        eaten = min(apples)
        print(sum(apples) - eaten)

if __name__ == "__main__":
    main();

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
N, L = map(int,input().split())

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

SUM = sum(taste)

DIF = abs(SUM - (SUM - taste[0]))
ans = SUM - taste[0]
for i in range(1,N + 1):
    x = SUM - taste[i]
    if abs(SUM - x) < DIF:
        DIF = abs(SUM - x)
        ans = x
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,L = map(int,input().split())
a_list = []
for i in range(N):
    diff = abs(((L-1)*(N-1)-i))
    a_list.append(diff)
    
print(sum(list(N+1))-((L-1)*(N-1) - min(a_list)))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range(n):
  apple.append([abs(i+l), i+l])
  c += l+i

apple.sort()

print(ret-A[0][i])

Submission status: Runtime Error

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

N_list = [ i for i in range(1,N+1)]

aaa_list = []

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

print(sum(aaa_list)-min(list_aaa,key=lambda x: abs(x)))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, l = map(int, input().split())
ans = n*((l-1)+0.5*n*(n-1))
if l>=O:
 	print(ans-l)
else:
 	print(ans)

Submission status: Runtime Error

Solution code:
n, l=map(int, input().split())
ans=n*((l-1)+0.5*n*(n-1))
for i in range(n):
  if l>=O:
    print(ans-l)
  else:
    print(ans)

Submission status: Runtime Error

Solution code:
import math
N,L = input().split()
N,L = int(N),int(L)
c = math.gcd(6,8)

if(L>=0):
    print(int(0.5*N*(N+1)+N*L-N-(L)))
else:
    n = min([-L,N-1])
    print(int(0.5*N*(N+1)+N*L-N-(L+n)))

Submission status: Runtime Error

Solution code:
import math
N,L = input().split()
N,L = int(N),int(L)
c = math.gcd(N,L)

if(L>=0):
    print(int(0.5*N*(N+1)+N*L-N-(L)))
else:
    n = min([-L,N-1])
    print(int(0.5*N*(N+1)+N*L-N-(L+n)))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if l >= 0:
    ls.pop(0)
elif n >= abs(l):
    ls.pop(abs(l))
else:
    ls.pop(-1)

print(sum(ls))

Submission status: Runtime Error

Solution code:
S = list(input())

if (S[0]==S[1])or(S[1]==S[2])or(S[2]==S[3]):
  print('Bad')
else:
  print('Good')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,l=map(int,input().split())
aji=[]
for i in range(n):
    aji+=[l+i]
su=sum(aji)
c=[su]
for i in range(n):
    c=[abs(su-aji[i])]
c.sort()
print(s)

Submission status: Runtime Error

Solution code:
n, l = map(int, input().split())
a = range(l. l + n)
print(sum(a) - min(a, key=abs))

Submission status: Runtime Error

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


A=[]
for i in range(N):
    a=L+i
    A.append(a)

T=0
for i in range(N):
    T+=A[i]    

if T>=0:
    A.pop(0)
else:
    A.pop(N)

T2=0
for i in range(N-1):
    T2+=A[i]

print(T2)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=[int(i) for i in input().split()]
array=[]
abs_array=[]
for i in range(n[0]):
  array.append(n[1]+i-1)
  abs_array.append(abs(n[1]+i-1))
abs_array=abs_array.sort()
if(abs_array[0] in array == True):
  print(sum(array)-abs_array[0])
else:
  print(sum(array)+abs_array[0])

Submission status: Runtime Error

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

ans == 0
for i in range(1,n+1):
  p = list[L+i-1]
  ans += p[i]

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,L = map(int,input().split())
azi = []
for i in range(N):
    azi.append(i+L)
if min(azi) > 0:
    k = min(azi)
elif min(azi) < 0 and max(azi) > 0:
    k = 0
elif max(azi) < 0:
    k = max(azi)
azi.remove(k)
print(sum(azi))

Submission status: Runtime Error

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

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

if L < 0 and L + N > 0:
    eat_a = 0
elif L < 0 and L + N < 0:
    eat_a = L + N
elif L > 0 and L + N > 0:
    eat_a = L
print(int(aji_sum - eat_a))

Submission status: Runtime Error

Solution code:
N = int(input())
L = int(input())

apple_list = list(k for k in range(1, N + 1))
aji_list = []

for i in range(N):
    aji = L + apple_list[i] - 1
    aji_list.append(aji)
# print(aji_list)
if int(0) not in aji_list and aji > 0:
    del aji_list[0]
    ans = sum(aji_list)
    print(ans)
elif int(0) not in aji_list and aji < 0:
    del aji_list[-1]
    ans = sum(aji_list)
    print(ans)
elif int(0) in aji_list:
    aji_list.remove(0)
    ans = sum(aji_list)
    print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
L = int(input())

apple_list = list(k for k in range(1, N + 1))
aji_list = []

for i in range(N):
    aji = L + apple_list[i] - 1
    aji_list.append(aji)
# print(aji_list)
if int(0) not in aji_list and aji > 0:
    del aji_list[0]
    ans = sum(aji_list)
    print(ans)
elif int(0) not in aji_list and aji < 0:
    del aji_list[-1]
    ans = sum(aji_list)
    print(ans)
else:
    aji_list.remove(0)
    ans = sum(aji_list)
    print(ans)

Submission status: Runtime Error

Solution code:
N: int = int(input())
L = int(input())

apple_list = list(k for k in range(1, N+1))
aji_list=[]

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

if int(0) not in aji_list and aji > 0:
    del aji_list[0]
    ans = sum(aji_list)
    print(ans)

elif int(0) not in aji_list and aji < 0:
    del aji_list[-1]
    ans = sum(aji_list)
    print(ans)
else:
    aji_list.remove(0)
    ans = sum(aji_list)
    print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
L = int(input())

apple_list = list(k for k in range(1,N+1))
aji_list=[]

for i in range(N):
    aji = L+apple_list[i]-1
    aji_list.append(aji)
#print(aji_list)

if int(0) not in aji_list and aji > 0:
    del aji_list[0]
    ans = sum(aji_list)
    print(ans)

elif int(0) not in aji_list and aji < 0:
    del aji_list[-1]
    ans = sum(aji_list)
    print(ans)
else:
    aji_list.remove(0)
    ans = sum(aji_list)
    print(ans)

Submission status: Runtime Error

Solution code:
N,L = list(map(int,input().split()))
A = list(range(L,L+N))
ans = sum(A)
if abs(A[0])>abs(A[N]):
  print(ans-A[N])
else:
  print(ans-A[0])

Submission status: Runtime Error

Solution code:
n,l = map(int, input().split())
a = []
ans = 0
for i in range(1, n+1):
  a.append([l + i - 1, abs(l + i - 1)])
a = sorted(a, key = lambda x:x[1], reverse = True)
a.pop()
for _ in range(n-1):
  ans += a[0]
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, l = (int(i) for i in input().solit())
ans = 0
flg = 0
min = 1000
for i in range(n) :
  sum =  l + (i + 1) - 1
  if sum == 0 :
    flg = 1
  elif min > sum :
    min = sum
  ans += sum
if flg == 1 :
  print(ans)
else :
  print(ans - sum)

Submission status: Runtime Error

Solution code:
import numpy as np
 
# 2つの整数の入力
N, L = map(int, input().split())
 
# 味を数列化
taste = np.arange(L, L + N, 1)
 
# 味の最小・最大ともに0以上の場合は最小値を選ぶ
if np.min(taste) >= 0 and np.max(taste) >= 0:
  print("{}".format(np.sum(taste) - np.min(taste)))
 
# 味の最小・最大ともに0以下の場合は最大値を選ぶ
elif np.min(taste) <= 0 and np.max(taste) <= 0:
  print("{}".format(np.sum(taste) - np.max(taste)))
 
# それ以外の場合は0を選ぶ
else:
  print("{}".format(np.sum(taste)))
import numpy as np

# 2つの整数の入力
N, L = map(int, input().split())

# 味を数列化
taste = np.arange(L, L + N, 1)

# 味の最小・最大ともに0以上の場合は最小値を選ぶ
if np.min(taste) >= 0 and np.max(taste) >= 0:
  print("{}".format(np.sum(taste) - np.min(taste)))

# 味の最小・最大ともに0以下の場合は最大値を選ぶ
elif np.min(taste) <= 0 and np.max(taste) <= 0:
  print("{}".format(np.sum(taste) - np.max(taste)))

# それ以外の場合は0を選ぶ
else:
  print("{}".format(np.sum(taste)))

Submission status: Runtime Error

Solution code:
n,l = map(int,input().split())
li = []
for i in range(1,n+1):
  li.append(abs(l+i-1))
m = min(li)
if l+i-1 >= 0:
  print(n*(l-1)+(n*(n+1)/2)-l-i+1):
else:
  print(n*(l-1)+(n*(n+1)/2)+l+i-1)

Submission status: Runtime Error

Solution code:
apples = [l+i for i in range(n)] 
ans = sum(apples) - apples[apples.index(min(apples, key=abs))]
print(ans)

Submission status: Runtime Error

Solution code:
import sys
N, L = map(int, sys.stdin.readline().split())
tastes= [L+i-1 for i in range(1, N+1)]

if 0 < L:
  tastes.pop(0)

elif L+N < 0:
  tastes.pop(-1)

elif L <= 0 and 0<=L+N:
  tastes.pop(-L)

print(sum(tastes))
exit()

Submission status: Runtime Error

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

flavors = [x + L - 1 for x in range(1, N + 1)]
planned_pie = sum(flavors)
eat = min(flavors)
eat_abs = -min([abs(x) for x in flavors])
print([planned_pie - max(eat, eat_abs) if planned_pie <
       0 else planned_pie - max(eat, eat_abs)][0])

Submission status: Runtime Error

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

x=[l+i-1 for i in range(1,n+1)]

min_val=None
idx=0
for i in x:
  if min_val is None or abs(l+i-1) < min_val:
    min_val=abs(l+i-1)
    idx=i-1

x.pop(idx)
print(sum(x))

Submission status: Runtime Error

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

apples=[a+i for i in ragen(n)]
eat=min(apples,key=lambda x:abs(x))
res=sum(apples)-eat

print(res)

Submission status: Runtime Error

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

l=[a+i-1 for i in range(1,n+1)]

import numpy as np
b=min(np.abs(l))

if b==0:
  l.remove(0)
else:
  l.remove([b,-b],1)
  
print(sum(l))