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,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])
  
print(sum(l))

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
object Main extends App {
  var Array(n, l)= readLine.split(" ").map(_.toInt)
  println(n*(n-1)/2+n*l - (if(l>0) l else if(-n>l) l+n-1 else 0))
}

Submission status: Runtime Error

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

applepie_n1 = 0
applepie_n2 = 0
apple = 0

for i in range(n):
  apple[i] = l+i-1 
  applepie_n1 += apple[i]
  
for j in range(n):
  apple[j] = l+j-1
  applepie_n2 = applepie_n1 - apple[j]
  min(abs(applepie_n1 - applepie_n2))
  
print(applepie_n2)

Submission status: Runtime Error

Solution code:
(int,input().split())
if L >= 0:
  print(int((N-1)/2*(L + L + N )))
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: Runtime Error

Solution code:
N,L=(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: Runtime Error

Solution code:
n, l = map(int, input().split())
pie = 0
min_aji = 100
for i in range(1, n+1):
    aji = l + i - 1
    pie += aji
    if abs(aji) < min_aji:
        min_aji = abs(aji)
        apple = i
        
pie -= l + apple -1

print(pie)

Submission status: Runtime Error

Solution code:
n, l = map(int, input().split())
pie = 0
min_aji = 100
for i in range(1, n+1):
    pie += l + i - 1
    if abs(l + i - 1) < min_aji:
        min_aji = abs(l + i - 1)
        apple = i
        
pie -= l + apple -1

print(pie)

Submission status: Runtime Error

Solution code:
n, l = map(int, input().split())
pie = 0
min_aji = 100
for i in range(1, n+1):
    if abs(l + i - 1) < min_aji:
        min_aji = abs(l + i - 1)
        apple = i
        
for i in range(1, n+1):
    if apple == i:
        continue
    pie += l + i - 1

print(pie)

Submission status: Runtime Error

Solution code:
# 味リストはL, L+1, L+2...
tastes = []
for i in range(n):
    tastes += [l+i]

# 味0があったらそれを食えばいい
if 0 in tastes:
    print(sum(tastes))
else:
    # 差が最小なのを食えばいい
    tastes.sort(key=abs)
    print(sum(tastes[1:]))

Submission status: Runtime Error

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

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

mi = min(abstaste)

try:
	taste.remove(mi)
except:
	taste.remove(-mi)
	print(sum(taste))
else:
	taste.remove(mi)
	print(sum(taste))

Submission status: Runtime Error

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

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

mi = min(abstaste)

taste.remove(mi)

print(sum(taste))

Submission status: Runtime Error

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

taste = []
abstaste = []
for i in range(n)
	taste.append(l+i)
	abstaste.append(abs(l+i))

mi = min(abstaste)

taste.remove(mi)

print(sum(taste))

Submission status: Runtime Error

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

r = l + n - 1

if r <= 0:
    eat = r
elif l >= 0:
    eat = l
else:
    eat = 0
print((R + L) * (R - L + 1) / 2 - eat)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:

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

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

Solution code:
from sys import stdin


def main():
    N, L = [int(x) for x in stdin.readline().rstrip().split()]

    apple_list = []

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

    s = sorted(apple_list, key=abs)
    s.pop(0)
    print(sum(s))
    //print(123)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n,l = map(int,input().split())
apple = [l + i -1 for i in range(1, n+1)]
org = sum(apple)
dif = org
for i in range(n):
    if abs(sum(apple[:i]+apple[i+1:]) - org) < dif:
        dif = abs(sum(apple[:i]+apple[i+1:]) - org)
        ans = sum(apple[:i]+apple[i+1:])
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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)))
  ajis.remove(mini)
  return sum(ajis)

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

Submission status: Runtime Error

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()
  mini = min([abs(x) for x in ajis])
  ajis.remove(mini)
  return sum(ajis)

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

Submission status: Runtime Error

Solution code:
def main08():
    data = input().split()
    nl = []
    for i in range(2):
        nl.append(int(data[i]))
    hantei = nl[0] + nl[1]
    result = 0
    if hantei <= nl[0] and 1 <= hantei:
        for i in range(nl[0]):
            result = result + nl[1] + i
    elif nl[1] > 0:
        for i in range(nl[0]-1):
            result = result + nl[1] + i + 1
    else:
        for i in range(nl[0]-1):
            result = result + nl[i] + i
    print(result)

if __name__ == "__main__":
    main08()

Submission status: Runtime Error

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

Submission status: Runtime Error

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 += abs(L + k - 1)

if min(ab):
    print(apple_pie - (L + ab.index(min(ab))  ))

Submission status: Runtime Error

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 += abs(L + k - 1)

if min(ab):
    print(apple_pie - (L + ab.index(min(ab))  - 1))

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

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

for k in range(1:N+1):
    ab = []
    ab += abs(L + k - 1)

if min(ab):
    print(apple_pie - (L + ab.index(min(ab))  - 1))

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

taste = L + i -1
for i in range(N):
    apple_pie_o += taste
    
    for k in range(N):
        ab = []
        ab += abs(L + k -1)
        if min(ab):
            apple_pie_a=apple_pie_o - (L + k -1)
            print(apple_pie_a)

Submission status: Runtime Error

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

taste = L + i -1
for i in range(N):
    apple_pie_o += taste
    
    for k in range(N):
        ab = []
        ab += abs(L + k -1)
        if min(ab):
            apple_pie_a=apple_pie_o - (L + k -1)
            print(apple_pie_a)

Submission status: Runtime Error

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

taste = 0

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

Submission status: Runtime Error

Solution code:
import sys
f = open('BiteEating_input.txt', 'r')#ファイルを読み込み
lines = f.readlines()#変数linesに1行ずつ読み込み.linesは配列

data = input().split()
N = int(data[0])
L = int(data[1])
taste = []
for i in range(N):
    taste.append(L + (i+1) - 1)
absTaste = []
for i in range(N):
    absTaste.append(abs(taste[i]))
index = 0
minimum = 0
for i in range(1,N):
    if absTaste[i-1] > absTaste[i]:
        index = i
        minimum = taste[i]
ans = sum(taste) - taste[index]#sumはリスト内の数値の合計を計算する関数
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

states = [L - (i + 1) - 1 for i in range(N)]
pie_state = sum(states)

ans = 0
if 0 in states:
    ans = pie_state
elif pie_state > 0:
    ans = pie_state - min(pie_state)
else:
    ans = pie_state - max(pie_state)

print(ans)

Submission status: Runtime Error

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

# find optical solution
states = []
for i in range(N):
    state = L + (i + 1) -1
    if state >= 0:
        states.append(state)

ate_apple_state = min(states)
# print(ate_apple_state)

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

# print(sum)

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

print(val)

Submission status: Runtime Error

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

if min(AJI) <= len(RINGO):
    RINGO.remove(min(AJI))
else:
    RINGO = []

print(sum(RINGO))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Solution code:
nl=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: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
N,L = map(int,input().split())
lst = [L]
for i in range(n-1):
  lst.append(lst[-1]+1)
arr = [abs(i) for i in lst]
del lst[arr.index(min(arr))]
print(sum(lst))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
N,L = map(int,input().split())
lst = [L]
for i in range(n-1):
  lst.append(lst[-1]-1)
arr = [abs(i) for i in lst]
del lst[arr.index(min(arr))]
print(sum(lst))

Submission status: Runtime Error

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


lis = []
for n in range(1, N+1):
    azi = L + n - 1
    lis.append(azi)

lis2 = [abs(l) for l in lis]

min = min(lis2)
del lis[min]

print(sum(lis))

Submission status: Runtime Error

Solution code:
s = 0
num_min = L + 1 - 1
num_max = L + N - 1
if 0 < num_min:
    s = sum([L + i - 1 for i in range(1, N+1)] ) - num_min
elif num_max < 0:
    s = sum([L + i - 1 for i in range(1, N+1)] ) - num_max
else:
    s = sum([L + i - 1 for i in range(1, N+1)] )
print(s)

Submission status: Runtime Error

Solution code:
#N  個のリンゴがあります。
#これらはそれぞれリンゴ 1、リンゴ 2、リンゴ 3、...、リンゴ N と呼ばれており、リンゴ i の「味」は L+i−1 です。
#「味」は負になることもありえます。
#また、1 個以上のリンゴを材料として、アップルパイをつくることができます。
#その「味」は、材料となったリンゴの「味」の総和となります。
#あなたはこれらのリンゴを全て材料として、アップルパイをつくる予定でしたが、おなかがすいたので 1 個だけ食べることにしました。
#勿論、食べてしまったリンゴはアップルパイの材料にはできません。
#つくる予定だったアップルパイとできるだけ同じものをつくりたいので、N 個のリンゴ全てを材料としてできるアップルパイの「味」と、食べていない N−1 個のリンゴを材料としてできるアップルパイの「味」の差の絶対値ができるだけ小さくなるように、食べるリンゴを選ぶことにしました。
#このようにして選ばれたリンゴを食べた時、食べていない N−1 個のリンゴを材料としてできるアップルパイの「味」を求めてください。
#なお、この値は一意に定まることが証明できます。

N, L = map(int, input().split())
A = [L+x for x in range(N)]

min_abs = abs(A[0])
ate = A[0]

for i in range(len(A)):
    if min_abs > abs(A[i]):
        min_abs = abs(A[i])
        ate = A[i]
        
print(sum(A)-eat)

Submission status: Runtime Error

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

total = sum(list(range(l, n+l)))
pie = []
min_abs = math.inf
for i in range(n):
    a = list(range(l, n+l))
    a.pop(i)
    if abs(total-sum(a)) < min_abs:
        min_abs = abs(total-sum(a))
        ans = sum(a)
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
NL = input()
N = int(NL[0])
L = int(NL[2])
apple = []
apple_abs = []
sum = 0
for i in range(1,N+1):
  apple.append(L+i-1)
  apple_abs.append(abs(L+i-1))
 
apple_min = min(apple_abs)
 
for i in apple:
  if abs(i) == apple_min:
    continue
  sum += i
print(sum)

Submission status: Runtime Error

Solution code:
NL = input()
N = int(NL[0])
L = int(NL[2])
apple = []
apple_abs = []
sum = 0
for i in range(1,N+1):
  apple.append(L+i-1)
  apple_abs.append(abs(L+i-1))

apple_min = min(apple_abs)

for i in apple:
  if abs(i) = apple_min:
    continue
  sum += i
print(sum)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
L = int(input())
tmp = abs(N) + abs(L)
s = 0
for i in range(N): 
    s += L + i
    if abs(L + i) < tmp:
        tmp = abs(L + i)
        cnt = i + 1
print(cnt)
print(s - (L + cnt -1))

Submission status: Runtime Error

Solution code:
N = int(input())
L = int(input())
tmp = abs(N + L)
s = 0
for i in range(N): 
    s += L + i
    if abs(L + i) < tmp:
        tmp = abs(L + i)
        cnt = i + 1
print(cnt)
print(s - (L + cnt -1))

Submission status: Runtime Error

Solution code:
N = int(input())
L = int(input())
tmp = 1000
s = 0
for i in range(N): #0<=i<=N-1
    s += L + i
    if abs(L + i) < tmp:
        tmp = abs(L + i)
        cnt = i + 1
print(cnt)
print(s - (L + cnt -1))

Submission status: Runtime Error

Solution code:
N = int(input())
L = int(input())
tmp = 5
s = 0
for i in range(N): #0<=i<=N-1
    s += L + i
    if abs(L + i) < tmp:
        tmp = abs(L + i)
        cnt = i + 1
print(cnt)
print(s - (L + cnt -1))

Submission status: Runtime Error

Solution code:
n,m=int(map(int,input()))
sum_=0
for i in range(n):
  sum_+=m+i
if n<abs(m):
  sum_-=(n-abs(m))
else:
  sum_-=m
print(sum_)

Submission status: Runtime Error

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

for i in range(N):
  lst.append(L + (i+1) - 1)
  
if L >= 0:
  print(sum(lst)-lst[0])
elif L+N-1 >= 0:
  print(sum(lst))
else:
  print(sum(lst) - lst[n-1])

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
using namespace std;
typedef long long ll ;
long const M=1000000007;
ll po(ll x, ll y) {
    ll t; 
    if( y == 0) 
        return 1; 
    t = po(x, y/2); 
    if (y%2 == 0) 
        return t*t; 
    else
        return x*t*t; 
} 

int main() {
	
    ll n ,l ,mini;
    cin >> n >> l ;
    mini = l ;
    if(mini> 0)
        cout << (n-1)*(2*mini+n)/2;
    else if (l+n-1 < 0)
        cout << (n-1)*(mini + mini + n -2)/2 ;
    else
        cout << n*(mini+mini+n-1)/2;
	return 0;
}

Submission status: Runtime Error

Solution code:
num, t = map(int, input().split())
taste = []
findmin = []

sum= 0
for i in range(1,len(num)+1):
  taste.append(t+i-1)
  sum += t+i-1
for j in range(len(taste)):
  findmin.append(j*j)
m = findmin.index(min(findmin))
print(sum - taste[m])

Submission status: Runtime Error

Solution code:
num, t = map(int, input().split())
taste = []
findmin = []

sum= 0
for i in range(len(num)):
  taste.append(t+i-1)
  sum += t+i-1
for j in range(len(taste)):
  findmin.append(j*j)
m = findmin.index(min(findmin))
print(sum - taste[m])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, X = map(int, input().split())
L = list(map(int, input().split()))
B=sum(L)
count=1
if X>=B:
  print(len(L)+1)
else:
  i=0
  H=0
  while H<=X:
    H=H+L[i]
    i=i+1
  print(i)

Submission status: Runtime Error

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

taste = []
taste_abs = []
min_taste = 0

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

sum_taste = sum(taste)
min_abs = min(abs(taste_abs))

print(sum_taste - min_abs)

Submission status: Runtime Error

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

taste = []
taste_abs = []
min_taste = 0

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

sum_taste = sum(taste)
min_abs = min(taste_abs)

for i in range(n):
    if min_abs == abs(taste[i])
    print(sum_taste - taste[i])
    break

Submission status: Runtime Error

Solution code:
a = input().split()
n = a[0]
l = a[1]

sum = 0
for i in range(n-1):
    sum = sum + (l + i - 1)

taste = [] #各パイの味

for i in range(n):
    taste = sum - (l + i - 1)

min_sa = 0
aaa = 0

for i in range(n):
    if min_sa > (sum - taste[i]):
        aaa = taste[i]

print(aaa)

Submission status: Runtime Error

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)

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

Solution code:
import sys

if __name__ == '__main__':
    N, A = sys.argv[1:]
    assert 2<=int(N)<=200
    assert -100<=int(A)<=100

    L = int(A)
    R = int(A)+int(N)-1

    if R <= 0:
        eat = R
    elif L >= 0:
        eat = L
    else:
        eat = 0

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, l = map(int, input().split())
 
total = 0
min_taste = 1000000000
 
for i in range(n):
    taste = l + i
    total += taste
    if abs(taste) < abs(min_taste):
        min_taste = taste
 
print(total - dis_min)

Submission status: Runtime Error

Solution code:
N,L = map(int,input().split())
taste = [None for _ in range(N)]
for i in range(N):
  taste[i] = L + i
taste_abs = [abs(taste[i]) for i in range(N)] 
  
p = taste.index(min(taste_abs))
taste[p] = 0
print(str(sum(taste)))

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
c = [i+b for i in range(a)]
d = [abs(j+b) for j in range(a)]
c.remove(min(d))
print(sum(c))

Submission status: Runtime Error

Solution code:
N, L = input().split()
apples = [x + int(L) for x in list(range(int(N)))]
abs_min_index = [abs(x) for x in apples].index(min(abs_apples))
print(sum(apples) - apples[abs_min_index])

Submission status: Runtime Error

Solution code:
N, L = input().split()
apples = [x + int(L) for x in list(range(int(N))]
abs_apples = [abs(x) for x in apples]
abs_min_index = abs_apples.index(min(abs_apples))
print(sum(apples) - apples[abs_min_index])

Submission status: Runtime Error

Solution code:
N, L = input().split()
apples = [x + int(L) for x in list(range(int(N))
abs_apples = [abs(x) for x in apples]
abs_min_index = abs_apples.index(min(abs_apples))
print(sum(apples) - apples[abs_min_index])

Submission status: Runtime Error

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

apples = list(range(N)) + L
abs_min = min([abs(x) for x in apples])
print(sum[apples] - abs_min*2)

Submission status: Runtime Error

Solution code:
N,L = map(int,input().split())
sumL = 0
mainasu = 0
plus = 0
aji = []
for i in range(N):
  aji.append(L + i)
  sumL += L + i
  if L + i == 0:
    count = 1
  elif L + i  < 0:
    mainasu += 1
  elif L + i > 0:
    plus += 1
if count == 1:
  print(sumL)
elif mainasu > plus :
  print(sumL-max((aji)))
else:
  print(sumL-min((aji)))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N,L = list(map(lambda x:int(x),input().split()))
apple = []
for i in range(N):
	apple.append(L + i )
abs_apple = list(map(lambda x: abs(x),apple))
print(sum(apple) - apple[apple.index(min(abs_apple))])

Submission status: Runtime Error

Solution code:
i = list(map(int,input().split()))
n = i[0]
l = i[1]
 
alist = []
i = 0
 
for i in range(n):
  x = l + i
  alist.append(x)
  
   
j = 0
m = 0
for j in range(n-1):
  if abs(alist[k]) >= abs(alist[k+1]):
    m = k+1
  
  
print(sum(alist) - alist[m])

Submission status: Runtime Error

Solution code:
i = list(map(int,input().split()))
n = i[0]
l = i[1]
 
alist = []
i = 1
 
for i in range(n):
  x = l + i - 1
  alist.append(x)
  
   
j = 0
m = 0
for j in range(n):
  if abs(alist[k]) >= abs(alist[k+1]):
    m = k+1
  
  
print(sum(alist) - alist[m])

Submission status: Runtime Error

Solution code:


i = list(map(int,input().split()))
n = i[0]
l = i[1]
 
alist = []
i = 1
 
for i in range(n):
  x = l + i - 1
  alist.append(x)
  
  
  
 
k = 0
m = 0
for k in range(n):
  if abs(alist[k]) >= abs(alist[k+1]):
    m = k+1
  
  
  
  
print(sum(alist) - alist[m])

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

i = list(map(int,input().split()))
n = i[0]
l = i[1]
 
alist = []
i = 1
 
for i in range(n):
  x = l + i - 1
  alist.append(x)
  
  
  
 
k = 0
m = 0
for k in range(n):
  if abs(alist[k]) >= abs(alist[k+1]):
    m = k+1
  
  
  
  
print(sum(alist) - alist[m])

Submission status: Runtime Error

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

"""
L + i - 1の対応する値の配列を作成する 
"""
apple_taste = []
taste_total = 0
for i in range(1, n + 1):
    apple_taste.append(L + i - 1)
    taste_total += L + i - 1


"""
要素数が少ないので愚直に一つずつ除外していって差がより小さい箇所を探す
"""

abs_taste_total = abs(sum(apple_taste))
ans = 10 ** 9 # これを差の絶対値が少ないときに入れ替えるようにする

for i in apple_taste:
    current_total = taste_total - i # iを食べたときの合計値
    abs_current_total = abs(abs(taste_total) - abs(i)) # 現在の値の絶対値。マイナス同士で引くと右辺が正の数として扱われるので絶対値にする

    current_abs = abs(abs(abs_taste_total) - abs(current_total))
    if current_abs < diff:
        diff = current_abs
        ans = current_total

print(ans)

Submission status: Runtime Error

Solution code:
# B - Bite Eating
# https://atcoder.jp/contests/abc131/tasks/abc131_b
"""
1~Nの数字がある
数列iの対応する値はL+i-1である

N = [1,2,3,4,5]
l = 1
対応する値=[2,3,4,5,6]

a = 対応する値の総和の絶対値を取得する
b = 1つだけ除外し、残った対応する値の総和の絶対値を取得する
aとbの差をなるべく小さくするには？
対応する値は負になることもある
"""

n, L = list(map(int, input().split()))

"""
L + i - 1の対応する値の配列を作成する 
"""
apple_taste = []
taste_total = 0
for i in range(1, n + 1):
    apple_taste.append(L + i - 1)
    taste_total += L + i - 1


"""
要素数が少ないので愚直に一つずつ除外していって差がより小さい箇所を探す
"""

abs_taste_total = abs(sum(apple_taste))
ans = 10 ** 9 # これを差の絶対値が少ないときに入れ替えるようにする

for i in apple_taste:
    current_total = taste_total - i # iを食べたときの合計値
    abs_current_total = abs(abs(taste_total) - abs(i)) # 現在の値の絶対値。マイナス同士で引くと右辺が正の数として扱われるので絶対値にする

    current_abs = abs(abs(abs_taste_total) - abs(current_total))
    if current_abs < diff:
        diff = current_abs
        ans = current_total

print(ans)

Submission status: Runtime Error

Solution code:
import sys
import math

args = sys.argv
n = args[0]
l = args[1]

n = int(n)
l = int(l)

all = []
for i in range(n):
    all.append(l+i)
all_sum = sum(all)

minus = 10000
ans = 0
for i in range(len(all)):
    if math.fabs(all_sum - (all_sum - all[i])) < math.fabs(minus):
        minus = math.fabs(all_sum - (all_sum -all[i]))
        ans = all_sum -all[i]
print(ans)

Submission status: Runtime Error

Solution code:
import sys

args = sys.argv
n = args[0]
l = args[1]

n = int(n)
l = int(l)

all = []
for i in range(n):
    all.append(l+i)
all_sum = sum(all)

minus = 10000
ans = 0
for i in range(len(all)):
    if abs(all_sum - (all_sum - all[i])) < abs(minus):
        minus = abs(all_sum - (all_sum -all[i]))
        ans = all_sum -all[i]
print(ans)

Submission status: Runtime Error

Solution code:
n,l = (int(I) for i in input().split())
d = (l-1)*n+(n+1)*n//2
if l<1: print(d+1-l-min(n,1-l))
else: print(d-l)

Submission status: Runtime Error

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

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

ans = 10 ** 9
for i in range(N):
  num = L + i
  if cnt >= abs(num):
    cnt = abs(num)
    ans = sums - num

print(ans)

Submission status: Runtime Error

Solution code:
n, l = (int(i) for i in input().split())
ap=[]

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

idx=ap.index(min(map(abs,ap)))

res=(l-1)*n+(1+n)*n/2-ap[idx]
print(res)

Submission status: Runtime Error

Solution code:
n, l = (int(i) for i in input().split())

ap=[]

for i in range(n):
	ap[i]=l+i

idx=ap.index(min(abs(ap))

res=(l-1)*n+(1+n)*n/2-ap[idx]

print(res)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

print(list)
list.sort(key=lambda x: abs(x))

del list[0]
print(sum(list))

Submission status: Runtime Error

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

apple = []
zerochk = False
tastes = 0
for i in range(N):
    taste = L + i
    apple.append(taste)
    tastes += taste
    if taste == 0: zerochk = True

ans = 0
minval = 100

if zerochk:

    print('{}'.format(tastes))

else if L > 0:

    for i in range(1, len(tastes)):
        ans += tastes(i)
    
    print('{}'.format(ans))

else: # L < 0

    for i in range(1, len(tastes)):
        minval = min(minval, abs(tastes[i]))
        ans += tastes(i)

    print('{}'.format(ans) - minval)

Submission status: Runtime Error

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

a = 10**6
b = 0
ans = 0
for i in range(1,N+1):
    if abs(L+i-1) < mina:
        mina = abs(L+i-1)
        minb = i
        
for i in range(1,N+1):
    if i != minb:
        ans += (L+i-1)

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

a = 10**6
b = 0
ans = 0


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

for i in range(1,N+1):
    if i != minb:
        ans += (L+i-1)

print(ans)

Submission status: Runtime Error

Solution code:
import math
import re
import time

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

total=(L-1)*N+((1+N)/2)*N
mn=1e9
for a in range(N):
    l=L+(a+1)-1
    total2+=l
    mn=min([mn,abs(l)])
#print("{} - {} = {}".format(total,mn,int(total-mn)))
print(int(total-mn))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np


def taste(N, L):
    all_abs = np.array([np.abs(L + i - 1) for i in range(1, N + 1)])
    all_base = np.array([L + i - 1 for i in range(1, N + 1)])

    return all_abs, all_base

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

all_abs, all_base = taste(N, L)

N_1_all = all_base[np.min(all_abs) != all_abs]

re = np.sum(N_1_all)
print(re)

Submission status: Runtime Error

Solution code:
def main():
    N, L = map(int, input().split())
    a = sum([L + n for n in range(N)])
    if L > 0:
        print(a - a[0])
    elif abs(L) >= N:
        print(a - a[-1])
    else:
        print(a)


main()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import fractions
n,l = map(int,input().split())
num = 1
sa = l+1-1

if (l+1-1)*(l+n-1)>0:
    num = min((l+1-1)**2,(l+n-1)**2)
else:
    num = 0



sum = 0
for i in range(1,n+1):
    sum += l+i-1
sum = sum - fractions.sqrt(num)

print(str(sum))