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:
taste_all = 0
list1 = []
N, L = map(int, input().split()) 
for i in range(1,N+1):
    taste = L + i -1
    list1.append(taste)
    taste_all =taste_all + taste
z = 10000000
anser = 10000000
b = 0
c = 0
for j in range(N):
    a = list1.pop(j)
    b = sum(list1)
    z = abs(taste_all-b)
    anser = min(z,anser)
    c = c + 1
    list1.insert(j,a)
c = list1.pop(c-1)
anser = sum(list1)
print(anser)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,L = map(int,input().split())
aji = [abs(L+i-1) for i in range(1,N+1)]
minaji = max(aji)
no = 0
for i in range(N):
    if aji[i] < minaji:
        no = i + 1
        minaji = aji[i]
print(no)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
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: Wrong Answer

Solution code:
n,m=map(int,input().split())
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: Wrong Answer

Solution code:
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))

N, L = read_int()

apples = [L + i for i in range(N)]
print(apples)
tasteN = sum(apples)
print(tasteN)
INF = float('INF')
def solve():
    res = INF
    for a in apples:
        res = min(res, abs(a))
        print(res)
    return tasteN - res if res * tasteN > 0 else tasteN + res

if __name__ == "__main__":
    print(solve())

Submission status: Wrong Answer

Solution code:
N, L = map(int,input().split())
c = 0
taste_sum = 0
list1 = []
list2 = []
for i in range(N):
    list1.append(L + i)

taste_sum = sum(list1)
if 0 in list1:
    print(0)
elif taste_sum > 0:
    for i in range(1,N):
        c += list1[i]
    print(c)
elif taste_sum < 0:
    for i in range(0,N-1):
        c += list1[i]
    print(c)

Submission status: Wrong Answer

Solution code:
N, L = map(int,input().split())
c = 0
zero = 0
list1 = []
for i in range(N):
    list1.append(L + i)
list1.sort()

zero = sum(list1)
if zero == 0:
    print(0)

elif L >= 0:
    for i in range(1,N):
        c += list1[i]
    print(c)

else:
    for i in range(0,N-1):
        c += list1[i]
    print(c)

Submission status: Wrong Answer

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

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

if l-n <= 0:
	ans -= l+n-1

print(ans)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
eat = L + N - 1
if eat > 0:
  eat = L
  if not eat > 0:
    eat = 0

print(1/2*N*(N-1)+(L-1)*N-eat)

Submission status: Wrong Answer

Solution code:
def print_ans(N,L):
  """
  Parameters
  --------------
  >>> print_ans(5,2)
  18
  >>> print_ans(3,-1) 
  0
  >>> print_ans(30,-50)
  -1044
  """
  ans = 0
  if L >= 0:
    ans = (L+N-1+L+1)*(N-1)//2
  elif L+N-1 <= 0:
    ans = (L+N-2+L)*(N-1)//2
  else:
    ans = (L+N-1+L)*(N-1)//2

  print(ans)
  

def main():
  N,L = map(int,input().split())
  print_ans(N,L)


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

applePie = L*N
min = 20000

for i in range(N):
    applePie += i
    if (L+i) < min:
        min = L+i

applePie -= min

print(applePie)

Submission status: Wrong Answer

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

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

print(applePie)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
quantity, basis = map(int, input().split())

taste = {}

for i in range(1, quantity + 1):
  taste[str(i)] = basis + i - 1

eatTaste = abs(taste["1"])
eatApple = 1

for i in range(1, quantity + 1):
  if (eatTaste > abs(taste[str(i)])):
    eatApple = i

tastePai = 0
for i in range(1, quantity + 1):
  if (i != eatApple):
    tastePai += taste[str(i)]

print(tastePai)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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

tas_li = []

for i in range(1,N+1):
    taste = L + i - 1
    tas_li.append(taste)
    
abs_li = list(map(abs, tas_li))

#print(N, L)
#print(tas_li, abs_li)

eat = min(abs_li)
pie_taste = sum(tas_li)-eat

print(pie_taste)

Submission status: Wrong Answer

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

taste = 0
for n in range(1, N+1):
    taste+=n+L-1
if (L > 0):
    taste-=L
elif (0 > N+L):
    taste-=N+L-1

print(taste)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b=input().split(" ")
a=int(a)
b=int(b)

total=a*(b-1)+a*(a+1)/2

c=abs(b)
d=1
for i in range (1, a+1):
    if abs(b+i-1)<c:
        d=i

print(int(total-(b+d-1)))

Submission status: Wrong Answer

Solution code:
a, b=input().split(" ")
a=int(a)
b=int(b)

total=a*(b-1)+a*(a+1)/2

c=abs(b)
d=1
for i in range (1, a+1):
    if abs(b+i-1)<=c:
        d=i

print(int(total-(b+d-1)))

Submission status: Wrong Answer

Solution code:
a, b=input().split(" ")
a=int(a)
b=int(b)

total=a*(b-1)+a*(a+1)/2

c=abs(b)
for i in range (1, a+1):
    c=min(c, abs(b+i-1))

print(int(total-c))

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
A = [] # リスト宣言(りんごの味)

for i in range(N):
    A.append(L + i) # A.append([追加するもの])

total = sum(A) # リストAの総和

# 持ってるりんごの味で一番絶対値が小さいものを選ぶ
b = 1000000
j = 0 # 絶対値が一番小さいりんごの番号
for i in range(N):
    if abs(A[i]) < b:
        j = i

print(total - A[j])

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
A = [] # リスト宣言(りんごの味)

for i in range(N):
    A.append(L + i) # A.append([追加するもの])

total = sum(A) # リストAの総和

# 持ってるりんごの味で一番絶対値が小さいものを選ぶ
b = 10000
j = 0 # 絶対値が一番小さいりんごの番号
for i in range(N):
    if abs(A[i]) < b:
        j = i

print(total - A[j])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
apple_sum = 0
eat_apple = float('inf')

for i in range(1,n+1):
	apple_sum += l + i - 1
	eat_apple = min(abs(l+i-1),abs(eat_apple))

ans = apple_sum - eat_apple

print(ans)

Submission status: Wrong Answer

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)

print(sum_taste - min_abs)

Submission status: Wrong Answer

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: Wrong Answer

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

taste = []
taste_abs = []

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

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

Submission status: Wrong Answer

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

sum = 0

# taste is always positive
if l > 0:
  for i in range(1, n):
    sum += l + i

# taste is always negarive
elif l + n - 1 < 0:
  for i in range(1, n):
    sum += l + i - 1
    
else:
  for i in range(1, n+1):
    print(i)
    taste = l + i - 1
    if i == n or abs(taste) > abs(taste + 1):
      print(taste)
      sum += taste

print(sum)

Submission status: Wrong Answer

Solution code:
x,y = input().split()
z = int(x)
g = int(y)
taste = []
ataste = []
num = 0
while z-1 >= num :
    num += 1
    num2 = g + num - 1
    if num2 < 0:
        num3 = num2*-1
    else:
        num3 = num2
    taste.append(num2)
    ataste.append(num3)
n = sum(taste)
m = min(ataste)
print (n -m)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
L = list(range(L, N+L))
L=list(map(lambda x: abs(x), L))
L.pop(L.index(min(L)))
print(sum(L))

Submission status: Wrong Answer

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

taste = 0
taste_sum = 0
eat = 0
temp_eat = 0

for i in range(1,N+1):
  taste = L+i-1
  taste_sum += taste
  if i == 1:
    eat = taste
    temp_eat = abs(taste)
  elif abs(taste) < temp_eat:
    eat = taste

print(taste_sum - eat)

Submission status: Wrong Answer

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

taste = 0
taste_sum = 0
eat = 0
temp_eat = 0

for i in range(1,N+1):
  taste = L+i-1
  taste_sum += taste
  if i == 1:
    temp_eat = abs(taste)
  elif abs(taste) < temp_eat:
    eat = taste

print(taste_sum - eat)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

avg = [abs(sum(lst) - i) for i in lst]

cnt = 0
tmp = 999
for n in range(len(avg) - 1):
    ans = abs(sum(lst) - avg[n])
    if abs(sum(lst) - avg[n]) < tmp:
        cnt = n
        tmp = ans
print(sum(lst) - lst[cnt])

Submission status: Wrong Answer

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

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

avg = [abs(sum(lst) - i) for i in lst]

cnt = 0
tmp = 999
for n in range(len(avg)):
    ans = abs(sum(lst) - avg[n])
    if abs(sum(lst) - avg[n]) < tmp:
        cnt = n
        tmp = ans
print(sum(lst) - lst[cnt])

Submission status: Wrong Answer

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

def solve():
    N, L = list(map(int, input().split()))
    all_taste = 0
    eat_taste = float("inf")
    for i in range(1, N+1):
        all_taste += L+i-1
        eat_taste = min(eat_taste, abs(L+i-1))
    print(eat_taste)
    
    if all_taste > 0:
        ans = all_taste - eat_taste
    else:
        ans = all_taste + eat_taste
    print(ans)



if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
A = [i for i in range(L,L+N)]
sum_A = sum(A)
B = [sum(A[:i]+A[:i]) for i in range(len(A))]
print(sorted(B, key=lambda x: abs(x-sum_A))[0])

Submission status: Wrong Answer

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

taste = [i for i in range(N)]

for i in range(N):
  taste[i] = taste[i] + L
  
sum_taste = sum(taste)

result = 10 ** 10

for i in range(N):
  if abs(sum_taste - abs(sum_taste - taste[i])) < abs(sum_taste - result):
    result = sum_taste - taste[i]

print(result)

Submission status: Wrong Answer

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

taste = [i for i in range(N)]

for i in range(N):
  taste[i] = taste[i] + L
  
  
sum_taste = sum(taste)

result = 10 ** 10
for i in range(N):
  if abs(sum_taste - taste[i]) < abs(result):
    result = sum_taste - taste[i]
    
print(result)

Submission status: Wrong Answer

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

taste = [i for i in range(N)]

for i in range(N):
  taste[i] = taste[i] + L
  
  
sum_taste = sum(taste)

result = 10 ** 10
for i in range(N):
  if abs(sum_taste - taste[i]) < result:
    result = sum_taste - taste[i]
    
print(result)

Submission status: Wrong Answer

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

for i in range(1,N+1):
    value = i + L - 1
    s.append(value)
    if abs(eat) > abs(value):
        eat = value

print(s)
print(eat)
print(sum(s))
print(sum(s) - eat)

Submission status: Wrong Answer

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

for i in range(1,N+1):
    value = i + L - 1
    s.append(value)
    if value == 0 or (eat != 0 and eat > value):
        eat = value

print(sum(s) - eat)

Submission status: Wrong Answer

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)]
print(sum(c)-min(d))

Submission status: Wrong Answer

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

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

import itertools
c = itertools.combinations(Apple, N-1)
apple_sum = sum(Apple)
mi = (apple_sum + 1 )* 100
near = mi
ans = mi

if 0 in Apple:
  print(apple_sum)
else:
  for v in c:
    if apple_sum - sum(v) <= near:
      mi = sum(v)
      near = apple_sum - mi
  print(mi)

Submission status: Wrong Answer

Solution code:
S=str(input())

ans='Good'
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        ans='Bad'
print(ans)

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
apples = [l+i-1 for i in range(n)]
apples.sort(key=lambda x: abs(x))

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

Submission status: Wrong Answer

Solution code:
print("食べてしまった分、一緒にりんごを買いに行く")

Submission status: Wrong Answer

Solution code:
import sys
n,l=map(int,input().split())
ls=[]
for i in range(n):
    ls.append(l+i)  #iは0から始まるので-1した

ls.sort()
st=0
hoge=0
sum_ls=sum(ls)

def i_hantei(k):
    if k!=0:
        return True
    return False

if ls[-1]<0:
    print(sum_ls-ls[-1])
    sys.exit()
if ls[0]>0:
    print(sum_ls-ls[0])
    sys.exit()

for i in range(n):
    if ls[i]<0:
        st=0
    else:
        if st==0:
            if i_hantei(i)==False:
                hoge=ls[i]
                break
            if abs(ls[i-1])<=abs(ls[i]):
                hoge=ls[i-1]
            else:
                hoge=ls[i]
print(sum_ls-hoge)

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
ii=1
minn=99999999999
summ=0

for i in range(1,n+1,1):
    summ=summ+(l+i-1)
    if abs(l+i-1)<minn:
        minn=abs(l+i-1)
        ii=i


print(summ-minn)

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
ii=1
minn=99999999999
summ=0

for i in range(1,n+1,1):
    summ=summ+(l+i-1)
    if l+i-1<minn:
        minn=l+i-1
        ii=i


print(summ-(l+ii-1))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
 
if L > -1:
  N_eat = 1
elif N+L-1 < 1:
  N_eat = N
else:
  N_eat = 1-L
 
pie = N*(N+1)/2 +N*(L-1) - (L + N_eat-1) 
print("{}".format(pie) )

Submission status: Wrong Answer

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

if L > -1:
  N_eat = 1
elif N+L-1 < 1:
  N_eat = N
else:
  N_eat = 1-L
 
pie = N*(N+1)/2 +N*(L-1) - (L + N_eat-1) 
print("{}".format(pie) )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

min_ = L
max_ = L + N -1

def eat_apple(N, L):
    if max_<0:
        return max_ 
    return L

print((min_+max_)*(max_-min_+1)//2 - eat_apple(N, L))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
ju=False
for i in range(n):
  if k+i==0:
    ju=True
    break
ans=0
if ju:
  if k<0:
    for i in range(n-1):
      ans+=k+i
  else:
    for i in range(1,n):
      ans+=k+i
else:
  for i in range(n):
    ans+=k+i
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
ans=10000
for i in range(n):
  ans=min(ans,abs(k+i))
print(n*k+(n-2)*(n-1)//2-ans)

Submission status: Wrong Answer

Solution code:
N, L = [int(n) for n in input().split()]
ans = [L+i-1 for i in range(1,N+1)]
if 0 in ans:
    print(sum(ans))
elif N <= abs(L):
    print(sum(ans)-max(ans))
else:
    print(sum(ans)-min([abs(n) for n in ans]))

Submission status: Wrong Answer

Solution code:
import math
inp = input().split()

n = int(inp[0])
l = int(inp[1])

min_abs = abs(l)
min_num = 1
for i in range(n):
    if abs(l+i) < min_abs:
        min_abs = abs(l+i)
        min_num = i

print(math.ceil(0.5*n*n + n*l - 0.5*n - l - min_num ))

Submission status: Wrong Answer

Solution code:
import math
inp = input().split()

n = int(inp[0])
l = int(inp[1])

min_abs = abs(l)
min_num = 1
for i in range(n):
    if abs(l+i) < min_abs:
        min_abs = abs(l+i)
        min_num = i

print(min_num)
print(math.ceil(0.5*n*n + n*l - 0.5*n - l - min_num ))

Submission status: Wrong Answer

Solution code:
quantity, basis = map(int, input().split())

taste = []

for i in range(quantity):
  taste.append(basis + (i + 1) - 1)

eatTaste = abs(taste[0])
eatApple = 0

for i in range(quantity):
  if (eatTaste > abs(taste[i])):
    eatApple = i

tastePai = 0
for i in range(quantity):
  if (i != eatApple):
    tastePai += taste[i]

print(tastePai)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,L = (int(x) for x in input().split())
if L<=0 and L+N-1>=0:
    for val in range(L,L+N-1):
        sum = N*(2*L+N-1)//2
elif L<0 and L+N-1<0:
    for val in range(L,L+N-2):
        sum = (N-1)*(2*L+N-2)//2
else:
    for val in list(range(L+1,L+N-1)):
        sum = (N-1)*(2*L+N)//2
print(sum)

Submission status: Wrong Answer

Solution code:
N,L = (int(x) for x in input().split())
if L<0 and L+N-1>0:
    for val in range(L,L+N-1):
        sum = N*(2*L+N-1)//2
elif L<0 and L+N-1<0:
    for val in range(L,L+N-2):
        sum = (N-1)*(2*L+N-2)//2
else:
    for val in list(range(L+1,L+N-1)):
        sum = (N-1)*(2*L+N)//2      
print(sum)

Submission status: Wrong Answer

Solution code:
def output(in_):
    import numpy as np
    N, L = [int(el) for el in in_.split(' ')]
    tastes = np.arange(L,N+L)
    return sum(tastes) - min(abs(tastes))
  
in_ = input()
print(output(in_))

Submission status: Wrong Answer

Solution code:
def output(in_):
    import numpy as np
    N, L = [int(el) for el in in_.split(' ')]
    tastes = np.arange(L,N+L)
    return sum(tastes) - min(tastes)


in_ = input()
print(output(in_))

Submission status: Wrong Answer

Solution code:
N,L=map(int,input().split())
taste=[0] #0は数合わせ
sum1=0
for i in range(1,N+1): #1～N
    a=L+i-1
    sum1+=a
    taste.append(a)

#print(sum1)
#print(taste)

ans=0
best=100000
for i in range(1,N+1):
    sum2=sum1-taste[i]
    dif=abs(sum1-sum2)
    if dif<best:
        best=dif
        ans=sum2
print(sum2)

Submission status: Wrong Answer

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

taste = [int(L + i) for i in range(N)]
taste.sort()
print(sum(taste) - taste[0])

Submission status: Wrong Answer

Solution code:
n,l=[int(x) for x in input().split(' ')]
arr=sorted([x+l-1 for x in range(1,n+1)])
t1=sum(arr)
# arr2=[abs(x) for x in arr]
print(min([t1-x for x in arr]))

Submission status: Wrong Answer

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

taste = []
taste_abs = []
for i in range(N):
    taste.append(L+i)
    taste_abs.append(abs(L+i))

print(sum(taste) - min(taste_abs))

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split(' '))
azi = [L+(i+1)+1 for i in range(N)]
print("{}".format(sum(azi)-min(azi)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,L = map(int,input().split())
ls = []
for i in range(L,L+N):
    ls.append(i)
    
x = ls[0]
abs_x = abs(x)
if abs_x in ls[1:]:
    print(sum(ls))
else:
    emp = []
    for i in ls:
        emp.append(abs(i))
    mi = min(emp)
    ind = emp.index(mi)
    print(ind)
    ls.pop(ind)
    print(sum(ls))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum = int(n * (2 * l + n - 1) / 2)

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 23 14:10:18 2019

@author: Enya
"""

X = input()
N = int(X.split()[0])
L = int(X.split()[1])

A = 0
B = N*(L - 1)

for i in range(N):
    A += i + 1

if B > 0:
    print(A + B - L)

elif B == 0:
    print(A + B)

else:
    if abs(B) > abs(A):
        print(A + B - L - N + 1)
    
    else:
        print(A + B)

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline
#-------------------------------------

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

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

if n+l < 0 :
        ans -=n+l-1
if n>0 and l>0 :
        ans -=l

print(ans)

Submission status: Wrong Answer

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

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

mn=min(map(abs,ap))

if mn not in ap:
	mn=-mn

res=(l-1)*n+(1+n)*n/2-mn
print(res)

Submission status: Wrong Answer

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

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

mn=min(map(abs,ap))

chk=0
if mn not in ap:
	mn=-mn

res=(l-1)*n+(1+n)*n/2-mn
print(res)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
s=sum([i+b for i in range(a)])
if s>0:
    print(max(abs(s-j) for j in [i+b for i in range(a)]))
else:
    print(min([s-j for j in [i+b for i in range(a)]]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = input().split()
N = int(a[0])
L = int(a[1])
a = [0]*N
for i in range(N):
  a[i] = abs(L+i)
for i in range(N):
  if a[i] == min(a):
    c = (L-1)*N+N*((N+1)/2)-(L+i)
    print(c)
    break

Submission status: Wrong Answer

Solution code:
a = input().split()
N = int(a[0])
L = int(a[1])
a = [0]*N
for i in range(N):
  a[i] = abs(L+i)
for i in range(N):
  if a[i] == min(a):
    print((L-1)*N+N*((N+1)/2)-(L+i))
    break

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
pi = [L+i-1 for i in range(1, N+1)]
minval = 100 + 200 -1
minindex = 0
for o in range(N):
  if minval>abs(pi[o]):
    minval = abs(pi[o])
    minindex = o
print(sum(pi) - pi[o])

Submission status: Wrong Answer

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
  ans = min(ans, abs(num))

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import re
import time

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

total=(L-1)*N+((1+N)/2)*N
mn=1e9
ans=1e9
for a in range(N):
    l=L+(a+1)-1
    print(l)
    if abs(l)<mn:
        mn=min([mn,abs(l)])
        ans=l
print(int(total-ans))

Submission status: Wrong Answer

Solution code:
N,L = map(int,input().split())
mina = 10**6
minb = 0
ans = 0
for i in range(1,N+1):
    if abs(L+i-1) < mina:
        mina = abs(L+i-1)
        minb = i
    if i != minb:
        ans += (L+i-1)

print(ans)

Submission status: Wrong Answer

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

#N個のリンゴ
#リンゴiの味＝L+i-1

#入力（数値）
spline = input().split()
N = int(spline[0])
L = int(spline[1])

#リンゴ1の味
taste = []
for i in range(0+1,N+1): #リンゴNは１から数える
    taste.append(L+i-1)  #味の設定
#print(taste)

#1つも食べなかった場合の味
taste_max = sum(taste)
#print("max"+str(taste_max))

#最適数値の定義
opt_coef = int()

#taste合計を繰り返し計算
for k in range(0,len(taste)):
    #1つ食べた場合のtaste合計
    taste_any = sum(taste) - taste[k]
    #print("any"+str(taste_any))

    #もし過去の最適数値よりも、今回の数値が小さければ
    if abs(taste_max - taste_any) < opt_coef:
        #最適数値に代入
        opt_coef = taste_max - taste_any

#最適数値を返す
print(opt_coef)

Submission status: Wrong Answer

Solution code:
n , k = [int(x) for x in input().split()]
s = n * k + (n*(n-1))//2
g = s - k
for x in range(1,n):
    g = min(g, s - (k + x))
    
print(g)

Submission status: Wrong Answer

Solution code:
n , k = [int(x) for x in input().split()]
g = 100000000000
s = n * k + (n*(n-1))//2
for x in range(n):
    g = min(g, s - (k + x))
    
print(g)

Submission status: Wrong Answer

Solution code:
INF=10e9
n,l=map(int,input().split())
taste=[]
for i in range(n):
  taste.append(l+i-1)
eat=INF
for i in range(n):
  if eat>abs(taste[i]):
    eat=abs(taste[i])
print(sum(taste)-eat)

Submission status: Wrong Answer

Solution code:
INF=10e9
n,l=map(int,input().split())
taste=[]
for i in range(n):
  taste.append(i+i-1)
eat=INF
for i in range(n):
  if eat>abs(taste[i]):
    eat=abs(taste[i])
print(sum(taste)-eat)

Submission status: Wrong Answer

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
    mn=min([mn,abs(l)])
#print("{} - {} = {}".format(total,mn,int(total-mn)))
print(int(total-mn))

Submission status: Wrong Answer

Solution code:
N, L = map(int,input().split())
i = 0
apple_taste = []
pi_taste = 0
while N > i:
    apple_taste.append(L + i)
    if(L>0):
        if i>0:
            pi_taste += apple_taste[i]
    elif(L+(N-1)>=0):
            pi_taste += apple_taste[i]
    elif(L<0):
        if i>0:
            pi_taste += apple_taste[i-1]
    i += 1 
print(pi_taste)
print(apple_taste)