Problem: 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.

Submission attempts (in order):
i = list(map(int,input().split()))
n = i[0]
l = i[1]

alist = []
i = 1

while i <= n:
  x = l + i - 1
  alist.append(x)
  i =+ 1
  
  
j = 0
abslist = []
while j < n:
  abslist[j] = abs(alist[j])
  j =+ 1

  

k = 0
m = 0
while k < n-1:
  if abslist[k] >= abslist[k+1]:
    m = k+1
  
  k =+ 1
  
  
print(sum(alist) - alist[m])



  
  
  

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

i = list(map(int,input().split()))
n = i[0]
l = i[1]

alist = []
i = 1

while i < n+1:
  x = l + i - 1
  alist.append(x)
  i =+ 1
  
  

k = 0
m = 0
while k < n-1:
  if abs(alist[k]) >= abs(alist[k+1]):
    m = k+1
  
  k =+ 1
  
  
print(sum(alist) - alist[m])



  
  
  

i = list(map(int,input().split()))
n = i[0]
l = i[1]

alist = []
i = 1

while i < n+1:
  x = l + i - 1
  alist.append(x)
  i =+ 1
  
  

k = 0
m = 0
while k < n-1:
  if abs(alist[k]) >= abs(alist[k+1]):
    m = k+1
  
  k =+ 1
  
  
print(sum(alist) - alist[m])



  
  
  

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

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



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

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

Verdicts: Time Limit Exceeded

Runtime Error

Time Limit Exceeded

Time Limit Exceeded

Runtime Error

Runtime Error

Runtime Error

Accepted