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:

import numpy as np

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


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

tastes = taste(N, L)
import numpy as np

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


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

tastes = taste(N, L)
all = tastes[np.min(tastes) != tastes]

re = np.sum(all)
print(re)
all = tastes[np.min(tastes) != tastes]

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

Submission status: Runtime Error

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

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

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

d = set()
e =0

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

Submission status: Runtime Error

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

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

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

d = set()
e =0

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

Submission status: Runtime Error

Solution code:
N,L=input().split()
N=int(N)
L=int(L)
A=0
B=[]
C=[]
for j in range(1,N+1):
    A+=L+j-1
for i in range(1,N+1):
    if L+i-1>=0:
        B.append(L+i-1)
    else:
        C.append(L+i-1)
if min(B)<=abs(max(C)):
    print(A-min(B))
else:
    print(A-max(C))

Submission status: Runtime Error

Solution code:
N,L=map(int, input().split())
 
sum = 0
lower = 100
for i in range(1, N+1):
    sum = sum + L + i -1
for i in range(1, N+1):
    s = abs(L + i -1)
    if s < lower:
        lower = s
        ij = i
 
print(sum - (L + ij -1))

Submission status: Runtime Error

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

Nazi=[]

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

sum=0
if L>0:
    del Nazi[0]
    print(sum(Nazi))
else:
    for i in Nazi:
       sum+=i
    sum=(sum-Nazi[-1])
    print(sum)

Submission status: Runtime Error

Solution code:
lista = input().split(" ")
a, b, c, d = lista
a = int(a)
b = int(b)
c = int(c)
d = int(d)
s = 0
a1=[]

while(a!=0):
    s+=b
    a1.append(b)
    b+=1
    a-=1
if 0 in a1:
    print((int(s)))
elif(b>0):
    print((int(s)-min(a1)))
else:
    print((int(s)-max(a1)))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
from sys import stdin

N, L = stdin.readline().rstrip()

# N, L = 5, 2
# N, L = 3, -1
# N, L = 30, -50

min_value = L
max_value = L + N - 1

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

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

Submission status: Runtime Error

Solution code:
from sys import stdin

N, L = stdin.readline().rstrip()

# N, L = 5, 2
# N, L = 3, -1
# N, L = 30, -50

min_value = L
max_value = L + N - 1

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np

n, l = [int(i) for i in input().split(' ')]

nl = np.array([i for i in range(n)]) + 1
ll = nl + l - 1

mini = np.where(ll == np.min(np.absolute(ll)))
ll = list(ll)
del ll[mini[0][0]]

print(np.sum(ll))

Submission status: Runtime Error

Solution code:
N, L = (int(x) for x in input().split())
aji = [L+i for i in range(N)]
left = 0

while (aji[left] < 0):
    left += 1
ans = sum(aji) - aji[left]
print(ans)

Submission status: Runtime Error

Solution code:
N, L = (int(x) for x in input().split())
#リンゴiの味はL+i-1で与えられる。（i=1~N）
#作る予定のアップルパイの味の総和はN*(L-1) + 1/2*(N+1)*N
#出力はN-1個からアップルパイを作るとき、元の味との差が最小になる味
#味が0に最も近いものを探して、引けばよい。
aji = [L+i for i in range(N)]
#print(aji)
left = 0

while (aji[left] < 0):
    left += 1
#print(left)
ans = sum(aji) - aji[left]
print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n,l= int(input().split())
index = 0
taste = lー1
small = abs(taste)
for i in range(1, n):
    taste = taste + (l+i-1)
    if small >abs(l+i-1):
        index = i
        small = abs(l+i-1)
print(taste -(l+index-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if min(t) > 0:
    p = sum(t) - l
elif max(t) > 0:
    p = sum(t)
else:
    p = sum(t) - max(t)
print(p)

Submission status: Runtime Error

Solution code:
N,K = [int(i) for i in input().split()] 
bi=None
if 2<=1-L and 1-L<=N:
    bi =1-L
elif 1-L>=N:
    bi = N
elif 2>=1-L:
    bi =1
ajis = [L+i for i in range (N)]
org_sum = sum(ajis)
ans = org_sum -(L+bi-1)
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np

n, l = [int(i) for i in input().split(' ')]

nl = np.array([i for i in range(n)]) + 1
ll = nl + l - 1

mini = ll.index(np.min(np.absolute(ll)))
lll = ll.pop(mini)

print(np.sum(lll))

Submission status: Runtime Error

Solution code:
apples =str(input())
apples_list = apples.split(" ")
N = int(apples_list[0])
L = int(apples_list[-1])
pai_values = []
 
for i in range(1,N+1):
    pai_value = i + L -1
    pai_values.append(pai_value)
    
min_pai = abs(pai_values[0])
 
for j in range(N):
    if min_pai > abs(pai_values[j]):
        min_pai = abs(pai_values[j])
        target_number = j
        
pai_values.pop(target_number)
 
answer = sum(pai_values)
 
print(int(answer))

Submission status: Runtime Error

Solution code:
import numpy as np

l, n = [int(i) for i in input().split(' ')]

nl = np.array([i for i in range(n)]) + 1
ll = nl + l - 1

mini = ll.index(np.min(np.absolute(ll)))
lll = ll.pop(mini)

print(sum(lll))

Submission status: Runtime Error

Solution code:
apples =str(input())
apples_list = apples.split(" ")
N = int(apples_list[0])
L = int(apples_list[-1])
pai_values = []

for i in range(1,N+1):
    pai_value = i + L -1
    pai_values.append(pai_value)

min_pai = abs(pai_values[0])

for j in range(N):
    if min_pai > abs(pai_values[j]):
        min_pai = abs(pai_values[j])
        target_number = j

pai_values.pop(target_number)

answer = sum(pai_values)

print(int(answer))

Submission status: Runtime Error

Solution code:
n, l=map(int,input())
lists = []
for i in range(1,n+1):
	taste += l+i-1
	lists.append(abs(l+i-1))
lists.sort()
print(taste-lists[0])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import numpy as np
x, y = map(int, input().split())
A = []

for i in range(x):
    A.append(y)
    y += 1

B = np.abs(A)

we = min(B)

A.remove(we)
cnt = 0
for i in A:
    cnt += i

print(cnt)

Submission status: Runtime Error

Solution code:
import numpy as np

l, n = [int(i) for i in input().split(' ')]

nl = np.array([i for i in range(n)]) + 1
ll = nl + l - 1

mini = ll.index(min(abs(ll)))
lll = ll.pop(mini)

print(sum(lll))

Submission status: Runtime Error

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

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

x = L+sum(i)-1

d = set()

for b in i:
    d.add(abs(i))
c = min(d)
print(x-c)

Submission status: Runtime Error

Solution code:
N,L=map(int, input().split())
aaa = [*range(L, N + L)]
n = sum(aaa)
if n == 0:
    print(n)
elif n < 0:
    print(n - max(aaa))
else:
    print(n - min(aaa))

Submission status: Runtime Error

Solution code:
import numpy as np
from math import min

l, n = [int(i) for i in input().split(' ')]

nl = np.array([i for i in range(n)]) + 1
ll = nl + l - 1

mini = ll.index(min(abs(ll)))
lll = ll.pop(mini)

print(sum(lll))

Submission status: Runtime Error

Solution code:
import numpy as np
a = input()
n, l = [int(i) for i in a.split(" ")]
apples = np.array([i for i in range(n)])
aji = apples + l
abss = [np.abs(aji[apples != i].sum() - aji.sum()) for i in range(n)]
i = abss.index(np.min(abss))
print([aji[apples != i].sum()][i])

Submission status: Runtime Error

Solution code:
a,b,c,d = list(map(int, input().split())
s = 0
a1=[]

while(a!=0):
    s+=b
    a1.append(b)
    b+=1
    a-=1
if 0 in a1:
    print((int(s)))
elif(b>0):
    print((int(s)-min(a1)))
else:
    print((int(s)-max(a1)))

Submission status: Runtime Error

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

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

ringo=[]

for i in range(n):
	ringo.append(l+i)
min = abs(ringo[0])
min_nim = 0
for i in range(len(ringo)):
	if min > abs(ringo[i]):
		min = abs(ringo[i])
		min_num = i
out = 0
for i in range(len(ringo)):
	if i != min_num:
		out = out + ringo[i]
print(out)

Submission status: Runtime Error

Solution code:
apples =str(input())
apples_list = apples.split(" ")
N = int(apples_list[0])
L = int(apples_list[-1])
pai_values = []

for i in range(1,N+1):
    pai_value = i + L -1
    pai_values.append(pai_value)

min_pai = abs(pai_values[0])

for j in range(N):
    if min_pai > abs(pai_values[j]):
        min_pai = abs(pai_values[j])
        target_number = j

pai_values.pop(target_number)

print(sum(pai_values))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N,L=input().split()
N=int(N)
L=int(L)
A=0
B=[]
for j in range(1,N+1):
    A+=L+j-1
for i in range(1,N+1):
    B.append(abs(A-(L+i-1))
print(max(B))

Submission status: Runtime Error

Solution code:
import numpy as np
from math import min

l, n = [i for i in input().split(' ')]

nl = np.array([i for i in range(n)]) + 1
ll = nl + l - 1

mini = ll.index(min(abs(ll)))
lll = ll.pop(mini)

print(sum(lll))

Submission status: Runtime Error

Solution code:
l,m = map(int,input().split())
lis =[]
lis2=[]
for i in range(l):
  lis.append(m+i)
  lis2.append(abs(m+i))

lis.pop(lis2.index(min(lis2)))
print(sum(lis)

Submission status: Runtime Error

Solution code:
import sys
from io import StringIO
import unittest
import numpy as np


def resolve():
    N, L = map(int, input().split())
    taste = np.zeros(N)
    for i in range(N):
        taste[i] = L + i
    min_idx = np.argsort(np.abs(taste))[0]
    sum_taste = np.sum(taste) - taste[min_idx]
    print(np.int(sum_taste))
resolve()

Submission status: Runtime Error

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

aji = [(i+1)+L-1 for i in range(N)]
abs = list(map(abs, aji))
index = abs.index(min(abs))

print(sum(aji)-aji[index])

Submission status: Runtime Error

Solution code:
l,m = map(int,input().split())
lis =[]
lis2=[]
for i in range(l):
  lis.append(m+i-1)
  lis2.append(abs(m+i-1))

lis.pop(list_name.index(min(lis2)))
print(sum(lis)

Submission status: Runtime Error

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

mini = 100
index = ""
for i in range(N):
  if mini > abs(lis[i]):
    mini = abs(lis[i])
    index = i

print(sum(lis)-lis[index])

Submission status: Runtime Error

Solution code:
import numpy as np
from math import abs, min

l, n = [i for i in input().split(' ')]

nl = np.array([i for i in range(n)]) + 1
ll = nl + l - 1

mini = ll.index(min(abs(ll)))
lll = ll.pop(mini)

print(sum(lll))

Submission status: Runtime Error

Solution code:
N , X =map(int,input().split())
sums = []
i = X
result =[]
for i in range(N):
    sums.append(i+X)
for j in range(N):
    result.append(sum(sums)-sums[j]*2 )
for k in range(N):
    if sum(sums) == result[k]:
        print(result[k])
    else:
        print(abs(min(result[k])))

Submission status: Runtime Error

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

aji = [(i+1)+L-1 for i in range(N)]
min = min(list(map(abs, aji)))
print(sum(aji)-min)

Submission status: Runtime Error

Solution code:
N,L = [int(x) for x in input().split()]
A = list(range(L,L+N))
Min = 100
for i in A:
    if Min > abs(i):
        youso = i
        Min = abs(i)
A.remove(youso)
print(sum(A))

Submission status: Runtime Error

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

aji = [(i+1)+L-1 for i in range(N)]
min = min(list(map(aji, abs)))
print(sum(aji)-min)

Submission status: Runtime Error

Solution code:
N,L = [int(x) for x in input().split()]
A = list(range(L,L+N))
Min = 100
for i in A:
    if Min > abs(i):
        youso = i
        Min = abs(i)

A.remove(youso)
print(sum(A))

Submission status: Runtime Error

Solution code:
import collections as c
# from fractions import gcd
from math import gcd
ip = lambda : map(int, input().split())
# ##############
mod = 1e9+7
n,l = ip()
ans = 0
k=abs(l)
for i in range(l,l+n):
    ans+=i
    if abs(i) < abs(k):
        k = i
ans -= k
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
import matplotlib.pyplot as plt
N,L = list(map(int,input().split()))
aji=[]
for i in range(N):
    aji.append(L+i)

absaji = []
for i in range(N):
    absaji.append(abs(aji[i]))

#newaji = np.abs(aji)
minaji = min(absaji)

if sum(aji) < 0:
    sumaji = sum(aji) + minaji
else:
    sumaji = sum(aji) - minaji
print(sumaji)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import numpy as np

def main():

    N,L = (int(i) for i in input().split())
    L_list = [int(L+i) for i in range(N)]

    Tmp = L_list[0]


    if L_list[0] < 0:
        if L_list[0]+N-1 >= 0 :
            print(sum(L_list[:]))
        else:
            print(sum(L_list[:-1]))
    else:
        print(sum(L_list[1:]))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
a = input()
int(n), int(l) = a.split(" ")
apples = [i for i in range(n)]
abs_app = np.abs(apples)
m = abs_app.min()
app = np.array(apples)
app = app + l - 1
print(app[abs_app != m].sum())

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
import numpy as np
a = input()
n, l= a.split(" ")
apples = [i for i in range(n)]
abs_app = np.abs(apples)
m = abs_app.min()
print((np.array(apples)[abs_app == m]).sum())

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N ,L= map(int,input().split())
one_aji = 0
aji = []
answer = []
for i in range(N):
    one_aji = L+i
    if one_aji < 0:
        answer.append(one_aji)
        one_aji *= -1
        aji.append(one_aji)
    else:
        aji.append(one_aji)
        answer.append(one_aji)
zettai = 500
ind = 0
for i, a in enumerate(aji):
    a = int(a)
    if a < zettai:
        zettai = a
        ind = i
        
        
answer.pop(ind)
print(sum(answer)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, L = map(int, input().split())
taste = sp.arange(L, L+N)
s = sum(taste)

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[1]:


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


# In[40]:


taste = list(range(L, N+L))


# In[41]:


choice = min(list(map(abs, taste)))
taste.remove(choice)
print(sum(taste))

Submission status: Runtime Error

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

if L > 0:
  erase_apple = 0
elif L+N >= 0:
  for i in range(N):
    if i + L == 0:
      erase_apple = i
      break
else:
  erase_apple = N-1

if erase_apple == N:
  erase_apple = N-1

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

apples.pop(erase_apple)
print(sum(apples))

Submission status: Runtime Error

Solution code:
N,L=map(int,input().split())
x=10000
c=0
S=0
for i in range(N):
  xx=x
  x=max(x,abs(L+i-1))
  S=S+L+i-1
  if xx!=x
    if L+i-1<0:
      c=1
    else:
      c=0
r=S-((-1)**c)*x+S
print(r)

Submission status: Runtime Error

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

arr.remove(min)

print("{}".format(sum(arr)))

Submission status: Runtime Error

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

if L > 0:
  print("a")
  erase_apple = 0
elif L+N-1 >= 0:
  for i in range(N):
    if i + L == 0:
      break
else:
  erase_apple = N-1

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

apples.pop(erase_apple)
print(sum(apples))

Submission status: Runtime Error

Solution code:
n,l=map(int,input().split())
d=114514
num=114514
for j in range(n):
  if abs(l+j)<d:
    d=abs(l+j)
    num=j
s=0
for in range(n):
  s+=1
print(s+(n-1)*l-num)

Submission status: Runtime Error

Solution code:
(L + N - 1)

Submission status: Runtime Error

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



l = []

min_a = N + L * N


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

    if abs(a) < abs(min_a):
        min_a = abs(a)
        ans_i = i



    l.append(a)


ans = sum(l) - l[ans_i]

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if L > 0:
  erase_apple = 0
elif L+N >= 0:
  for i in range(N):
    if i + L == 0:
      erase_apple = i
      break
else:
  erase_apple = N-1
  
apples = []
for i in range(N):
  apples.append(L+i)

apples.pop(erase_apple)
print(sum(apples))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

x = 1 - l
if x <= n and x >= i:
    print(s)
else:
    a = L
    b = L + n - 1
    if abs(a) < abs(b):
        print(s - a)
    else:
        print(s - b)

Submission status: Runtime Error

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

x = 1 - l
if x <= n and x >= i:
	print(s)
else:
    a = L
    b = L + n - 1
    if abs(a) < abs(b):
      print(s - a)
    else:
      print(s - b)

Submission status: Runtime Error

Solution code:
import itertools

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

def output_list(v):
    print(' '.join(str(x) for x in v))

def main():
    n, l = input_ints()
    a = [*range(l, l + n)]
    ans = sum(a)
    if a[-1] < 0:
        ans -= a[-1]
    if a[0] > 0:
        ans -= a[0]
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

mn = 10*9
i = -1
for i in range(N):
  if mn > abs(a[i]):
    mn = abs(a[i])
    agmn = i
sm = 0
for i in range(N):
  if i!=agmn:
    sm += a[i]

# print(mn, agmn)
print(sm)

Submission status: Runtime Error

Solution code:
N, L =  list(map(int, input().split()))
r = np.arange(L, N + L)
print(np.sum(r) - r[np.argmin(np.abs(r))])