qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n,l=map(int,input().split())
ans1=0
for i in range(n):
    ans1=ans1+l+i
if l==0:
    ans2=ans1
elif l<0 and abs(l)<=n:
    ans2=ans1
elif l<0 and abs(l)>n:
    ans2=ans1-l-n
else:
    ans2=ans1-l
print(ans2)

Fixed code:
n,l=map(int,input().split())
ans1=0
for i in range(n):
    ans1=ans1+l+i
if l==0:
    ans2=ans1
elif l<0 and abs(l)<n:
    ans2=ans1
elif l<0 and abs(l)>=n:
    ans2=ans1-l-n+1
else:
    ans2=ans1-l
print(ans2)
Buggy code:
N,L=map(int ,input().split())
if L >= 0:
    print(int((2*L+N)*(N-1)/2) )
elif L < 0 and L+N-1>=0:
    print(int((2*L+N)*(N-1)/2) )
else:
    print(int((2*L+N-2)*(N-1)/2) )

Fixed code:
N,L=map(int ,input().split())
if L >= 0:
    print(int((2*L+N)*(N-1)/2) )
elif L < 0 and L+N-1>=0:
    print(int((2*L+N-1)*(N)/2) )
else:
    print(int((2*L+N-2)*(N-1)/2) )
Buggy 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))

Fixed code:
n,l=map(int,input().split())
 
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))
Buggy 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)




Fixed 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) < a:
        a = abs(L+i-1)
        b = i

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

print(ans)
Buggy code:
n,l=map(int,input().split( ))

s=2*l+n-1

if l>0:
    s-=l
elif l==0:
    pass
elif l+n<=0:
    s-=l+n-1

print(s)

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

s=n*(2*l+n-1)//2

if l>0:
    s-=l
elif l==0:
    pass
elif l+n<=0:
    s-=l+n-1

print(s)
Buggy code:
N,L = map(int,input().split())
inf = float('inf')
eat = inf
ans = 0
for i in range(N):
    eat = min(eat, abs(L+i))
if L > 0:
    s = eat - L + 1
else:
    s = abs(eat + L -1)
print(s)
for i in range(1,N+1):
    if s == i:
        continue
    ans += L + i -1
print(ans)


Fixed code:
N,L = map(int,input().split())
inf = float('inf')
eat = inf
ans = 0
for i in range(N):
    eat = min(eat, abs(L+i))
if L > 0:
    s = eat - L + 1
else:
    s = abs(eat + L -1)

for i in range(1,N+1):
    if s == i:
        continue
    ans += L + i -1
print(ans)
Buggy code:
n,l=input().split()
n=int(n)
s=f=0
l=int(l)
for i in range(n):
    a=l+i
    if(a==0):
        f=1
    else:
        s+=a
if(f==0):
    s-=(l)
print(s)

Fixed code:
n,l=input().split()
n=int(n)
s=f=0
l=int(l)

for i in range(n):
    a=l+i
    if(a==0):
        f=1
    else:
        s+=a
if(f==0):
    if(l<0):
        s-=(l+n-1)
    else:
        s-=l
print(s)
Buggy code:

N,L=map(int,input().split())
#L+i-1,i>=1
nin=10**6
for i in range(N):
    if abs(L+i)<nin:
        nin=abs(L+i)
        nn=L+i

ans=N*(L-1)+N*(N+1)*0.5-(nn)

print(ans)

Fixed code:
N,L=map(int,input().split())
#L+i-1,i>=1
nin=10**6
for i in range(N):
    if abs(L+i)<nin:
        nin=abs(L+i)
        nn=L+i

ans=N*(L-1)+N*(N+1)*0.5-(nn)

print(int(ans))
Buggy 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 )

Fixed code:
N, L = map(int, input().split())
#L, L+N-1 => sum: (2L+N-1)*N // 2
A = (2 * L + 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 )
Buggy code:
N,L = map(int, input().split())
allsum = N//2*(2*L+(N-1))
eat = 0
if L >= 0:
        eat = L
elif L + N >= 0:
        eat = 0
else:
        eat = L + N - 1
print(allsum - eat)

Fixed code:
N,L = map(int, input().split())
allsum = int(N/2*(2*L+(N-1)))
eat = 0
if L >= 0:
        eat = L
elif L + N >= 1:
        eat = 0
else:
        eat = L + N - 1
print(allsum - eat)
Buggy 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)

Fixed code:
N,L = map(int,input().split())
aji1 = [L+i-1 for i in range(1,N+1)]
aji = [abs(L+i-1) for i in range(1,N+1)]
#print(aji)
minaji = max(aji1)
no = 0
for i in range(N):
    if aji[i] < minaji:
        no = i + 1
        minaji = aji[i]
aji1[no-1] = 0
print(sum(aji1))
Buggy 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)

Fixed 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))
Buggy code:
n,l=map(int,input().split())
no=1000
num=0
for i in range(n):
    if abs(l+i)<no:
        no=abs(l+i)
        num=i
ans=0
for i in range(n):
    ans+=abs(l+i)
ans=ans-abs(l+num)
print(ans)

Fixed code:
n,l=map(int,input().split())
no=1000
num=0
for i in range(n):
    if abs(l+i)<no:
        no=abs(l+i)
        num=i
ans=0
for i in range(n):
    ans+=l+i
ans=ans-l-num
print(ans)
Buggy code:
N, L = map(int,input().split())
import statistics
S = []
for i in range(L,N+L):
    S.append(i)
ans = []
p = []
for j in S:
    ans.append(abs(sum(S) - sum(S) - j))
    p.append(sum(S)-j)
print(ans)
print(p[ans.index(min(ans))])

Fixed code:
N, L = map(int,input().split())
import statistics
S = []
for i in range(L,N+L):
    S.append(i)
ans = []
p = []
for j in S:
    ans.append(abs(sum(S) - sum(S) - j))
    p.append(sum(S)-j)

print(p[ans.index(min(ans))])
Buggy code:
n,l=map(int,input().split())
A=[]
for i in range(n):
    A.append(l+i)
B=A.copy()
for j in range(len(B)):
    B[j]=abs(B[j])
sum(A)-A[B.index(min(B))]

Fixed code:
n,l=map(int,input().split())
A=[]
for i in range(n):
    A.append(l+i)
B=A.copy()
for j in range(len(B)):
    B[j]=abs(B[j])
print(sum(A)-A[B.index(min(B))])
Buggy code:
n,l=map(int,input().split())
a=0
b=1000
for i in range(l,l+n):
  a+=i
  if b>abs(i):
    b=i
print(a-b)

Fixed code:
n,l=map(int,input().split())
a=0
b=1000
for i in range(l,l+n):
  a+=i
  if abs(b)>abs(i):
    b=i
print(a-b)
Buggy code:
n,l = map(int,input().split())
i = 1-l
if 1<= i <= n:
  sum = n*(l-1)+ int(n*(n+1)/2)
else:
  sum = n*(l-1)+ int(n*(n+1)/2) - l
print(sum)

Fixed code:
n,l = map(int,input().split())
i = 1-l
if 1<= i <= n:
  sum = n*(l-1)+ int(n*(n+1)/2)
else:
  if l>=0:
    sum = n*(l-1)+ int(n*(n+1)/2) -l
  else:
    sum = n*(l-1)+ int(n*(n+1)/2) - (l+n-1)
print(sum)
Buggy 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()

Fixed 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[1] + i
    print(result)

if __name__ == "__main__":
    main08()
Buggy code:
n,l=map(int,input().split())
s=(l-1)*n+n*(n+1)/2
if n>=1:
  print(s-1)
elif n>=1-l:
  print(s-1+l)
else:
  print(s-n)

Fixed code:
n,l=map(int,input().split())
s=(l-1)*(n-1)+n*(n+1)//2
if l>=1:
  print(s-1)
elif n>=1-l:
  print(s-1+l)
else:
  print(s-n)
Buggy 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))

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

min_ = L
max_ = L + N -1

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

print(int((min_+max_)*(max_-min_+1)/2 - eat_apple(N, L)))
Buggy 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)

Fixed 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 >= 1:
    print(s)
else:
    a = l
    b = l + n - 1
    if abs(a) < abs(b):
        print(s - a)
    else:
        print(s - b)
Buggy code:
N, L = map(int, input().split())

aji = list(map(lambda x: L + x - 1, range(1, N + 1)))

print(aji)

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

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

aji = list(map(lambda x: L + x - 1, range(1, N + 1)))

if (aji[0] <= 0 and aji[N - 1] >= 0) :
    print(sum(aji))
elif (aji[0] < 0 and aji[N - 1] < 0):
    print(sum(aji) - aji[N -1])
else:
    print(sum(aji) - aji[0])
Buggy code:
n,l = map(int,input().split())
l = [i for i in range(l,l+n)]
minus = min(list(map(abs,l)))
minus = minus if minus<0 else -1*minus
print(sum(l)-minus)

Fixed code:
n,l = map(int,input().split())
li = [i for i in range(l,l+n)]
minus = min(list(map(abs,li)))
minus = minus if l+n>0 else -1*minus
print(sum(li)-minus)
Buggy code:
N, L = map(int, input().split())
tastes = [ L+x for x in range(N) ] 

if 0 in tastes:
    print(sum(tastes))

if L<0:
    absmin = max(tastes)
    print(sum(tastes)-absmin)
elif L>0:
    absmin = min(tastes)
    print(sum(tastes)-absmin)

Fixed code:
import sys
N, L = map(int, input().split())
tastes = [ L+x for x in range(N) ] 

if 0 in tastes:
    print(sum(tastes))
    sys.exit(0)
    

if L<0:
    absmin = max(tastes)
    print(sum(tastes)-absmin)
elif L>0:
    absmin = min(tastes)
    print(sum(tastes)-absmin)
Buggy code:
n, l = map(int, input().split())
total = [l+(i+1)-1 for i in range(n)]
m = 100000000
for i in range(n):
    if abs(total[i]) < m:
        idx = i
total.pop(idx)
print(sum(total))


Fixed code:
n, l = map(int, input().split())
total = [l+(i+1)-1 for i in range(n)]
m = 100000000
for i in range(n):
    if abs(total[i]) < m:
        idx = i
        m = abs(total[i])
total.pop(idx)
print(sum(total))
Buggy code:
r=input().split()
N=int(r[0])
L=int(r[1])
ans=0
ans_li=[]
for i in range(N):
    ans+=L-(i+1)-1
    ans_li.append(L-(i+1)-1)
if 0 in ans_li:
    print(ans)
elif max(ans_li)>0:
    print(ans-min(ans_li))
else:
    print(ans-max(ans_li))

Fixed code:
r=input().split()
N=int(r[0])
L=int(r[1])
ans=0
ans_li=[]
for i in range(N):
    ans+=L+(i+1)-1
    ans_li.append(L+(i+1)-1)
if 0 in ans_li:
    print(ans)
elif max(ans_li)>0:
    print(ans-min(ans_li))
else:
    print(ans-max(ans_li))
Buggy 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))

Fixed 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)-c[d.index(min(d))])
Buggy 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))

Fixed code:
N,L=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))
Buggy code:
n, L = map(int, input().split())
l = [0] * n
for i in range(n):
  l[i] = L + i
mins = 10 ** 10
for i in l:
  mins = min(mins, abs(i))
print(sum(l) - mins)

Fixed code:
n, L = map(int, input().split())
l = [0] * n
for i in range(n):
  l[i] = L + i
mins = 10 ** 10
for i in l:
  if abs(mins) > abs(i):
    mins = i
print(sum(l) - mins)
Buggy code:
N,L=map(int,input().split())
ans=0
min=10000
for i in range(1,N+1):
    tmp=L+i-1
    ans+=tmp
    if abs(tmp) < min:
        min = abs(tmp)
ans-=min
print(ans)

Fixed code:
N,L=map(int,input().split())
ans=0
f=0
min=10000
for i in range(1,N+1):
    tmp=L+i-1
    ans+=tmp
    if abs(tmp) < min:
        min = abs(tmp)
        if tmp < 0:
            f=1
if f == 0:
    ans-=min
else:
    ans+=min
print(ans)
Buggy 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)

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

total = (l - 1) * n + n * (n + 1) // 2
min_diff = 1e20
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)
Buggy 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)
  

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

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

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

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

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

else:
  print(int((2*L+N-1)*N/2))
Buggy code:
N, L =  (int(j) for j in input().split())  

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

if L > 0:
  print(sum(taste)-taste[0])
else:
  print(sum(taste))

Fixed code:
N, L =  (int(j) for j in input().split())  

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

if L > 0:
  print(sum(taste)-taste[0])
elif L + N - 1 <= 0:
  print(sum(taste)-taste[N-1])
else:
  print(sum(taste))
Buggy code:
N,L=map(int,input().split())
taste_abs=[]
taste=[]
for i in range(N):
    taste_abs.append(abs(L+i))
    taste.append(L+i)
    
a=taste_abs.index(min(taste_abs))
b=sum(taste)-taste_abs[a]
print(b)


Fixed code:
N,L=map(int,input().split())
taste_abs=[]
taste=[]
for i in range(N):
    taste_abs.append(abs(L+i))
    taste.append(L+i)
    
a=taste_abs.index(min(taste_abs))
b=sum(taste)-taste[a]
print(b)
Buggy code:
N,L=map(int,input().split())
val=val=L*N+0.5*N*(N+1)-N
if L>0:
    val-=(L-1)
elif L+N-1<0:
    val-=(L+N-1)

print(int(val))

Fixed code:
N,L=map(int,input().split())
val=L*N+0.5*N*(N+1)-N
if L>0:
    val-=L
elif L+N-1<0:
    val-=(L+N-1)
print(int(val))
Buggy code:
N, L=map(int, input().split())
s=0
S=[L+i-1 for i in range(1, N+1)]
T = [abs(S[i]) for i in range(0, N)]
for i in range(0, N):
    if T[i] < T[i+1]:
        del S[i]
        break
    else:
        del S[N-1]
        break
for i in range(0,N-1):
    s+=S[i]
print(s)


Fixed code:
N, L=map(int, input().split())
s=0
S=[L+i-1 for i in range(1, N+1)]
T = [abs(S[i]) for i in range(N)]

for i in range(N-1):
    if T[i] < T[i+1]:
        del S[i]
        break
    elif i == N-2:
        del S[N-1]

for i in range(0,N-1):
    s+=S[i]
print(s)
Buggy 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))

Fixed code:
n,l=map(int,input().split())
a=list(range(l,l+n,1))
x=sum(a)
if(0 in a):
  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))
Buggy code:
n, l = map(int, input().split())
list_taste = [l+i for i in range(n)]

if 0 in list_taste:
  ans = sum(list_taste)
else:
  ans = sum(list_taste) - min(list_taste)

print(ans)


Fixed code:
n, l = map(int, input().split())
list_taste = [l+i for i in range(n)]
 
if 0 in list_taste:
  ans = sum(list_taste)
else:
  if list_taste[0] > 0:
  	ans = sum(list_taste) - min(list_taste)
  else:
    ans = sum(list_taste) - max(list_taste)

print(ans)
Buggy code:
inp = input().split(" ")
n = int(inp[0])
l = int(inp[1])

taste_list = [l+i-1 for i in range(1,n+1)]
abs_taste_list = [abs(i) for i in taste_list]
min = min(abs_taste_list)
print(sum(taste_list)-min)


Fixed code:
inp = input().split(" ")
n = int(inp[0])
l = int(inp[1])

taste_list = [l+i-1 for i in range(1,n+1)]
abs_taste_list = [abs(i) for i in taste_list]
min_index = abs_taste_list.index(min(abs_taste_list))
min = taste_list[min_index]
print(sum(taste_list)-min)
Buggy 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))

Fixed 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 = lis2.index(min(lis2))
del lis[min]

print(sum(lis))
Buggy code:
N, L = map(int, input().split())

count = 0
min = None
sum = 0
for i in reversed(range(1, N+1)):
  num = abs(L + i - 1)
  if min == None:
    min = num
    continue
  if min > num:
    min = num
    count = i

for i in range(1, N+1):
  if i == count:
    continue
  num = L + i - 1
  sum += num
print(sum)

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

count = 0
min = None
sum = 0
for i in range(N):
  i += 1
  num = abs(L + i - 1)
  if min == None:
    min = num
    count = i
    continue
  if min > num:
    min = num
    count = i
for i in range(N):
  i += 1
  if i != count:
    num = L + i - 1
    sum += num
print(sum)
Buggy code:
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


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


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
5 2
'''


def MAIN():
  # T_IN()
  A()


def A():
  n, l = IN_L_I()
  li = list([ i + l for i in range(0,  n)])
  # print(li)
  if li.count(0) == 0:
    if abs(li[0]) > abs(li[-1]):
      li.pop(-1)
    else:
      li = li[0:-1]
  # print(li)
  print(sum(li))

  return None
 

def B():
  return None


def C():
  return None


MAIN()


Fixed code:
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


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


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
5 2
'''


def MAIN():
  # T_IN()
  A()


def A():
  n, l = IN_L_I()
  li = list([ i + l for i in range(0,  n)])
  if li.count(0) == 0:
    j = li.pop(0)
    k = li.pop(-1)
    if abs(j) < abs(k):
      li.append(k)
    else:
      li.append(j)

  print(sum(li))

  return None
 

def B():
  return None


def C():
  return None


MAIN()
Buggy 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])

Fixed code:
import numpy as np

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

A = np.arange(N)+L

if A[0] <= 0 and A[N-1] >= 0:
    print(np.sum(A))
elif A[0] < 0 and A[N-1] < 0:
    print(np.sum(A)-A[N-1])
else:
    print(np.sum(A)-A[0])
Buggy code:
n,l = map(int,input().split())

al = []
for i in range(n):
    aji = l + i
    aji_ = abs(aji)
    al += [aji_]

x = abs(l)
an = 0
for i in range(n):
    if al[i] < x:
        x = al[i]
        an = i

ans = (l + l+n-1)*n/2 - (l+an)
print(ans)


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

al = []
for i in range(n):
    aji = l + i
    aji_ = abs(aji)
    al += [aji_]

x = abs(l)
an = 0
for i in range(n):
    if al[i] < x:
        x = al[i]
        an = i

ans = (l + l+n-1)*n/2 - (l+an)
print(int(ans))
Buggy code:
import numpy as np
N,L  = map(int,input().split())
L_list=np.array(range(1,N+1))+L-1
print(sum(L_list))
if (0 in L_list):
    print(sum(L_list))
    exit()
if(N<=abs(L) and L<0):
    print(sum(L_list)-L_list[N-1])
    
    exit()
else:
    print(sum(L_list)-L_list[0])
    exit()

Fixed code:
import numpy as np
N,L  = map(int,input().split())
L_list=np.array(range(1,N+1))+L-1
if (0 in L_list):
    print(sum(L_list))
    exit()
if(N<=abs(L) and L<0):
    print(sum(L_list)-L_list[N-1])
    
    exit()
else:
    print(sum(L_list)-L_list[0])
    exit()
Buggy 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))


Fixed 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))
Buggy code:
lst = input()
lst = lst.split()


for i in range(len(lst)):
    lst[i]= int(lst[i])
N = lst[0]
L = lst[1]
q = L
l = 0
lste = [abs(L)]
tlst = []
for i in range(2,N+1):
    t = L+i-1
    q += t
    tlst.append(t)
    t = abs(t)
    lste.append(t)


slst = sorted(lste)
l = slst[0]
if tlst.count(-l) > 0:
    print(q+l)
else:
    print(q-1)

Fixed code:
lst = input()
lst = lst.split()


for i in range(len(lst)):
    lst[i]= int(lst[i])
N = lst[0]
L = lst[1]
q = L
l = 0
lste = [abs(L)]
tlst = []
for i in range(2,N+1):
    t = L+i-1
    q += t
    tlst.append(t)
    t = abs(t)
    lste.append(t)


slst = sorted(lste)
l = slst[0]
if tlst.count(-l) > 0:
    print(q+l)
else:
    print(q-l)
Buggy 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)

Fixed code:
n,l=map(int,input().split())
ls=[]
for i in range(1,n+1):
  ls.append(abs(l-1+i))
mi=ls.index(min(ls))
print(n*(l-1)+sum(range(1,n+1))-l-mi)
Buggy 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
m=list.index(min(list))
print(sum-l-m)

Fixed 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-1)+s
m=list.index(min(list))
print(sum-l-m)
Buggy code:
def main(str):
    input = str.split()
    n = int(input[0])
    l = int(input[1])
    apples = [l + i for i in range(n)]
    abs_apples = list(map(lambda x: abs(x), apples))
    return sum(apples) - apples[abs_apples.index(min(abs_apples))]


if __name__ == "__main__":
    str = input()
    main(str)

Fixed code:
def main(str):
    input = str.split()
    n = int(input[0])
    l = int(input[1])
    apples = [l + i for i in range(n)]
    abs_apples = list(map(lambda x: abs(x), apples))
    return sum(apples) - apples[abs_apples.index(min(abs_apples))]


if __name__ == "__main__":
    str = input()
    print(main(str))
Buggy code:
a,b = map(int,input().split())
c = a*b + a*(a-1)/2
if b < -a+1:
    print(int(c+1))
elif b >0:
    print(int(c-b))
else:
    print(int(c))

Fixed code:
a,b = map(int,input().split())
c = a*b + a*(a-1)/2
if b < -a+1:
    print(int(c-(b+a-1)))
elif b >0:
    print(int(c-b))
else:
    print(int(c))