qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
l=list(mi())
s=0
t=0
for i in l:
  s+=i
  t+=i**2
print(s**2-t)

Fixed code:
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
l=list(mi())
s=0
t=0
for i in l:
  s+=i
  t+=i**2
print(int((s**2-t)/2))
Buggy code:
N=int(input())
A=list(map(int,input().split()))
ans = 0
for i in range(N-1):
  for j in range(N):
    ans += A[i]*A[j]
print(ans)

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

ans = 0
for i in range(N-1):
	for j in range(i+1, N):
		ans += D[i]*D[j]

print(ans)
Buggy code:
a= input().split(" ")

N=int(a[0])

#d=[int(input()) for _ in range(N)]
d=input().split(" ")
for i in range(N):
  d[i] = int(d[i])

sum=0
print(d)

for i in range(N-1):
  for j in range(N-1-i):
    sum = sum + d[i]*d[i+j+1]
  
print(sum)


Fixed code:
a= input().split(" ")

N=int(a[0])

#d=[int(input()) for _ in range(N)]
d=input().split(" ")
for i in range(N):
  d[i] = int(d[i])

sum=0
#print(d)

for i in range(N-1):
  for j in range(N-1-i):
    sum = sum + d[i]*d[i+j+1]
  
print(sum)
Buggy code:
N = int(input())
L = list(map(int,input().split()))

s = sum(L)
p = 0
for a in L:
 p += a*a

ans=(s*s-p)/2

print(ans)

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

s = sum(L)
p = 0
for a in L:
 p += a*a

ans=(s*s-p)/2

print(int(ans))
Buggy code:
N=int(input())
D=list(map(int,input().split()))
p=0
q=0
for i in range(N):
  p= p+D[i]**2
  q= q+D[i]
print((q**2-p)/2)

Fixed code:
N=int(input())
D=list(map(int,input().split()))
p=0
q=0
for i in range(N):
  p= p+D[i]**2
  q= q+D[i]
print((q**2-p)//2)
Buggy code:
N = int(input())
D = list(map(int, input().split()))

def sum_(N, D):
    total = 0
    for i in range(N):
        for j in range(i+1, N):
            total = total + (D[i] * D[j])
    return total

sum_(N, D)

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

def sum_(N, D):
    total = 0
    for i in range(N):
        for j in range(i+1, N):
            total = total + (D[i] * D[j])
    print(total)

sum_(N, D)
Buggy code:
n = int(input())
D = list(map(int,input().split()))

ans = 0

for i in range(n):
  for j in range(i):
    ans += D[i]*D[j]
print(ans//2)

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

ans = 0

for i in range(n):
  for j in range(i):
    ans += D[i]*D[j]
print(ans)
Buggy code:
N = int(input())
d = [int(x) for x in input().split()]
f = sum(d)
s = 0

for i in f:
  s += i * (f-i)

print(s//2)


Fixed code:
N = int(input())
d = [int(x) for x in input().split()]

f = sum(d)
s = 0

for i in d:
  s += i * (f-i)
print(s//2)
Buggy code:
N = int(input())
taste_list = list(map(int, input().split()))
taste_sum = 0
for i in range(len(taste_list)):
  for j in range(len(taste_list)):
    taste = taste_list[i] + taste_list[j]
    taste_sum += taste
for i in range(len(taste_list)):
  taste_sum -= taste_list[i]**2
print(taste_sum)




Fixed code:
n = int(input())
taste_list = list(map(int, input().split())) 
taste_sum = 0
for i in range(n):
  for j in range(n):
    taste = taste_list[i]*taste_list[j]
    taste_sum += taste
for i in range(len(taste_list)):
  taste_sum -= taste_list[i]**2
print(int(taste_sum/2))
Buggy code:
N = int(input())
List = [int(j) for j in input().split(" ")]
Sum = 0
for n in range(0,N-1):
  for m in range(n+1,N):
    Sum += List[i]*List[j]
print(Sum)

Fixed code:
N = int(input())
List = [int(j) for j in input().split(" ")]
Sum = 0
for n in range(0,N-1):
  for m in range(n+1,N):
    Sum += List[n]*List[m]
print(Sum)
Buggy code:
num=int(input())
data=input().split()
sum=0

for a in range(num):
  for b in range(num-1-a):
    sum+=int(data[a])*int(data[-b])
print(sum)

Fixed code:
num=int(input())
data=input().split()
sum=0
 
for a in range(num):
  for b in range(num-1-a):
    sum+=int(data[a])*int(data[-1-b])
print(sum)
Buggy code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Ds = list(mapint())

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        aNS += Ds[i]*Ds[j]

print(ans)

Fixed code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Ds = list(mapint())

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        ans += Ds[i]*Ds[j]

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

ans=0
for i in range(n):
    for k in range(n):
        if i != k:
            ans += d[i] * d[k]

print(ans/2)

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

ans=0
for i in range(n):
    for k in range(n):
        if i != k:
            ans += d[i] * d[k]

print(ans//2)
Buggy code:
input()
d=[int(i) for i in input().split()]
i=0
while True:
  a=d[0]
  del d[0]
  if d == []:
    break
  for i in d:
    sum += a*i
print(sum)

Fixed code:
n=input()
d=[int(i) for i in input().split()]
sum=0
while True:
  a=d[0]
  del d[0]
  if d == []:
    break
  for i in d:
    sum += a*i
print(sum)
Buggy code:
import itertools

N = int(input())
d = list(map(int, input().split()))

print(sum([d[i - 1] * d[j - 1] for i, j in list(itertools.combinations(d, 2))]))

Fixed code:
import itertools

N = int(input())
d = list(map(int, input().split()))

print(sum([i * j for i, j in list(itertools.combinations(d, 2))]))
Buggy code:
n=int(input())
d=list(map(int,input().split())
hp=0
for i in range(n-1):
       for j in range(i+1,n):
            hp=hp+d[i]*d[j]
print(hp)

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

sum = 0
for i in range(n-1):
  for j in range(i+1, n):
    sum += d[i] * d[j]
print(sum)
Buggy code:
n=int(input())
d=list(map(int,input().split())
hp=0
for i in range(n):
       for j in range(i+1,n):
            hp+=d[i]*d[j]
print(hp)

Fixed code:
n=int(input())
d=list(map(int,input().split()))
hp=0
for i in range(n-1):
       for j in range(i+1,n):
            hp=hp+d[i]*d[j]
print(hp)
Buggy code:
n=input()
arr=list(map(int,input().split()))
s=0
for i in range(0,n-1):
  for j in range(i+1,n):
    s+=arr[i]*arr[j]
print(s)

Fixed code:
n=int(input())
arr=list(map(int,input().split()))
s=0
for i in range(0,n-1):
  for j in range(i+1,n):
    s+=arr[i]*arr[j]
print(s)
Buggy code:
n=int(input())
a=list(map(int,input().split())
ans=0
for i in range(n):
  for j in range(i + 1, n):
    ans+=a[i]*a[j]
print(ans)

Fixed code:
n = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(n):
  for j in range(i+1, n):
    ans += d[i] * d[j]
print(ans)
Buggy code:
n = int(input())
data = [int(i) for i input().split()]
ans = 0
for i in range(n):
  for j in range(i+1,n):
    ans += data[i]*data[j]
print(ans)

Fixed code:
n = int(input())
data = [int(i) for i in input().split()]
ans = 0
for i in range(n-1):
  for j in range(i+1,n):
    ans += data[i]*data[j]
print(ans)
Buggy code:
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    D = list(map(int,input().split()))
    ans = 0
    for i in range(N):
        for j in range(i,N):
            ans += (D[i]*D[j])
    print(ans)
if __name__ == '__main__':
    main()

Fixed code:
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    D = list(map(int,input().split()))
    ans = 0
    for i in range(N):
        for j in range(i+1,N):
            ans += (D[i]*D[j])
    print(ans)
if __name__ == '__main__':
    main()
Buggy code:
import itertools

n=int(input())
d=list(map(int,input().split()))
ans=0
for v in itertools.combinations(d, 2):
    ans=ans+v[0]+v[1]
    
print(ans)

Fixed code:
import itertools

n=int(input())
d=list(map(int,input().split()))
ans=0
for v in itertools.combinations(d, 2):
    ans=ans+v[0]*v[1]
   
print(ans)
Buggy code:
N = int(input())
d_list = list(map(int, input().split()))
 
ret = 0
for i in range(N):
  for j in range(i,N):
    ret += d_list[i] * d_list[j]
print(ret)

Fixed code:
N = int(input())
d_list = list(map(int, input().split()))
 
ret = 0
for i in range(N):
  for j in range(i+1,N):
    ret += d_list[i] * d_list[j]
print(ret)
Buggy code:
# B: TAKOYAKI FES
N = int(input())
D = [int(d) for d in input().split()]
deli_list = [x*y for x in D for y in D]

# sum of diagonal 
self_comb = sum(D)

# (sum of 2D-Table - sum of diagonal) / 2
ans = int(((sum(deli_list)-self_comb)/2))
print(ans)

Fixed code:
# B: TAKOYAKI FES
N = int(input())
D = [int(d) for d in input().split()]
deli_list = [x*y for x in D for y in D]

# sum of diagonal 
self_comb = sum(D[i]*D[i] for i in range(N))

# (sum of 2D-Table - sum of diagonal) / 2
ans = int(((sum(deli_list)-self_comb)/2))
print(ans)
Buggy code:
N = int(input())
D = list(map(int, input().split()))

sum_all = 0
for i in range(N):
  for s in range(i, N):
    sum_all += D[i] * D[s]
    
print(sum_all)

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

sum_all = 0
for i in range(N):
  for s in range(i+1, N):
    sum_all += D[i] * D[s]
    
print(sum_all)
Buggy code:
N = int(input())
d = [int(i) for i in input().split()]
sum = 0

for i in range(N):
  for j in range(N):
    if i != j:
      sum += d[i] * d[j]

print(sum)

Fixed code:
N = int(input())
d = [int(i) for i in input().split()]
sum = 0

for i in range(N):
  for j in range(N):
    if i != j:
      sum += d[i] * d[j]

print(int(sum/2))
Buggy code:
    n = int(input())
    tastes = list(map(lambda x:int(x), input().split()))
    
    ans = 0
    
    while len(tastes)>0:
        x = tastes.pop()
        for y in tastes:
            ans += x * y
            
    print(ans)

Fixed code:
n = int(input())
tastes = list(map(lambda x:int(x), input().split()))

ans = 0

while len(tastes)>0:
    x = tastes.pop()
    for y in tastes:
        ans += x * y
            
print(ans)
Buggy code:
n=int(input())
d=list(map(int,input().split()))
for i in range(n):
  for j in range(n):
    if i!=j:
      sum+=d[i]*d[j]
print(sum//2)


Fixed code:
n=int(input())
d=list(map(int,input().split()))
sum=0
for i in range(n):
  for j in range(n):
    if i!=j:
      sum+=d[i]*d[j]
print(sum//2)
Buggy code:
def main():
    number_of_takoyakis = int(input())
    takoyaki_list = list(map(int,input().split()))
    cure_list = []
    for i in range(number_of_takoyakis):
        for j in range(number_of_takoyakis):
            if i != j:
                cure_list.append(caliculate_cure_point(takoyaki_list[i],takoyaki_list[j]))
    print(sum(cure_list)/2)

def caliculate_cure_point(takoyaki1,takoyaki2):
    return takoyaki1*takoyaki2

main()


Fixed code:
def main():
    number_of_takoyakis = int(input())
    takoyaki_list = list(map(int,input().split()))
    cure_list = []
    for i in range(number_of_takoyakis):
        for j in range(number_of_takoyakis):
            if i != j:
                cure_list.append(caliculate_cure_point(takoyaki_list[i],takoyaki_list[j]))
    print(sum(cure_list)//2)

def caliculate_cure_point(takoyaki1,takoyaki2):
    return takoyaki1*takoyaki2

main()
Buggy code:
n=int(input())
L=list(map(int,input().split()))

ans=0
for i in range(n):
      for j in range(i+1,n):
            ans+=i*j
print(ans)
            


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

ans=0
for i in range(n):
      for j in range(i+1,n):
            ans+=L[i]*L[j]
print(ans)
Buggy code:
N = int(input())
l = list(map(int, input().split()))
sum = 0
for i in range((N*(N-1))//2):
    for j in range(i):
        a = l[i]*l[j]
        sum+=a
print(sum)


Fixed code:
N = int(input())
l = list(map(int, input().split()))
sum = 0
for i in range((N*(N-1))//2):
    for j in range(i+1,N):
        a = l[i]*l[j]
        sum+=a
print(sum)
Buggy code:
N = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(N):
  ans = ans - d[i]**2
  for j in range(N):
    ans = ans + d[i]*d[j]
ans = ans / 2
print(ans)


Fixed code:
N = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(N):
  ans = ans - d[i]**2
  for j in range(N):
    ans = ans + d[i]*d[j]
ans = ans / 2
print(int(ans))
Buggy code:
n = int(input())
d = list(map(int,input().split()))
ans = 0
for i in range(len(d)):
    for j in range(i,len(d)):
        ans += d[i]*d[j]
print(ans)

Fixed code:
n = int(input())
d = list(map(int,input().split()))
ans = 0
for i in range(len(d)):
    for j in range(i+1,len(d)):
        ans += d[i]*d[j]
print(ans)
Buggy code:
N = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
  for j in range(i + 1, N):
    ans += d[i] * d[j]

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

ans = 0

for i in range(N-1):
    for j in range(i+1,N):
        ans += d[i] * d[j]

print(ans)
Buggy code:
N = int(input())
D = list(map(int,input().split()))
TotalList = 0

for A in range(N-1):
  for B in range(A+1):
    TotalList += D[A]*D[B]
    

print(TotalList)

Fixed code:
N = int(input())
D = list(map(int,input().split()))
TotalList = 0

for A in range(N-1):
  for B in range(A+1,N):
    TotalList += D[A]*D[B]
    

print(TotalList)
Buggy code:
num = int(input())
heellist = input().split(' ')

HeelSum = 0

for i in range(0, num-1):
  for j in range(i+1, num-1):
    HeelSum += int(heellist[i]) * int(heellist[j])
print(HeelSum)

Fixed code:
num = int(input())
heellist = input().split(' ')

HeelSum = 0

for i in range(0, num):
  for j in range(i+1, num):
    HeelSum += int(heellist[i]) * int(heellist[j])

print(HeelSum)
Buggy code:
n = int(input())
d = list(map(int,input().split()))
ans = 0
for i in range(n):
  ans += i * (sum(d) - i)
print(ans // 2)

Fixed code:
n = int(input())
d = list(map(int,input().split()))
ans = 0
for i in range(n):
  ans += d[i] * (sum(d) - d[i])
print(ans // 2)
Buggy code:
n = int(input())
d = list(map(int,input().split()))
ans = 0
for i in range(n):
  for j in range(n):
    ans += d[i]*d[j]
    print(ans)
for k in range(n):
  ans -= d[k]**2
print(ans//2)

Fixed code:
n = int(input())
d = list(map(int,input().split()))
ans = 0
for i in range(n):
  for j in range(n):
    ans += d[i]*d[j]
for k in range(n):
  ans -= d[k]**2
print(ans//2)
Buggy code:
n=int(input())
d=list(map(int,input().split()))
s=0
for i in range(n):
  for j in range(i+1,n):
    s+=i*j
print(s)
    

Fixed code:
n=int(input())
d=list(map(int,input().split()))
s=0
for i in range(n):
  for j in range(i+1,n):
    s+=d[i]*d[j]
print(s)
Buggy code:
n=int(input())
d=map(int,input().split(" "))
wa=[]
for i in range(1,n+1):
  for j in range(i,n+1):
    wa.append(i*j)
print(sum(wa))


Fixed code:
n=int(input())
d=list(map(int,input().split(" ")))
wa=[]
for i in range(0,n):
  for j in range(i+1,n):
    wa.append(d[i]*d[j])

print(sum(wa))
Buggy code:
n=int(input())
d=list(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(n):
        if i!=j:
            ans+=d[i]*d[j]
print(ans/2)

Fixed code:
n=int(input())
d=list(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(n):
        if i!=j:
            ans+=d[i]*d[j]
print(ans//2)
Buggy code:
n = int(input().split())
d = list(map(int,input().split()))
print((sum(d)**2-sum(d[i]**2 for i in range(n)))//2)

             

Fixed code:
n=int(input())
d=list(map(int,input().split()))
tot=sum(d)**2
for i in range(n):
  tot-=d[i]**2
print(tot//2)
Buggy code:
n = int(input().split())
d = list(map(int(input().split())))
print((sum(d)**2-sum(d[i]**2 for i in range(n)))//2)

             

Fixed code:
n = int(input())
d = list(map(int,input().split()))
print((sum(d)**2-sum(d[i]**2 for i in range(n)))//2)
Buggy code:
n = int(input())
d=list(map(int,input().split()))

kaihuku = 0

for i in range(n-1):
    for j in range(i+1,n):
        kaihuku += d(i) * d(j)

print(kaihuku)

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

kaihuku = 0

for i in range(n-1):
    for j in range(i+1,n):
        kaihuku += d[i] * d[j]

print(kaihuku)
Buggy code:
from collections import deque

def input():
    return sys.stdin.readline().rstrip('\n')

N = int(input())
D = list(map(int, input().split()))

D = deque(D)
sum0 = D.pop()
hp = 0

for _ in range(N-1):
    d = D.pop()
    hp += d * sum0
    sum0 += d

print(hp)


Fixed code:
import sys
#import bisect
from collections import deque

def input():
    return sys.stdin.readline().rstrip('\n')

N = int(input())
D = list(map(int, input().split()))

D = deque(D)
sum0 = D.pop()
hp = 0

for _ in range(N-1):
    d = D.pop()
    hp += d * sum0
    sum0 += d

print(hp)
Buggy code:
n = input()
d = map(int, input().split())
sum = 0
for i in range(n-1):
  for j in range(i+1, n):
    sum += d[i] * d[j]
print(sum)


Fixed code:
n = int(input())
d = list(map(int, input().split()))
sum = 0
for i in range(n-1):
  for j in range(i+1, n):
    sum += d[i] * d[j]
print(sum)
Buggy code:
n = input()
d = list(map(int, input().split()))
sum = 0
for i in range(n-1):
  for j in range(i+1, n):
    sum += d[i] * d[j]
print(sum)


Fixed code:
n = int(input())
d = list(map(int, input().split()))
ans = 0

for i in range(n-1):
    for j in range(1+i, n):
        ans += d[i] * d[j]

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

from itertools import combinations

combi = list(combinations(ls, 2))

s = 0
for a, b in combi:
    s += (a * b)

print(s

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

from itertools import combinations

combi = list(combinations(ls, 2))

s = 0
for a, b in combi:
    s += (a * b)

print(s)
Buggy code:
import itertools
N = int(input())
d = list(map(int, input().split()))

p = list(itertools.permutations(d,2))


n = 0

for i in range(len(p)):
    n = n + (p[i][0] * p[i][1])
    
print(n/2)


Fixed code:
import itertools
N = int(input())
d = list(map(int, input().split()))

p = list(itertools.permutations(d,2))


n = 0

for i in range(len(p)):
    n = n + (p[i][0] * p[i][1])
    
A = int(n/2)
print(A)
Buggy code:
n=int(input())
d=list(map(int,input().split()))
d_sum=sum(d)
sq=0
for i in range(n):
    sq+=d[i]**2
print(d_sum**2-sq)

Fixed code:
n=int(input())
d=list(map(int,input().split()))
d_sum=sum(d)
sq=0
for i in range(n):
    sq+=d[i]**2
print((d_sum**2-sq)//2)
Buggy code:
a=int(input())
b=list(map(int,input().split))

s=0
for i in range(a):
  for j in range(i+1,a):
    s+=d[i]*d[j]
print(s)
  


Fixed code:
a=int(input())
b=list(map(int,input().split()))
 
s=0
for i in range(a):
  for j in range(i+1,a):
    s+=b[i]*b[j]
print(s)
Buggy code:
n=int(input())
d=list(int(x) for x in input().split())

sum=0

for i in range(n):
  for j in range(n-i-1):
    sum+=d[i]*d[i+j+1]
    print(sum)
print(sum)

Fixed code:
n=int(input())
d=list(int(x) for x in input().split())

sum=0

for i in range(n):
  for j in range(n-i-1):
    sum+=d[i]*d[i+j+1]
print(sum)
Buggy code:
N = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(N-1):
  for j in range(i:N):
    ans += d[i] * d[j]
print (ans)

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

total=0
for i in range(N-1):
    for j in range(i+1,N):
        total += d[i]*d[j]

print(total)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n-1):
  for j in range(n-1):
    ans += a[i] * a[j]
for k in range(n):
  ans -= a[k]
print(ans)

Fixed code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
  for j in range(i +1, n):
    ans += a[i] * a[j]
print(ans)
Buggy code:
N=int(input())
d=list(map(int,input().split()))

answer=0

for i in range(N):
  for t in range(N):
    if t>=i:
      answer+=d[i]*d[t]

print(answer)

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

answer=0

for i in range(N):
  for t in range(N):
    if t>i:
      answer+=d[i]*d[t]

print(answer)
Buggy code:
n = int(input())
l = [int(i) for i in input().split()]
sum = 0
i = 0
while i < n:
    j = i+1
    while j <= n:
        sum += l[i] * l[j]
        j += 1
    i += 1
print(sum)

Fixed code:
n = int(input())
l = [int(i) for i in input().split()]
sum = 0
i = 0
while i < n-1:
    j = i+1
    while j < n:
        sum += l[i] * l[j]
        j += 1
    i += 1
print(sum)
Buggy code:
n=int(input())
s=list(map(int,input().split()))
sum=0
for i in range(n):
  for j in range(n-1):
    sum+=s[i]*s[j]
    
print(sum)
    

Fixed code:
n=int(input())
s=list(map(int,input().split()))
sum=0
for i in range(n):
  for j in range(i+1,n):
    sum+=s[i]*s[j]
    
print(sum)
Buggy code:
n=int(input())
s=list(map(int,input().split()))
sum=0
for i in range(n):
  for j in range(n):
    sum=sum+s[i]*s[j]
print(sum)

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

sum = 0
for i in range(n):
    for j in range(i):
        sum += d[i] * d[j]

print(sum)
Buggy code:
n=int(input())
d=list(map(int,input().split()))
s=[0]*n
cnt=0
for i in range(n):
  for j in range(i+1,n):
    s[cnt]=d[i]*d[j]
    cnt+=1
print(sum(s))

Fixed code:
n=int(input())
d=list(map(int,input().split()))
s=[0]*int(n*(n-1)/2)
cnt=0
for i in range(n):
  for j in range(i+1,n):
    s[cnt]=d[i]*d[j]
    cnt+=1
print(sum(s))
Buggy code:
n=int(input())
tako=list(map(int,input().split()))
ans=0
for i in range(n-1):
    for j in range(1,n):
        if not i==j:
            ans+=tako[i]*tako[j]
print(ans)

Fixed code:
n=int(input())
tako=list(map(int,input().split()))
ans=0
for i in range(n-1):
    for j in range(1,n):
        if not j<=i:
            
          
            ans+=tako[i]*tako[j]
print(ans)
Buggy code:
N = int(input())
l = list(map(int,input().split()))


ans = 0
for i in range(N):
  for j in range(i,N):
    ans += l[i]*l[j]
    
print("ans")

Fixed code:
N = int(input())
l = list(map(int,input().split()))
 
ans = 0
for i in range(N):
  for j in range(i+1,N):
    ans += l[i]*l[j]
    
print(ans)
Buggy code:
n = int(input())
d = list(map(int, input().split()))

print(n)
i = 0
j = 0
p = 0

while i < n - 1:
    while j < n - 1:
        p += d[i] * d[j + 1]
        j = j + 1 
    i = i + 1
    j = i
print('p=', p)

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

i = 0
j = 0
p = 0

while i < n - 1:
    while j < n - 1:
        p += d[i] * d[j + 1]
        j = j + 1 
    i = i + 1
    j = i
print(p)
Buggy code:
n = int(input())
d = list(map(int, input().split()))
ans = 0
for i in n -1:
	for j in (i + 1: n):
		ans += d[i] * d[j]
		
print(ans)

Fixed code:
n = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += d[i]*d[j]

print(ans)
Buggy code:
n = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(n):
  for j in range(i+1, n):
    ans += i*j
print(ans)

Fixed code:
n = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(n):
  for j in range(i+1, n):
    ans += d[i] * d[j]
print(ans)
Buggy code:
n = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(n-1):
  for j in range(i+1, n):
    ans += i*j
print(ans)

Fixed code:
n = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(n-1):
  for j in range(i+1, n):
    ans += d[i]*d[j]
print(ans)
Buggy code:
n = int(input())
l = [*map(int,input().split())]
s,res = l[0],0
for i in range(1,n):
  res+=s*l[i]
  s+=l[i]
print(s)


Fixed code:
n = int(input())
l = list(map(int,input().split()))
s,res = l[0],0
for i in range(1,n):
  res+=s*l[i]
  s+=l[i]
print(res)
Buggy code:
N = int(input())
data = [int(x) for x in input().split()]
data_sum = 0
for i in range(N):
    for j in range(i+1,N):
        print(i,j)
        data_sum += data[i] * data[j]
print(data_sum)


Fixed code:
N = int(input())
data = [int(x) for x in input().split()]
data_sum = 0
for i in range(N):
    for j in range(i+1,N):
        data_sum += data[i] * data[j]
print(data_sum)
Buggy code:
n=int(input())
d = list(map(int, input().split()))
sum=0

for i in range(n-1):
    for j in range(n-2,n):
        if i!=j:
            sum=sum+d[i]*d[j]

print(sum)


Fixed code:
n=int(input())
d = list(map(int, input().split()))
sum=0

for i in range(n-1):
    for j in range(i,n):
        if i!=j:
            sum=sum+d[i]*d[j]

print(sum)