qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N, L = map(int, input().split())
if L > 0:
    a = range(L, L + N)
    print(sum(a) - L)
else:
    if L + N - 1 >= 0:
        a = range(L, L + N)
        print(sum(a))
    else:
        print(range(L, L + N))
        a = range(L, L + N)
        print(len(a))
        print(sum(a) - (L + N - 1))


Fixed code:
N, L = map(int, input().split())
if L > 0:
    a = range(L, L + N)
    print(sum(a) - L)
else:
    if L + N - 1 >= 0:
        a = range(L, L + N)
        print(sum(a))
    else:
        a = range(L, L + N)
        print(sum(a) - (L + N - 1))
Buggy code:
N,L=map(int,input().split())

tot=N*L+(N-1)*N/2
ans=[]


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

print(tot-min(ans))

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

tot=N*L+(N-1)*N/2
ans=[]


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

a=ans.index(min(ans))

print(int(tot-(a+L)))
Buggy code:
n.l = map(int,input().split())
al = [l+i for i in range(n)]
a = min(al,key=abs)
al.remove(a)
print(sum(al))

Fixed code:
n,l = map(int,input().split())
al = [l+i for i in range(n)]
a = min(al,key =abs)
al.remove(a)
print(sum(al))
Buggy code:
n, l = map(int, input().split())
taste_abs = [abs(l + i) for i in range(n)]
index = taste_abs.index(min(taste_abs))
taste_abs.pop(index)
print(sum(taste_abs))

Fixed code:
n, l = map(int, input().split())
taste, taste_abs = [l + i for i in range(n)], [abs(l + i) for i in range(n)]
index = taste_abs.index(min(taste_abs))
taste.pop(index)
print(sum(taste))
Buggy code:
i = list(map(int, input().split()))
n = i[0]
l = i[1]
if l >= 0:
    print((n-1)*(2*l+n)/2)
elif l+n-1 <= 0:
    print((n-1)*(2*l+n-2)/2)
else:
    print(n*(2*l+n-1)/2)

Fixed code:
i = list(map(int, input().split()))
n = i[0]
l = i[1]
if l >= 0:
    print(round((n-1)*(2*l+n)/2))
elif l+n-1 <= 0:
    print(round((n-1)*(2*l+n-2)/2))
else:
    print(round(n*(2*l+n-1)/2))
Buggy code:
n,l = list(map(int,input().split()))

r = [l+i for i in range(n)]
min_r = 1000000000
for i in r:
    if min_r > abs(i):
        min_r = abs(i)
        ans = i
print(sum(r)-i)


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

r = [l+i for i in range(n)]
min_r = 1000000000
for i in r:
    if min_r > abs(i):
        min_r = abs(i)
        ans = i
print(sum(r)-ans)
Buggy code:
n,l = list(map(int,input().split()))
n_l = []
for i in range(n):
    n_l.append(i+l)

print(n_l)
min_i = n_l[0]
for i in n_l:
    print(i)
    if abs(i) < abs(min_i):
        min_i = i

print(sum(n_l) - min_i)


Fixed code:
n,l = list(map(int,input().split()))
n_l = []
for i in range(n):
    n_l.append(i+l)
    
min_i = n_l[0]
for i in n_l:
    if abs(i) < abs(min_i):
        min_i = i

print(sum(n_l) - min_i)
Buggy code:
a,b=map(int,input().split())
sum1=0
min1=1000

for i in range(a):
    if min1>abs(b):
        min1=abs(b)
    sum1+=b
    b+=1
print(sum1-min1)


Fixed code:
a,b=map(int,input().split())
sum1=0
min1=1000

for i in range(a):
    if abs(min1)>abs(b):
        min1=b
    sum1+=b
    b+=1

print(sum1-min1)
Buggy code:

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

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)

Fixed code:

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

t = list(map(lambda i: L + i, range(N)))

targ = sum(t)
m = 10000000000000
res = 0
for c in t:
    now = targ - c
    if m > abs(targ - now):
        m = abs(targ - now)
        res = now

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

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

else:
  print(int((L-1)*N+N*(N+1)/2-L))
Buggy code:
n,l = map(int,input().split())

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

if l>-1 :
    mind = D[0]
elif l+n<0:
    mind = D[n-1]
else:
    mind = 0


ans = sum(D)-mind
print(ans

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

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

if l+1>0 :
    mind = min(D)
elif l+n<=0:
    mind = max(D)
else:
    mind = 0


ans = sum(D)-mind
print(ans)
Buggy 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))

Fixed 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
    if abs(l)<mn:
        mn=min([mn,abs(l)])
        ans=l
print(int(total-ans))
Buggy code:
n,l=map(int,input().split())
s=n*l+n*(n+1)/2-n
d2=n**2
x=0
for i in range(n):
    s1=s-i-l
    d=abs(s-s1)
    if d<d2:
        d2=d
        x=i
print(s-l-x)

Fixed code:
n,l=map(int,input().split())
s=n*l+n*(n+1)/2-n
d2=100000000000000000
x=0
for i in range(n):
    s1=s-i-l
    d=abs(s-s1)
    if d<d2:
        d2=d
        x=i
print(int(s-l-x))
Buggy 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))

Fixed 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(np.absolute(ll) == np.min(np.absolute(ll)))
ll = list(ll)
del ll[mini[0][0]]

print(np.sum(ll))
Buggy code:
n,l=map(int,input().split())
ans=888
SUM=0
s=0
for i in range(l,l+n):
        SUM+=i
        s=i
        if i<0:
                s=1
                i*=-1
        else:
                s=-1
        if ans>i:
                ans=i
        print(i,ans)
y=range(l,l+n)
ANS=SUM+s*ans
print(ANS)

Fixed code:
n,l=map(int,input().split())
ans=888
SUM=0
s=0
for i in range(l,l+n):
        SUM+=i
        s=i
        if i<0:
                s=1
                i*=-1
        else:
                s=-1
        if ans>i:
                ans=i
       
y=range(l,l+n)
ANS=SUM+s*ans
print(ANS)
Buggy code:
N, L = [s for s in input().split()]


apples_taste = []
abs_apples_taste = []

for i in range(int(N)):
  apples_taste.append(i+int(L))
  abs_apples_taste.append(abs(i+int(L)))

abs_apples_taste.sort()
print(sum(apples_taste) - abs_apples_taste[0])

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


apples_taste = []
abs_apples_taste = []

for i in range(int(N)):
  apples_taste.append(i+int(L))
  abs_apples_taste.append(abs(i+int(L)))

abs_apples_taste.sort()
if abs_apples_taste[0] in apples_taste:
  print(sum(apples_taste) - abs_apples_taste[0])
else:
  print(sum(apples_taste) + abs_apples_taste[0])
Buggy code:
n, l = map(int, input().split())
taste = [l+i-1 for i in range(1, n+1)]

apple1 = float('inf')
apple2 = -float('inf')
flag = 0
for i in taste:
    if i == 0:
        apple = i
        break
    elif (apple2 < i < 0):
        apple2 = i
        flag = 1
    elif (0 < i < apple1):
        apple1 = i
        flag = 2
if flag == 1:        
    pie = abs(sum(taste) - apple2)
elif flag == 2:
    pie = abs(sum(taste) - apple1)
else:
    pie = abs(sum(taste) - apple)
    
print(pie)

Fixed code:
n, l = map(int, input().split())
taste = [l+i-1 for i in range(1, n+1)]

apple1 = float('inf')
apple2 = -float('inf')
flag = 0
for i in taste:
    if i == 0:
        apple = i
        flag = 0
        break
    elif (apple2 < i < 0):
        apple2 = i
        flag = 1
    elif (0 < i < apple1):
        apple1 = i
        flag = 2
        
if flag == 1:
    pie = (sum(taste) - apple2)
elif flag == 2:
    pie = (sum(taste) - apple1)
else:
    pie = (sum(taste) - apple)
    
print(pie)
Buggy code:
n,l = map(int, input().split())
L = [0]*n
#l+i-1
for i in range(n):
  L[i] += l+i

if(l < 0 and n + l < 0):
  print(sum(L) - L[n-1])
elif(l =< 0 and n + l >= 0):
  print(sum(L))
else:
  print(sum(L) - L[0])


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

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

if L[0] > 0:
    print(sum(L[1:]))
elif L[0] <=0 and L[-1] >= 0:
    print(sum(L))
else:
    print(sum(L[:-1]))
Buggy 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))

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


Fixed 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.pop(AJI.index(min(AJI)))
print(sum(RINGO))
Buggy code:
N,L = map(int,input().split())
NL = [int(i)+L-1 for i in range(1,N+1)]
SNL = sum(NL)
ate = 10**18
for i in range(N):
  ate = min(ate,abs(NL[i]))
print(SNL-ate)

Fixed code:
N,L = map(int,input().split())
NL = [int(i)+L-1 for i in range(1,N+1)]
SNL = sum(NL)
ate = 10**18
count = 0
for i in range(N):
  ate = min(ate,abs(NL[i]))
  if ate == abs(NL[i]):
    count = i
print(SNL-NL[count])
Buggy code:
N,L = map(int, input().split())

N_list = [ i for i in range(1,N+1)]

aaa_list = []

for i in range(1,N+1):
    aaa_list.append(L+i-1)

print(sum(aaa_list)-min(list_aaa,key=lambda x: abs(x)))


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

N_list = [ i for i in range(1,N+1)]

aaa_list = []

for i in range(1,N+1):
    aaa_list.append(L+i-1)

print(sum(aaa_list)-min(aaa_list,key=lambda x: abs(x)))
Buggy 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])

Fixed 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())
Buggy code:
N, L = map(int, input().split())
# N = 30
# L = -50
T_N = (N**2 + (2*L -1)*N)/2
# print(T_N)
array = []
num = 0
for i in range(1,N+1):
    T_i = L + i -1
    T_Ni = T_N - T_i
#     print(T_i)
    T_abs = abs(T_N - T_Ni)
    array.append(T_abs)
    if (min(array) == T_abs):
        num = T_Ni
# print(array)
print(num)

Fixed code:
N, L = map(int, input().split())
# N = 30
# L = -50
T_N = (N**2 + (2*L -1)*N)/2
# print(T_N)
array = []
num = 0
for i in range(1,N+1):
    T_i = L + i -1
    T_Ni = T_N - T_i
#     print(T_i)
    T_abs = abs(T_N - T_Ni)
    array.append(T_abs)
    if (min(array) == T_abs):
        num = T_Ni
# print(array)
print(int(num))
Buggy code:
N,L = map(int,input().split())

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

ans = float("inf")

for apple in apples:
  ans = min(ans,abs(apple))
  
print(sum(apples) - ans)

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

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

ans = float("inf")
res = float("inf")

for apple in apples:
  if ans > abs(apple):
    ans = min(ans,abs(apple))
    res = apple
  
print(sum(apples) - res)
Buggy code:
N,L = map(int,input())
A = list()
for i in range(N):
  A.append(L+i)
A.sort()
S = sum(A)
if min(A)*max(A)<=0:
  print(S)
else:
  if L>=0:
    print(S-min(A))
  else:
    print(S-max(A))

Fixed code:
N,L = map(int,input().split())
A = list()
for i in range(N):
  A.append(L+i)
A.sort()
S = sum(A)
if min(A)*max(A)<=0:
  print(S)
else:
  if L>=0:
    print(S-min(A))
  else:
    print(S-max(A))
Buggy code:
# -*- coding: utf-8 -*-

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

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

A_abs = [abs(x) for x in A]
abs_min = min(A_abs)
index = A_abs.index(abs_min)
eat = A[index]
print(sum(A))

ans = sum(A) - eat
print(ans)

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

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

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

A_abs = [abs(x) for x in A]
abs_min = min(A_abs)
index = A_abs.index(abs_min)
eat = A[index]
ans = sum(A) - eat
print(ans)
Buggy code:
import sys
n,l = list(map(int, input().split()))

if l >0:
    print(sum(range(l+1,l+n)))
elif l <=0:
    if l+n>=0:
        print(sum(range(l,l+n)))
    else:
        print(sum(range(l,l+n)))


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

if l >0:
    print(sum(range(l+1,l+n)))
elif l <=0:
    if l+n>0:
        print(sum(range(l,l+n)))
    else:
        print(sum(range(l,l+n-1)))
Buggy code:
import math
N,L = map(int,input().split())
r = []
total=0
max = -100100100100
for i in range(1,N+1):
  r.append(L+i-1)
all_applepay=sum(r)
for i in range(N):
  for j in range(N):
    if j != i:
      total+=r[j]
  if max < abs(all_applepay-total):
    max = total
  total=0
print(max)

Fixed code:
import math
N,L = map(int,input().split())
r = []
total=0
abs_min = 100100100100
max_applepay=0
for i in range(1,N+1):
  r.append(L+i-1)
all_applepay=sum(r)
for i in range(N):
  for j in range(N):
    if j != i:
      total+=r[j]
  if abs(all_applepay-(total)) < abs_min:
    abs_min = abs(all_applepay-(total))
    max_applepay = total
  total=0
print(max_applepay)
Buggy code:
n, l = list(map(int, input().split()))
taste = []
a = 1000
for i in range(1, n+1):
    if(abs(l + i - 1) < a):
        a = abs(l + i - 1)
    taste.append(l + i - 1)
print(sum(taste) - a)



Fixed code:
n, l = list(map(int, input().split()))
taste = []
a = 10000
for i in range(1, n+1):
    if(abs(l + i - 1) < abs(a)):
        a = l + i - 1
    taste.append(l + i - 1)
print(sum(taste) - a)
Buggy code:
N, L = map(int, input().split())
s = []
for i in N:
  s.append(i+L)
t = abs(s)
del s[t.index(min(s))]
print(sum(s))

Fixed code:
N, L = map(int, input().split())
s = []
for i in range(N):
  s.append(i+L)
t = list(map(abs, s))
del s[t.index(min(t))]
print(sum(s))
Buggy code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n, l = map(int, input().split())

    ls = [i + l for i in range(1, n+1)]
    if l >= 0:
        ls = ls[1:]
    elif n + l < 0:
        ls = ls[:-1]

    print(sum(ls))

if __name__ == '__main__':
    main()


Fixed code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n, l = map(int, input().split())

    ls = [i + l for i in range(n)]
    if l >= 0:
        ls = ls[1:]
    elif n + l - 1 < 0:
        ls = ls[:-1]

    print(sum(ls))

if __name__ == '__main__':
    main()
Buggy 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)


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

score=[]
for i in range(N):
    score.append(abs(L+i+1-1))
score.remove(min(score))

print(sum(score))

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

score=[]
for i in range(N):
    score.append(L+i+1-1)
score.remove(min(score, key=lambda x: abs(x)))
print(sum(score))
Buggy code:
n,l = int(input())
tastes = [(i + l) for i in range(n)]
t = tastes.copy()
for j in range(n):
    t[j] = abs(t[j])
del tastes[t.index(min(t))]
print(sum(tastes))

Fixed code:
n,l = map(int, input().split())
tastes = [(i + l) for i in range(n)]
t = tastes.copy()
for j in range(n):
    t[j] = abs(t[j])
del tastes[t.index(min(t))]
print(sum(tastes))
Buggy code:
n, l = map(int, input().split())
ans = 1000000000
r = []
for i in range(n):
    r.append(l+i)
total = sum(r)
for i in r:
    ans = min(ans, abs(i))
print(total - ans)

Fixed code:
n, l = map(int, input().split())
ans = 1000000000
r = []
for i in range(n):
    r.append(l+i)
total = sum(r)
for i in r:
    if(abs(i) < abs(ans)):
        ans = i
print(total - ans)
Buggy code:
N, L = map(int, input().split())
eatable_taste = L - 1
eatable_index = 0

for i in range(1, N):
    taste = L + i - 1
    if abs(taste) < abs(eatable_taste):
        eatable_index = i
        eatable_taste = taste

print(int(N*(N-1)/2 + (L-1)*N - ((eatable_index) + L - 1)))    

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

for i in range(2, N+1):
    taste = L + i - 1
    if abs(taste) < abs(eatable_taste):
        eatable_taste = taste

print(int(N*(N-1)/2 + L*N - (eatable_taste)))
Buggy code:
N,L = map(int,input().split())
a = [0]*N
for i in range(N):
  a[i] = L+i
all_apple_pie = sum(a)
apple_pie = [0]*N
def_apple_pie = [0]*N
for i in range(N):
  t = a[i]
  a[i] = 0
  apple_pie[i] = sum(a)
  def_apple_pie[i] = abs(all_apple_pie-apple_pie[i])
  a[i] = t
print(min(def_apple_pie))

Fixed code:
N,L = map(int,input().split())
a = [0]*N
for i in range(N):
  a[i] = L+i
all_apple_pie = sum(a)
apple_pie = [0]*N
def_apple_pie = [0]*N
for i in range(N):
  t = a[i]
  a[i] = 0
  apple_pie[i] = sum(a)
  def_apple_pie[i] = abs(all_apple_pie-apple_pie[i])
  a[i] = t
index = def_apple_pie.index(min(def_apple_pie))
print(apple_pie[index])
Buggy code:
N,L = list(map(int, input().split()))
l = []
l_abs = []
for i in range(N):
    l.append(L+i)
    l_abs.append(abs(L+i))


print(sum(l)-l[l.index(min(l_abs))])


Fixed code:
N,L = list(map(int, input().split()))
l = []
l_abs = []
for i in range(N):
    l.append(L+i)
    l_abs.append(abs(L+i))


print(sum(l)-l[l_abs.index(min(l_abs))])
Buggy code:
N,L = map(int,input().split())

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

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

if L >= 1:
    print((N-1)*(2*L+N)//2)
elif L < 1 and N > -L:
    print(N*(2*L+N-1)//2)
else:
    print(N*(2*L+N-1)//2-N-L+1)
Buggy code:
n,l = map(int,input().split())
s = sum([i for i in range(l,l+n)])
x = [i for i in range(l,l+n) ]

find = 10**9
for i in x:
    if abs(i)<find:
        find = i

print(s-i)

Fixed code:
n,l = map(int,input().split())
s = sum([i for i in range(l,l+n)])
x = [i for i in range(l,l+n) ]

find = 10**9
data = 0
for i in x:
    if abs(i)<find:
        find = abs(i)
        data = i

print(s-data)
Buggy code:
n, l = map(int, input().split())
ans = 10 ** 6
for i in range(1, n + 1):
    t = l + i - 1
    if ans > abs(t):
        ans, t = abs(t), t
print(n * l + n * (n - 1) // 2 - t)

Fixed code:
n, l = map(int, input().split())
ans = 10 ** 6
k = 0
for i in range(1, n + 1):
    t = l + i - 1
    if ans > abs(t):
        ans, k = abs(t), t
print(n * l + n * (n - 1) // 2 - k)
Buggy code:
N, L = [int(s) for s in input().split()]
tastes = [L + i - 1 for i in range(1, N + 1)]
print(sum(tastes) - min(map(abs, tastes)))

Fixed code:
N, L = [int(s) for s in input().split()]
tastes = [L + i - 1 for i in range(1, N + 1)]
print(sum(tastes) - min(tastes, key = abs))
Buggy code:
import numpy as np

def LI():
  return [int(s) for s in input().split()]

N,L = LI()
ringo = np.array(list(range(1,N+1))) + L - 1

taste_all = sum(ringo)

min_index = 0
min_abs = abs(ringo[0])

for i in range(1,N):
  if min_abs < abs(ringo[i]):
    min_index = i
    min_abs = abs(ringo[i])

print(taste_all - ringo[min_index])

Fixed code:
import numpy as np

def LI():
  return [int(s) for s in input().split()]

N,L = LI()
ringo = np.array(list(range(1,N+1))) + L - 1

taste_all = sum(ringo)

min_index = 0
min_abs = abs(ringo[0])

for i in range(1,N):
  if min_abs > abs(ringo[i]):
    min_index = i
    min_abs = abs(ringo[i])

print(taste_all - ringo[min_index])
Buggy code:
n,l=map(int,input().split())
if l<0 and l+n-1<0:
    print((2*l+n-2)*(n-1)/2)
elif l>0 and l+n-1>0:
    print((2*l+n)*(n-1)/2)
else:
    print((2*l+n-1)*n/2)

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

x=[l+i-1 for i in range(1,n+1)]

min_val=None
idx=0
for i in x:
  if min_val is None or abs(l+i-1) < min_val:
    min_val=abs(l+i-1)
    idx=i-1

x.pop(idx)
print(sum(x))

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

x=[l+i-1 for i in range(1,n+1)]
min_val=None
idx=0
for i in range(1,n+1):
  tmp=abs(l+i-1)
  if min_val is None or tmp < min_val:
    min_val=tmp
    idx=i-1

x.pop(idx)
print(sum(x))
Buggy code:
N,L = map(int,input().rstrip().split(' '))
apple_pie = 0
ex = abs(L * N)
apple = []
for i in range(N):
    a = L + i 
    apple.append(a)
    apple_pie += a
apple = map(abs,apple)
for i in apple:
    if ex > i:
        ex = i
apple_pie-= ex
print(apple_pie)

Fixed code:
N,L = map(int,input().rstrip().split(' '))
apple_pie = 0
ex = abs(L * N)
apple = []
for i in range(N):
    a = L + i 
    apple.append(a)
    apple_pie += a
for i in range(len(apple)):
    if abs(ex) > abs(apple[i]):
        ex = apple[i]
apple_pie-= ex
print(apple_pie)
Buggy code:
# -*- coding: utf-8 -*-
N, L = map(int,input().split())

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

SUM = sum(taste)

DIF = abs(SUM - (SUM - taste[0]))
ans = SUM - taste[0]
for i in range(1,N + 1):
    x = SUM - taste[i]
    if abs(SUM - x) < DIF:
        DIF = abs(SUM - x)
        ans = x
print(ans)


Fixed code:
# -*- coding: utf-8 -*-
N, L = map(int,input().split())

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

SUM = sum(taste)

DIF = abs(SUM - (SUM - taste[0]))
ans = SUM - taste[0]
for i in range(1,N):
    x = SUM - taste[i]
    if abs(SUM - x) < DIF:
        DIF = abs(SUM - x)
        ans = x
print(ans)
Buggy code:
n, l = map(int, input().split())
taste = [l + i for i in range(n)]
min_abs = None
for i in taste:
    if min_abs == None or min_abs > abs(i):
        min_abs = i

print(sum(taste)-min_abs)



Fixed code:
n, l = map(int, input().split())
taste = [l + i for i in range(n)]
min_abs = None
for i in taste:
    
    if min_abs == None or abs(min_abs) > abs(i):
        min_abs = i

print(sum(taste)-min_abs)
Buggy code:
a = input().split()
num = int(a[0])
L = int(a[1])
apple = dict()
orig_taste = 0
for i in range(1, num + 1) :
    apple[i] = L + i - 1
    orig_taste += L + i - 1

if(L + num - 1 > 0 and L > 0):
    print(orig_taste - L)
elif(L + num - 1 > 0 and L < 0):
    print(orig_taste)
elif(L + num - 1 < 0 and L < 0):
    print(orig_taste - L - num - 1)
else:
    print(orig_taste)



Fixed code:
a = input().split()
num = int(a[0])
L = int(a[1])
apple = dict()
orig_taste = 0
for i in range(1, num + 1) :
    apple[i] = L + i - 1
    orig_taste += L + i - 1

if(L + num - 1 > 0 and L > 0):
    print(orig_taste - L)
elif(L + num - 1 > 0 and L < 0):
    print(orig_taste)
elif(L + num - 1 < 0 and L < 0):
    print(orig_taste - L - num + 1)
else:
    print(orig_taste)
Buggy code:
# coding: utf-8
# Your code here!

n=input().rstrip().split(" ")
n[0]=int(n[0])
n[1]=int(n[1])
if n[1]>=0:
    terget=0
elif n[1]+n[0]<=0:
    terget=n[0]
else:
    terget=-(n[1])
ans=n[1]*(n[0]-1)
#print(ans)
ans=ans+int(n[0]*(n[0]-1)/2)
#print(int(n[0]*(n[0]-1)/2))
print(ans-terget)
#print(terget)

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

n=input().rstrip().split(" ")
n[0]=int(n[0])
n[1]=int(n[1])
if n[1]>=0:
    terget=0
elif n[1]+n[0]<=0:
    terget=n[0]-1
else:
    terget=-(n[1])
ans=n[1]*(n[0]-1)
#print(ans)
ans=ans+int(n[0]*(n[0]-1)/2)
#print(int(n[0]*(n[0]-1)/2))
print(ans-terget)
#print(terget)
Buggy 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))

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


Fixed 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[minindex])