Problem:


Score : 200 points

Problem Statement

It's now the season of TAKOYAKI FESTIVAL!

This year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.

As is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \times y health points.

There are \frac{N \times (N - 1)}{2} ways to choose two from the N takoyaki served in the festival. For each of these choices, find the health points restored from eating the two takoyaki, then compute the sum of these \frac{N \times (N - 1)}{2} values.

Constraints

All values in input are integers.

2 \leq N \leq 50

0 \leq d_i \leq 100

Input

Input is given from Standard Input in the following format:

N
d_1 d_2 ... d_N

Output

Print the sum of the health points restored from eating two takoyaki over all possible choices of two takoyaki from the N takoyaki served.

Sample Input 1

3
3 1 2

Sample Output 1

11

There are three possible choices:

Eat the first and second takoyaki. You will restore 3 health points.

Eat the second and third takoyaki. You will restore 2 health points.

Eat the first and third takoyaki. You will restore 6 health points.

The sum of these values is 11.

Sample Input 2

7
5 0 7 8 3 3 2

Sample Output 2

312



Sample input:
3
3 1 2


Sample output:
11

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    D=list(mi())

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

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

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)

Submission status: Accepted

Solution code:
# ABC143
# B Tkoyaki Festival 2019
n = int(input())
D = list(map(int, input().split()))
ct = 0
for i in range(n):
    for j in range(n):
        if i != j:
            if i < j:
                ct += D[i] * D[j]
print(ct)

Submission status: Accepted

Solution code:
n=int(input())
d = list(map(int,input().split()))
import itertools
p = itertools.combinations(d, 2)
s=0
for v in p:
    s+=v[0]*v[1]
print(s)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
c = 0
for i in range(n):
  for j in range(i+1,n):
    c += l[i]*l[j]
print(c)

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
l = inpl()
ans = 0
for i in range(0, n):
    for j in range(i + 1, n):
        ans += l[i] * l[j]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int,input().split()))
amount = 0
b = [0] * N
for i in range(N):
    b[i] = amount
    amount += d[N-1-i]


ans = 0
for i in range(N):
    ans += d[i]*b[N-1-i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [int(n) for n in input().split()]
s = 0
for i in range(n):
    for j in range(i + 1, n):
        s += a[i] * a[j]
print(s)

Submission status: Accepted

Solution code:
from itertools import combinations

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

info = list(combinations(d, 2))

ans = 0
for x, y in info:
    ans += x*y

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
s=0
for i in range(len(l)):
  for j in range(i):
    res=l[i]*l[j]
    s+=res
print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from itertools import combinations


def main():
    input = sys.stdin.buffer.readline
    _n = int(input())
    d = list(map(int, input().split()))
    ans = 0
    for i, j in combinations(d, 2):
        ans += i * j
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())
d=list(map(int,input().split()))
a=0
for i in range(len(d)):
    for j in range(len(d)):
        if i!=j and i>j:
            a+=d[i]*d[j]
print(a)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
D = list(map(int, input().split()))

D = list(itertools.combinations(D, 2))

ans = 0
for d in D:
    ans += d[0]*d[1]

print(ans)

Submission status: Accepted

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

for n in range(N-1):
  ans+=sum(D[n]*D[n+1:])
  
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = list(map(int,input().split()))

ans = 0
for x in range(N-1):
  for y in range(x+1,N):
    ans += S[x]*S[y]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i, j in itertools.combinations(a, 2):
  cnt += i*j
print(cnt)

Submission status: Accepted

Solution code:
import math 
import itertools

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

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int,input().split()))
power = 0
for i in range(N-1):
    for j in range(i+1,N):
        power += D[i]*D[j]
print(power)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int,input().split()))
sumc = 0
for i in range(len(d)):
    for j in range(i+1,len(d)):
        sumc += d[i]*d[j]
print(sumc)

Submission status: Accepted

Solution code:
import numpy as np
n=int(input())
d_i = list(map(int, input().split()))  
d=np.array(d_i)
out=0
for i in range(1,n):
    a=d_i.pop(0)
    d_i.append(a)
    out+=np.dot(d,np.array(d_i))
print(int(out/2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
ans = 0
d = readInts()
for a,b in combinations(d,2):
    ans += a*b
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from itertools import combinations

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

pairs = combinations(d, 2)

print(sum(map(lambda x: x[0]*x[1], pairs)))

Submission status: Accepted

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

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

Submission status: Accepted

Solution 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:
            continue
        elif i < j:
            ans += d[i]*d[j]
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

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

C = list(combinations(D, 2))

ans = 0
for i, j in C:
  ans += i*j
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

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

xy = list(combinations(D,2))
ans = 0

for i in range(len(xy)):
    ans += xy[i][0]*xy[i][1]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

N, *D = map(int, open(0).read().split())
ans = 0
for v in itertools.combinations(D, 2):
    ans += v[0] * v[1]

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
dl = list(map(int, input().split()))

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

print(ans)

Submission status: Accepted

Solution code:
import itertools
import functools
import operator
pi = functools.partial(functools.reduce, operator.mul)


def solve():
    N = int(input())
    d = [int(x) for x in input().split()]
    ans = 0
    for c in itertools.combinations(d, 2):
        # print(c)
        ans += pi(c)
    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int,input().split()))
cnt = 0
for i in range(N):
    cnt += D[i]**2
tot = 0
for i in range(N):
    tot += D[i]
tot = tot**2
tot -= cnt
print(tot//2)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N):
  for j in range(i+1,N):
    temp = A[i]*A[j]
    ans += temp
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split(' ')))
x = 0
start = 1

for i in l:
    for j in range(start,n):
        x += (i*l[j])
    start += 1

print(x)

Submission status: Accepted

Solution code:
from functools import reduce
from itertools import accumulate
from math import gcd
n=int(input())
L=list(map(int,input().split()))
print(sum(d*cumulate for d,cumulate in zip(L[1:],accumulate(L))))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N=int(input())
d=list(map(int,input().split()))
ls=[]
for i in range(N):
    ls.append(i)
lsp=list(itertools.permutations(ls,2))
#print(lsp)
ans=0
#print(lsp[])
for i in range(len(lsp)):
    ans += d[lsp[i][0]]*d[lsp[i][1]]
print(ans//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D_ls = list(map(int, input().split(' ')))
result = 0
for i in range(N):
    for j in range(i+1, N):
        result += D_ls[i] * D_ls[j]
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

l = list(it.combinations(d,2))

ans = 0
for i in range(len(l)):
    ans += l[i][0] * l[i][1]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

n = int(input())
d = list(map(int, input().split()))
s = 0
c = itertools.combinations(d, 2)

for x, y in c:
    s += x*y
print(s)

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int,input().split()))
res = 0

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

Submission status: Accepted

Solution code:
N = int(input())
dd = input().split()
total = 0
for i in range(N-1):
  for j in range(i+1,N):
    total += int(dd[i]) * int(dd[j])
print(total)

Submission status: Accepted

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

m = 1
num = 0
for s in range(0,n-1):
    for t in range(m,n):
        num += (d[s]*d[t])
    m += 1
print(num)

Submission status: Accepted

Solution code:
n=int(input())

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

d[0]

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
d = LI()
ans = 0
l = list(itertools.combinations(d,2))
for i, j in l:
    ans += i*j
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations
N = int(input())
D = list(map(int, input().split()))
res = 0
for x, y in combinations(D, 2):
    res += x*y
print(res)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
prod=0
for i in range(n):
    for j in range(i+1,n):
        prod=prod+(l[i]*l[j])
print(prod)

Submission status: Accepted

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

Submission status: Accepted

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

main()

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))

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)

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
d = list(map(int, input().split()))
ans = (sum(d)**2 - sum(item**2 for item in d))//2
print(ans)

Submission status: Accepted

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

a=0
for i in range(N):
    for k in range(1,N-i):
        a=a+d[i]*d[i+k]
print(a)

Submission status: Accepted

Solution code:
n = int(input())
d = [int(s) for s in input().split()]
ans = 0
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        else:
            ans += d[i] * d[j]
print(ans // 2)

Submission status: Accepted

Solution code:
n = int(input())
q = list(map(int,input().split()))
ans = 0

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

Submission status: Accepted

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

def main():

    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)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
numList = map(int,input().split())
numList = list(numList)

multiplyList = []
start = 0
for i in range(n+1):
    start += 1
    for j in range(start, n):
        multiplyList.append(numList[i] * numList[j])

print(sum(multiplyList))

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
s = 0

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

print(s)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
s = 0

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

s //= 2

print(s)

Submission status: Accepted

Solution 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 += d[i]*d[j]
print(hp)

Submission status: Accepted

Solution code:
import itertools

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

ans = sum(x * y for x, y in itertools.combinations(D, 2))
print(ans)

Submission status: Accepted

Solution code:


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    D = read_ints()
    S = sum(D)
    answer = 0
    for d in D:
        S -= d
        answer += d*S
    return answer


if __name__ == '__main__':
    print(solve())

Submission status: Accepted

Solution code:
from itertools import accumulate

N=int(input())
d=[int(i) for i in input().split()]
hp=[]

for i in range(N):
    for j in range(N):
        if i>j:
            hp.append(d[i]*d[j])
l=list(accumulate(hp))
print(l[-1])

Submission status: Accepted

Solution code:
from itertools import combinations

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

ans = 0
for x, y in combinations(D, 2):
    ans += x * y

print(ans)

Submission status: Accepted

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

ans = 0
for i in range(n):
  for ii in range(i+1, n):
    ans += l[i]*l[ii]

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
d=[int(x) for x in input().rstrip().split()]

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

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
sum_mul = sum(d)

recovery = 0
for i in range(n):
    sum_mul -= d[i]
    recovery += d[i] * sum_mul

print(recovery)

Submission status: Accepted

Solution code:
import itertools

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

recovery = 0
for i in itertools.combinations(range(n), 2):
    recovery += d[i[0]] * d[i[1]]
print(recovery)

Submission status: Accepted

Solution code:
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
import math
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math as M
MOD=10**9+7
import sys
#####################################
n=int(input())
A=INPUT()
s=0
for i in range(n):
    for j in range(i+1,n):
        s+=A[i]*A[j]
print(s)

Submission status: Accepted

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

from  itertools import combinations

ans = 0
for x, y in combinations(d, 2):
    ans += x*y
print(ans)

Submission status: Accepted

Solution code:
# abc143_b.py
# https://atcoder.jp/contests/abc143/tasks/abc143_b

# B - TAKOYAKI FESTIVAL 2019 /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# たこ焼きフェスティバル (たこフェス) の季節がやってきました！
# 今年のたこフェスでは N個のたこ焼きがふるまわれる予定です。このうち i 個目のたこ焼きのおいしさは diです。
# ところで、おいしさが xと y であるたこ焼きを一緒に食べると、体力が x×y回復することが一般に知られています。
# たこフェスでふるまわれる N個のたこ焼きから、2 個を選ぶ方法は N×(N−1)2通り考えられます。
# そのそれぞれについて、一緒に食べたときの体力の回復量を求めて、その総和を出力してください。

# 制約
#     入力は全て整数である。
#     2≤N≤50
#     0≤di≤100

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# d1 d2 ... dN

# 出力
# たこフェスでふるまわれる N個のたこやきから、2個を選んで一緒に食べたときの体力の回復量の総和を出力せよ。

# 入力例 1
# 3
# 3 1 2

# 出力例 1
# 11

# 以下の 3通りの食べ方が考えられます。
#     1, 2個目のたこ焼きを選んで一緒に食べる。このとき、体力の回復量は 3である。
#     2, 3個目のたこ焼きを選んで一緒に食べる。このとき、体力の回復量は 2である。
#     1, 3個目のたこ焼きを選んで一緒に食べる。このとき、体力の回復量は 6である。

# 体力の回復量の総和は 11です。

# 入力例 2
# 7
# 5 0 7 8 3 3 2

# 出力例 2
# 312


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = 0
    for i in range(N-1):
        for j in range(i+1, N):
            log(f'i=[{i}], j=[{j}]')
            result += values[i] * values[j]
            # log(f'result=[{result}]')

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['3', '3 1 2']
        lines_export = [11]
    if pattern == 2:
        lines_input = ['7', '5 0 7 8 3 3 2']
        lines_export = [312]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input());a=list(map(int,input().split()));print(sum([a[i]*a[j] for i in range(n) for j in range(i+1,n)]))

Submission status: Accepted

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

N = int(input())
d = list(map(int, input().split()))
dc = d[:]

ans = []

for i, v in enumerate(d):    
    for j, w in enumerate(dc):
        # print(i, j)
        if (i == j):
            continue        
        ans.append(v * w)

print(int(sum(ans)/2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import accumulate
n=int(input())
d=list(map(int,input().split()))
ans=0
for i in range(n):
  ans+=(list(accumulate(d))[-1]-d[i])*d[i]
print(ans//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations
n = int(input())
d = list(map(int, input().split()))
print(sum(d[i]*d[j] for i, j in combinations(range(n), 2)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations
N = int(input())
d = list(map(int,input().split()))
C = list(combinations(range(0,N),2))

ans = 0
for x,y in C:
  ans += d[x] * d[y]

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
#a, b = map(int, input().split())
l = list(map(int, input().split()))

ans = 0
for i in range(n):
    for j in range(n):
        if i < j:
            ans = ans + l[i] * l[j]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# cook your dish here
import sys
def file():
	sys.stdin = open('input.py', 'r')
	sys.stdout = open('output.py', 'w') 
#file()	
def main(N, arr):

	#initialising with positive infinity value
	maxi=float("inf")

	#initialising the answer variable
	ans=0

	#iterating linesrly
	for i in range(N):

		#finding minimum at each step
	    maxi=min(maxi,arr[i])
	    #increasing the final ans
	    ans+=maxi
	    print("dhh")

    #returning the answer
	return ans
        

if __name__ == '__main__':

	#length of the array
	'''N = 4

	#Maximum size of each individual bucket
	Arr = [4,3,2,1]

	#passing the values to the main function
	answer = main(N,Arr)

	#printing the result
	print(answer)'''
	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)

Submission status: Accepted

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
sum=0
for i in range(0,len(a)-1):
    for j in range(i+1,len(a)):
        sum=sum+(a[i]*a[j])
print(sum)

Submission status: Accepted

Solution code:
N=int(input())
List = list(map(int, input().split()))
wa = 0
for i in range(N):
  for j in range(N):
    if j == i:
      pass
    else:
      wa += List[i]*List[j]
wa = wa //2
print(wa)

Submission status: Accepted

Solution code:
N=int(input())
d=list(map(int,input().split()))
ans=0
for x in range(N):
  for y in range(x+1,N):
    ans += d[x]*d[y]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N=int(input())
D=list(map(int,input().split()))
print(sum(d*cumulate for d,cumulate in zip(D[1:],itertools.accumulate(D))))

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int,input().split()))
print((sum(D)**2-sum(list(map(lambda x:x**2,D))))//2)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
D = list(input().split())
a = itertools.combinations(D,2)
sum= 0
for i,j in a:
    sum += eval("{} * {}".format(i,j))
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
d=l()

for i in itertools.combinations(d,2):
    ans += i[0]*i[1]

print(ans)

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    D = list(map(int, input().split()))
    ans = 0
    import itertools
    for x, y in itertools.combinations(D, 2):
        ans += x*y
    print(ans)

if '__main__' == __name__:
    resolve()

Submission status: Accepted

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