qyliang/CodeNanoFix huggingface dataset:
Buggy code:
L,N = (int(i) for i in input().split()) 
sum = (2*L+N-1)*N/2 
if L>0:
    print(int(sum-L))
elif L+N-1<0:
    print(int(sum-(L+N-1)))
else:
    ans=sum
    print(int(sum))

Fixed code:
N,L = (int(i) for i in input().split()) 
sum = (2*L+N-1)*N/2 
if L>0:
    print(int(sum-L))
elif L+N-1<0:
    print(int(sum-(L+N-1)))
else:
    ans=sum
    print(int(sum))
Buggy code:
N,L=map(int,input().split())
li=[]
absli=[]
for i in range(1,N+1):
  li.append(L+i-1)
total=sum(li)
if max(li)<0:
  print(total-max(li))
else:
  print(total-min(li))

Fixed code:
N,L=map(int,input().split())
li=[]
absli=[]
for i in range(1,N+1):
  li.append(L+i-1)
total=sum(li)
if max(li)<0:
  print(total-max(li))
else:
  li=map(abs,li)
  print(total-min(li))
Buggy code:
import numpy as np

def main():
    N, L = map(int, input().split())
    apple = np.zeros(N)
    R = L + N - 1
    eat = 0
    if R <= 0:
        eat = R
    elif L >= 0:
        eat = L
    print((R + L) * (R - L + 1)/2 - eat)



       

if __name__ == '__main__':
    main()

Fixed code:
import numpy as np

def main():
    N, L = map(int, input().split())
    apple = np.zeros(N)
    R = L + N - 1
    eat = 0
    if R <= 0:
        eat = R
    elif L >= 0:
        eat = L
    print(int((R + L) * (R - L + 1)/2 - eat))



       

if __name__ == '__main__':
    main()
Buggy code:
N,L = map(int,input().split(' '))
X = []

for i in range(1,N+1):
  X.append(L+i-1)
res = float('inf')
for i in X:
  res = min(abs(res),abs(i))
print(sum(X)-res)
  

Fixed code:
N,L = map(int,input().split(' '))
X = []

for i in range(1,N+1):
  X.append(L+i-1)
res = float('inf')
print(sum(X)-min(X,key=abs))
Buggy code:
n, l = list(map(int ,input().split()))
sumApple = sum(range(l,l+n))
aMin = 10000
for i in range(n):
    if abs(l + i) < aMin:
        aMin = abs(l + i)
print(sumApple - aMin)

Fixed code:
n, l = list(map(int ,input().split()))
sumApple = sum(range(l,l+n))
aMin = 10000
for i in range(1,n + 1):
    if abs(l + i - 1) < abs(aMin):
        aMin = (l + i - 1)
print(sumApple - aMin)
Buggy code:
n, l = map(int, input().split())

eat_taste = 99999
sum_taste = 0
for i in range(n):
  taste = l + i
  sum_taste += taste
  if taste < eat_taste:
    eat_taste = taste
print(sum_taste - eat_taste)

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

eat_taste = 99999
sum_taste = 0
for i in range(n):
  taste = l + i
  sum_taste += taste
  if abs(taste) < abs(eat_taste):
    eat_taste = taste
print(sum_taste - eat_taste)
Buggy code:
n,a=map(int,input().split())

apples=[a+i for i in ragen(n)]
eat=min(apples,key=lambda x:abs(x))
res=sum(apples)-eat

print(res)

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

apples=[a+i for i in range(n)]
eat=min(apples,key=lambda x:abs(x))
res=sum(apples)-eat

print(res)
Buggy code:
n,a=map(int,input().split())

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

import numpy as np
b=min(np.abs(l))

if b==0:
  l.remove(0)
else:
  l.remove([b,-b])
  
print(sum(l))

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

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

import numpy as np
b=min(np.abs(l))

if b==0:
  l.remove(0)
elif b in l:
  l.remove(b)
elif -b in l:
  l.remove(-b)
  
print(sum(l))
Buggy code:
a = input().split(" ")
n = int(a[0])
l = int(a[1])
m = 0
if l >= 0:
    for i in range(n - 1):
        m += l + i + 1
    print(m)
elif l + n - 1 >= 0:
    for i in range(n):
        m += l + i
    print(m)
else:
    for i in range(n - 1):
        m += l + i + 1
    print(m)

Fixed code:
a = input().split(" ")
n = int(a[0])
l = int(a[1])
m = 0
if l >= 0:
    for i in range(n - 1):
        m += l + i + 1
    print(m)
elif l + n - 1 >= 0:
    for i in range(n):
        m += l + i
    print(m)
else:
    for i in range(n - 1):
        m += l + i
    print(m)
Buggy 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]))

Fixed code:
import numpy as np
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]))
Buggy code:
n,k=list(map(int,input().split()))
l=[]
for i in range(n):
  l.append(k+i)
l.sort()
if max(l)=>0 and min(l)<=0:
  print(sum(l))
elif max(l)<0:
  print(sum(l)-l[n-1])
else:
  print(sum(l)-l[0])
  

Fixed code:
n,k=list(map(int,input().split()))
l=[]
for i in range(n):
  l.append(k+i)
l.sort()
if max(l)>=0 and min(l)<=0:
  print(sum(l))
elif max(l)<0:
  print(sum(l)-l[n-1])
else:
  print(sum(l)-l[0])
Buggy code:
n, l = map(int,input().split())
m = list(range(l, n))

if 0 in m:
  print(sum(m))
  
else:
  if m[0] < 0:
    print(sum(m)-max(m))
  else:
    print(sum(m)-min(m))

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

if 0 in m:
  print(sum(m))
  
else:
  if m[0] < 0:
    print(sum(m)-max(m))
  else:
    print(sum(m)-min(m))
Buggy code:
n,l=map(int,input().split())

if l <= 0:
  if -1 * l >= n:
    n -= 1
else:
  l += 1
  n -= 1

print(int(n *(2+l+n-1)/2))

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

if l <= 0:
  if -1 * l >= n:
    n -= 1
else:
  l += 1
  n -= 1

print(int(n*(2*l+n-1)/2))
Buggy code:
import sys
input = sys.stdin.readline
N,L = map(int,input().split())
lst = [L]
for i in range(n-1):
  lst.append(lst[-1]-1)
arr = [abs(i) for i in lst]
del lst[arr.index(min(arr))]
print(sum(lst))


Fixed code:
import sys
input = sys.stdin.readline
N,L = map(int,input().split())
lst = [L]
for i in range(N-1):
  lst.append(lst[-1]+1)
arr = [abs(i) for i in lst]
del lst[arr.index(min(arr))]
print(sum(lst))
Buggy 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))
else:
        print(sum(apple[1:len(apple)+1]))

Fixed 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-1] < 0:
        print(sum(apple)-apple[len(apple)-1])
else:
        print(sum(apple[1:len(apple)+1]))
Buggy code:
n,l = map(int,input().split())

sum = n * (l - 1) + (n * (n + 1)) / 2.0

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

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

sum = n * (l - 1) + (n * (n + 1)) / 2.0

if n + l - 1 < 0:
    print(int(sum - (n + l - 1)))
elif l > 0:
    print(int(sum - (l)))
else:
    print(int(sum))
Buggy code:
L, L+1, L+2, ..., L+N-1
N, L = list(map(lambda x: int(x), input().split(" ")))

S = int(N * (N-1) / 2) + L * N

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

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


Fixed 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+1:]) for i in range(len(A))]
print(sorted(B, key=lambda x: abs(x-sum_A))[0])
Buggy code:
N,L = map(int, input().split())

apple = [L+i for i in range(N)]
print(apple)
min = 500
for k in range(len(apple)):
    if abs(apple[k])<min:
        min = abs(apple[k])

apple.remove(min)
print(sum(apple))

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

apple = [L+i for i in range(N)]
min = 500
for k in range(len(apple)):
    if abs(apple[k])<abs(min):
        min = apple[k]

apple.remove(min)
print(sum(apple))
Buggy code:
n,l=map(int,input().split())

aji=[]
for i in range(1,n+1):
    aji.append(l+i-1)
sum=sum(aji)
#print(aji)
p=1000
for i in range(n):
    if p<=aji[i]<=0 or 0<=aji[i]<=p:
        p=aji[i]
print(sum-p)


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

aji=[]
for i in range(1,n+1):
    aji.append(l+i-1)
sum=sum(aji)
#print(aji)
#print(sum)
p=1000
for i in range(n):
    if abs(aji[i])<=abs(aji[i-1]):
        p=aji[i]
        #print(aji[i])
print(sum-p)
Buggy code:
n,l=map(int,input().split())
ringo=[0]*n
ringoz=[0]*n
min=1000000000000000
mini=0
for i in range(n):
    ringo[i]+=i+l
    if ringo[i]<0:
        ringoz[i]=-ringo[i]
    else:
        ringoz[i]=ringo[i]
    if ringoz[i]>min:
        min=ringoz
        mini=i
ringo.pop(mini)
print(sum(ringo))


Fixed code:
n,l=map(int,input().split())
ringo=[0]*n
ringoz=[0]*n
min=1000000000000000
mini=0
for i in range(n):
    ringo[i]+=i+l
    if ringo[i]<0:
        ringoz[i]=-ringo[i]
    else:
        ringoz[i]=ringo[i]
    if ringoz[i]<min:
        min=ringoz[i]
        mini=i
ringo.pop(mini)

print(sum(ringo))
Buggy code:
temp=input().split()
N=int(temp[0])
L=int(temp[1])

edge=[L, L+N-1]
if edge[0]*edge[1]<=0:
  ans=sum(edge)*N/2
elif edge[0]>0:
  ans=(L+1+L+N-1)*(N-1)/2
else:
  ans=(L+L+N-2)*(N-1)/2
  
print(ans)

Fixed code:
temp=input().split()
N=int(temp[0])
L=int(temp[1])

edge=[L, L+N-1]
if edge[0]*edge[1]<=0:
  ans=sum(edge)*N/2
elif edge[0]>0:
  ans=(L+1+L+N-1)*(N-1)/2
else:
  ans=(L+L+N-2)*(N-1)/2
  
print(int(ans))
Buggy code:
N, L = map(int,input().split())
azi = [L+i-1 for i in range(1,N+1)]
mini = abs(azi[0])

for i in azi:
    if abs(i) < mini:
        mini = i
azi.remove(mini)
print(sum(azi))

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

for i in azi:
    if abs(i) < abs(mini):
        mini = i
azi.remove(mini)
print(sum(azi))
Buggy code:
[N, L] = [int(i) for i in input().split()]

apples = []

m = abs(L)
ind = 0

for i in range(N):
    apples.append(L+i)
    if m > abs(L+i):
        m = abs(L+i)
        ind = i
        
apples.remove(apples[i])

print(sum(apples))


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

apples = []

m = abs(L)
ind = 0

for i in range(N):
    apples.append(L+i)
    if m > abs(L+i):
        m = abs(L+i)
        ind = i
        
apples.remove(apples[ind])

print(sum(apples))
Buggy code:
l = list(map(int,input().split()))
N = l[0]
L = l[1]

apple =[]

for i in range(N):
    apple.append(L + i)
print(apple)

pie = 0
min = abs(L)
for i in range(N):
    pie = pie +apple[i]
    if abs(apple[i])< min:
        min = apple[i]

pie = pie - min

print(pie)


Fixed code:
l = list(map(int,input().split()))
N = l[0]
L = l[1]

apple =[]

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

pie = 0
flag = 1
min = abs(L)
for i in range(N):
    pie = pie + apple[i]
    if abs(apple[i]) < min:
        min = abs(apple[i])
        if apple[i]<0:
            flag = -1
        else:
            flag = 1

pie = pie - flag * min

print(pie)
Buggy code:
N, L = input().split()
N = int(N)
L = int(L)

Nsum=0
sum=0
for i in range(N):
    Nsum+=L+i

sa=1000000000
for i in range(N):
    a = (L+i-1)
    if(a<0):
      a=-a
    if(sa > a):
        sa=a

print(Nsum-sa)

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

Nsum=0
sum=0
for i in range(N):
    Nsum+=L+i

sa=1000000000
for i in range(N):
    a = (L+i)
    if(a<0):
      a=-a
    if(sa > a):
        sa=a

if(Nsum<0):
	print(Nsum+sa)
else:  
	print(Nsum-sa)
Buggy code:
n,l=map(int,input().split())
aji=[]
for i in range(n):
    aji.append(l+i)
e=aji.index(min(abs(aji)))
print(sum(aji)-aji[e])

Fixed code:
n,l=map(int,input().split())
aji=[]
for i in range(n):
    aji.append(l+i)
aji_abs=[]
for i in aji:
    aji_abs.append(abs(i))
e=aji_abs.index(min(aji_abs))

print(sum(aji)-aji[e])
Buggy code:
import numpy as np
N,L=map(int,input().split())
Taste=list(int(i) for i in range(L+1-1,L+N-1+1) )
MaxTaste=[sum(Taste)]*N
print(Taste)
print(MaxTaste)
print(sum(Taste)-Taste[np.argmax(np.abs(np.array(Taste)-np.array(MaxTaste)))])

Fixed code:
import numpy as np
N,L=map(int,input().split())
Taste=list(int(i) for i in range(L+1-1,L+N-1+1) )
MaxTaste=[sum(Taste)]*N
print(sum(Taste)-Taste[np.argmin(np.abs(np.array(Taste)))])
Buggy code:
n,l=map(int,input().split())
A=l-1+n*(n-1)//2
if 1<=1-l and 1-l<=n:
  print(A)
elif 1>1-l:
  print(A-(l-2))
else:
  print(A-n+1-l)

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

sum_all = 0
for i in range(N):
    sum_all += L + i

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

print(ans)
print(sum_all)

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

sum_all = 0
for i in range(N):
    sum_all += L + i

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

print(ans)
Buggy code:
line = input().strip()
N,K = line.split(" ")
N = int(N)
K = int(K)

flavors = 0
min_data = 10000000000000000
flag = False

for i in range(N):
    flavor = K  + i
    flavors += flavor
    if min_data > abs(flavor): min_data = flavor
    if flavor == 0: flag = True

if flag: print(flavors)
else: print(flavors - min_data)

Fixed code:
line = input().strip()
N,K = line.split(" ")
N = int(N)
K = int(K)

flavors = 0
min_data = 10000000000000000
flag = False

for i in range(N):
    flavor = K  + i
    flavors += flavor
    if abs(min_data) > abs(flavor): min_data = flavor
    if flavor == 0: flag = True

if flag: print(flavors)
else: print(flavors - min_data)
Buggy code:
N, L = map(int, input().split())

S = int(N * (L-1) + N * (N+1) / 2)

if L + N -1 < 0:
  print(S- (L + N - 1))
elif L - 1 > 0:
  print(S - (L-1))
else:
  print(S)


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

S = int(N * (L-1) + N * (N+1) / 2)

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

Fixed code:
N,L = map(int,input().split())
a = []
for i in range(1,N+1):
  a.append(L+i-1)
b = []
for i in a:
  b.append(abs(i))
for i in range(1,N+1):
  if abs(L+i-1) == min(b):
    print(sum(a)-L-i+1)
Buggy code:
n, l = [int(i) for i in input().split()]
ans = (l-1)*n+n*(n+1)//2
if l-1<=0 and l-1+n>=0:
  print(ans)
elif l+n-1<0:
  print(ans-(l+n-1))
elif l-1 >0:
  print(ans-l+1)

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

Fixed code:
n, l = map(int, input().split())
 
res = n * (l-1) + n * (n+1) / 2
if (0 >= l) and (1-l <= n):
  pass
elif 1-l > n:
  res -= (l+n-1)
else:
  res -= l
print(int(res))
Buggy code:
lm = []
N,L = input().split()
N = int(N)
L = int(L)
for x in range(N):
    lm.append((abs(L+x-1),L+x-1))
lm.sort(reverse=True)
lm = lm[1::]
s = 0
for u in range(len(lm)):
    s = s + lm[u][1]
print('{}'.format(s))

Fixed code:
lm = []
N,L = input().split()
N = int(N)
L = int(L)
for x in range(1,N+1):
    lm.append((abs(L+x-1),L+x-1))
lm.sort()
lm = lm[1::]
s = 0
for u in range(len(lm)):
    s = s + lm[u][1]
print('{}'.format(s))
Buggy code:
N, L = map(int, input().strip().split())

if L > 0:
  print(sum([i + L for i in range(1, N)]))
if L + N > 0:
  print(sum([i + L for i in range(0, N)]))
else:
  print(sum([i + L for i in range(0, N - 1)]))


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

if L > 0:
  print(sum([i + L for i in range(1, N)]))
elif L + N > 0:
  print(sum([i + L for i in range(0, N)]))
else:
  print(sum([i + L for i in range(0, N - 1)]))
Buggy code:
N,L=map(int,input().split())
taste=0
for i in range(N):
  taste += L + i

ans=10*6
p=-1
for j in range(N):
  tmp = abs(L+i)
  if tmp < ans:
    ans = tmp
    p = i
print(taste -(L+p))


Fixed code:
N,L=map(int,input().split())
taste=0
for i in range(N):
  taste += (L + i)

ans=10**6
p=-1
for j in range(N):
  tmp = abs(L+j)
  if tmp < ans:
    ans = tmp
    p = j
print(taste -(L+p))
Buggy 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))

Fixed 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])
target_number = 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))
Buggy code:
N,L = map(int,input().split())
aji = [L+i for i in range(N)]
ate = 10000
for a in aji:
  if abs(ate) > a:
    ate = a
print(sum(aji)-a)

Fixed code:
N,L = map(int,input().split())
aji = [L+i for i in range(N)]
ate = 10000
for a in aji:
  if abs(ate) > abs(a):
    ate = a
print(sum(aji)-ate)
Buggy code:
n, a = map(int, input().split())
L = a
R = a + n - 1
print(L)
print(R)
eat = 0
if R <= 0:
    eat = R
elif L >= 0:
    eat = L

ans = (R+L) * (R-L+1) / 2 - eat
print(int(ans))

Fixed code:
n, a = map(int, input().split())
L = a
R = a + n - 1
eat = 0
if R <= 0:
    eat = R
elif L >= 0:
    eat = L

ans = (R+L) * (R-L+1) / 2 - eat
print(int(ans))
Buggy code:
n, l = map(int, input().split())
l_ = [l+i for i in range(n)]
i_=0
for i in range(n):
	if abs(l_[i])<abs(l_[i_]):
		i_=i
print(sum(l_)-l_[i])

Fixed code:
n, l = map(int, input().split())
l_ = [l+i for i in range(n)]
i_=0
for i in range(n):
	if abs(l_[i])<abs(l_[i_]):
		i_=i
print(sum(l_)-l_[i_])
Buggy code:
N, L = map(int, input().split())

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

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



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

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

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

Fixed code:
n, l = map(int, input().split())
a = [l + i for i in range(n)]
if l + n - 1 < 0:
    a.pop(n - 1)
elif l > 0:
    a.pop(0)
print(sum(a))
Buggy code:
n,l = map(int,input().split())
a = [l+i for i in range(n)]
ans = 10000
for i in a:
  if abs(i) < ans:
    ans = abs(i)
print(sum(a)-ans)

Fixed code:
n,l = map(int,input().split())
a = [l+i for i in range(n)]
ans = 10000
index = 0
for i in range(n):
  if abs(a[i]) < ans:
    ans = abs(a[i])
    index = i
print(sum(a)-a[index])
Buggy code:
N, L = map(int, input().split())
A = list(range(1, N+1))
ans = 0
saisyo = float("inf")
saidai = -float("inf")
for i in range(N):
    x = A[i] + L-1 
    saisyo = min(x, saisyo)
    saidai  = max(x, saisyo)
    ans += x
if saisyo >=0:
    print(ans-saisyo)
else:
    print(ans-saidai)

Fixed code:
N, L = map(int, input().split())
A = list(range(1, N+1))
ans = 0
saisyo = float("inf")
saidai = -float("inf")
for i in range(N):
    x = A[i] + L-1 
    saisyo = min(x, saisyo)
    saidai  = max(x, saisyo)
    ans += x
if saidai < 0:
    print(ans-saidai)
elif saidai >= 0 and saisyo <= 0 :
    print(ans)
else:
    print(ans-saisyo)
Buggy code:
N,L=list(map(int,input().split()))
taste=[]
taste1=[]
memo=[]
sum=0
for i in range(N):
    tasty=abs(L+i)
    if L+i<0:
        memo.append(L+i)
    taste.append(tasty)
    taste1.append(L+i)
    sum+=taste1[i]
tasteab=sorted(taste)
memo=sorted(memo)
pie=(sum-memo[-1])
print(pie)

Fixed code:
N,L=list(map(int,input().split()))
taste=[]
taste1=[]
memo=[]
sum=0
for i in range(N):
    tasty=abs(L+i)
    if L+i<=0:
        memo.append(L+i)
    taste.append(tasty)
    taste1.append(L+i)
    sum+=taste1[i]
tasteab=sorted(taste)
memo=sorted(memo)
if memo!=[]:
    pie=(sum-memo[-1])
else:
    pie=(sum-tasteab[0])
print(pie)
Buggy 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)

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

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

if L >= 0 :
  print(sum_N - L)
elif L + N - 1 < 0 :
  print(sum_N - (L + N - 1))
else :
  print(sum_N)
Buggy code:
a,b=map(int,input().split())
total=a*(a+2*b-1)//2
x=b
y=a+b-1
z=min(abs(x),abs(y))
if x<=0 and y>=0:
  print(total)
else:
  print(total-z)

Fixed code:
a,b=map(int,input().split())
total=a*(a+2*b-1)//2
x=b
y=a+b-1
if abs(x)<abs(y):
  z=x
else:
  z=y
if x<=0 and y>=0:
  print(total)
else:
  print(total-z)
Buggy code:
N, L = map(int, input().split())
A = [L+i for i in range(N)]

A.remove(min([abs(a) for a in A]))
print(sum(A))

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

A.remove(min(max(A), *[abs(a) for a in A]))

print(sum(A))
Buggy code:
# coding: utf-8
# Your code here!

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

al_te = []
for i in range(N):
    T = L + i -1
    al_te.append(T)
#print(al_te)

ab_te = []
for i in range(N):
    T = L + i -1
    ab_te.append(abs(T))
#print(ab_te)
x = ab_te.index(min(ab_te))
#print(x)

al_te.pop(x)
print(sum(al_te))

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

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

al_te = []
for i in range(N):
    T = L + (i+1) -1
    al_te.append(T)
#print(al_te)

ab_te = []
for i in range(N):
    T = L + (i+1) -1
    ab_te.append(abs(T))
#print(ab_te)
x = ab_te.index(min(ab_te))
#print(x)

al_te.pop(x)
print(sum(al_te))
Buggy code:
n=[int(i) for i in input().split()]
array=[]
abs_array=[]
for i in range(n[0]):
  array.append(n[1]+i-1)
  abs_array.append(abs(n[1]+i-1))
abs_array=abs_array.sort()
if(abs_array[0] in array == True):
  print(sum(array)-abs_array[0])
else:
  print(sum(array)+abs_array[0])

Fixed code:
n=[int(i) for i in input().split()]
array=[]
abs_array=[]
for i in range(1,n[0]+1):
  array.append(n[1]+i-1)
  abs_array.append(abs(n[1]+i-1))
abs_array.sort()
if abs_array[0] in array :
  print(sum(array)-abs_array[0])
else:
  print(sum(array)+abs_array[0])
Buggy 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))

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

del apples[0]
print(sum(apples))
Buggy code:
from sys import stdin

# N, L = stdin.readline().rstrip()
N, L = map(int, input().split(' '))
print(N, L)
# 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)

Fixed code:
from sys import stdin

# N, L = stdin.readline().rstrip()
N, L = map(int, input().split(' '))
# print(N, L)
# 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)
Buggy code:
n,l=map(int,input().split())
if(n-1<=l<=0):
  print('{0}'.format(n*(2*l+n-1)//2))
elif(l>0):
  print('{0}'.format(n*(2*l+n-1)//2-l))
else:
  print('{0}'.format(n*(2*l+n-1)//2-l-n+1))

Fixed code:
n,l=map(int,input().split())
if(-n+1<=l<=0):
  print('{0}'.format(n*(2*l+n-1)//2))
elif(l>0):
  print('{0}'.format(n*(2*l+n-1)//2-l))
else:
  print('{0}'.format(n*(2*l+n-1)//2-l-n+1))
Buggy code:
import numpy as np

N,L = [int(i) for i in input().split()]
L = np.arange(L,L+N)
print(L)

if 0 in L:
  print(sum(L))
else:
  if min(L) > 0:
    print(sum(L)-min(L))
  else:
    print(sum(L)-max(L))

Fixed code:
import numpy as np

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


if 0 in L:
  print(sum(L))
else:
  if min(L) > 0:
    print(sum(L)-min(L))
  else:
    print(sum(L)-max(L))