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:
def solve(inp):
    N = int(inp.readline().strip())
    D = list(map(int, inp.readline().strip().split(' ')))

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

    return str(r)


def test(s):
    from io import StringIO
    print(solve(StringIO(s)))


def main():
    import sys
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    # test('50\n' + '100 ' * 50)
    main()

Submission status: Accepted

Solution code:
n = int(input())
total = 0
takos = [int(i) for i in input().split()]
for _ in range(n - 1):
    curr = takos.pop(0)
    total += curr * sum(takos)

print(total)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, d: "List[int]"):
    p = 0
    for i in range(N):
        for j in range(i+1,N):
            p = p + d[i] * d[j]
    print(p)
        
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a=int(input())
import itertools 
b=list(map(int,input().split()))
c=0
for d,e in itertools.combinations(b,2):
  c+=d*e
print(c)

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

Solution code:
N = int(input())
d=list(map(int, input().split()))
 
toori=int((N*(N-1))/2)
p=1
k=0
list_x=[0]*toori
for i in range(N):
  for j in range(N-i-1):
    list_x[(k)]=d[i]*d[p]
    p=p+1
    k=k+1
  p=i+2
kaihuku=0
for i in range(toori):
  kaihuku=kaihuku+(list_x[i])
print(kaihuku)

Submission status: Accepted

Solution code:

n = int(input())

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

a = []
ans = 0

for i in range(n):
	for j in range(n):
		if i == j:
			pass
		else:
			ans += d[i]*d[j]
		
print(int(ans/2))

Submission status: Accepted

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

print(recovery)

Submission status: Accepted

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

total = sum(d) ** 2
for i in range(n):
    total -= d[i]**2

print(total // 2)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0

for i in range(N):
    for j in range(N):
        ans += list[i]*list[j]

for i in range(N):
    ans += -list[i]**2

print(int(ans/2))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())
d=list(map(int,input().split()))
flag=0
buf=0
squaresum=0
for i in range(N):
   for j in range(N):
      buf=buf+d[i]*d[j]
   squaresum=squaresum+d[i]*d[i]

print(int((buf-squaresum)/2))

Submission status: Accepted

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

print(S)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
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())
T = list(map(int, input().split()))
S = 0
for i in range(n):
    for j in range(i+1, n):
        S += T[i]*T[j]

print(S)

Submission status: Accepted

Solution code:
N = int(input())
list_d = list(map(int, input().split()))
len_d = len(list_d)
list_2d = []

for i in range(len_d-1):
    for j in range(i+1,len_d):
        recovery = list_d[i] * list_d[j]
        list_2d.append(recovery)

print(sum(list_2d))

Submission status: Accepted

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

ans = 0
for i, j in enumerate(d):
    for k, l in enumerate(d):
        if i > k:
            ans += j * l
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
D = list(map(int, input().split()))
from itertools import combinations as cm
total = 0
for pair in cm(D, 2):
  total += pair[0] * pair[1]
print(total)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
*A, = map(int, input().split())
print(sum([x*y for x, y in list(itertools.combinations(A, 2))]))

Submission status: Accepted

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

heal = 0
for x in range(n):
    for y in range(n):
        if x == y:
            pass
        else:
            heal += (a[x] * a[y]) / 2

print(int(heal))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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


ans = 0

for i,j in itertools.combinations(range(N),2):
    ans += d[i]*d[j]

print(ans)

Submission status: Accepted

Solution code:
import itertools

n = int(input())
dList = list(itertools.combinations(list(map(int,input().split())),2))

hp = 0
for i in dList:
  hp += i[0]*i[1]

print(hp)

Submission status: Accepted

Solution code:
n=int(input())
d=[int(i) for i in input().split()]
s=0
for i in range(len(d)):
    if d[i]==0: continue
    else: s+=sum([d[i]*d[k] for k in range(i+1,len(d))])
print(s)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
d = LIST()
a = 0

c = list(combinations(d, 2))
# print(c)
for l in c:
  a += l[0] * l[1]
print(a)

Submission status: Accepted

Solution code:
N = int(input())
delicious = [0] * N
delicious = list(map(int, input().split()))
total = 0

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

print(total)

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,N-1):
       power+=D[i]*D[j+1]
print(power)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import accumulate

_ = int(input())
d = tuple(map(int, input().split()))
a = tuple(accumulate(reversed(d)))[::-1]
print(sum(dd * aa for dd, aa in zip(d, a[1:])))

Submission status: Accepted

Solution code:
from itertools import accumulate

_ = int(input())
d = tuple(map(int, input().split()))
a = tuple(reversed(tuple(accumulate(reversed(d)))))
print(sum(dd * aa for dd, aa in zip(d, a[1:])))

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,N-1):
        ans += D[i] * D[j+1] 
print(ans)

Submission status: Accepted

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

arr = []
for i in range(n-1):
    for j in range(i,n):
        if i == j:
            pass
        else:
            arr.append(d[i] * d[j])

print(sum(arr))

Submission status: Accepted

Solution code:

def ABC143B():
    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)

ABC143B()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

sum = 0
for x in range(n):
    for y in range(n):
        if x != y: sum += l[x] * l[y]

print(int(sum/2))

Submission status: Accepted

Solution code:
N = int(input())
d = [int(x) for x in input().split()]
res = 0
for count in range(len(d)-1):
    fd = d[count]
    for e in d[count+1:]:
        res += fd * e
print(res)

Submission status: Accepted

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

s = 0

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

print(sum(x*y for x, y in combinations(dn, 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(N-i-1):
        k = j + i + 1
        #print(i,k)
        ans += A[i]*A[k]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

N = int(input())
d_s = LI()

count = 0
for x,y in itertools.combinations(d_s,2):
  count+=x*y
  
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
s=sum(l)
ans=0
for i in l:
    ans+=(s-i)*i
print(ans//2)

Submission status: Accepted

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n = int(input())
ddd = get_nums_l()

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

print(ans)

Submission status: Accepted

Solution code:
import sys
from itertools import combinations

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


def main():
    _ = INT()
    D = LIST()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, *d = map( int, open(0).read().split())

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

Submission status: Accepted

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

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

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):
        recovery_amount = d[i] * d[j]
        sum += recovery_amount
print(sum)

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())
numbers = list(map(int, input().split()))

r = 0

for i, x in enumerate(numbers[:-1]):
  for y in numbers[i+1:]:
    r += x * y

print(r)

Submission status: Accepted

Solution code:
import itertools

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

d_com = list(itertools.combinations(d_l, 2))

d_sum = 0
for x in range(len(d_com)):
    d_sum += d_com[x][0] * d_com[x][1]
print(d_sum)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    num_list = list(map(int, input().split()))

    result = 0

    for i in range(n):
        for j in range(n):
            if i == j or i > j:
                continue
            result += num_list[i] * num_list[j]

    print(result)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
    for j in range(N):
        if i>j:
            oishisa=oishisa+d[i]*d[j]
        else:
            pass

print(oishisa)

Submission status: Accepted

Solution code:
a = int(input())
list = list(map(int, input().split()))
sum = 0

for i in range(a):
  for j in range(i+1,a):
    sum += list[i]*list[j]
    
print(sum)

Submission status: Accepted

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

res = 0
for i, di in enumerate(ds):
    for h in range(i + 1, N):
        res += di * ds[h]

print(res)

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

Submission status: Accepted

Solution code:
import itertools

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)
    return 0
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:
def calc_double(n):
    return n ** 2

n=int(input())
L=list(map(int,input().split()))
L2=list(map(calc_double,L))
print((sum(L)**2-sum(L2))//2)

Submission status: Accepted

Solution code:
n=int(input())
dlis=list(map(int,input().split()))
rlis=[]
for i in range(n):
	for j in range(n):
		if i<j:
			r=dlis[i]*dlis[j]
			rlis.append(r)
print(sum(rlis))

Submission status: Accepted

Solution code:
def main():

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a = int(input())
d = list(map(int,input().split()))
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ds = input().split(" ")
rec = 0
for i in range(0, len(ds) - 1):
  di = int(ds[i])
  for j in range(i+1, len(ds)):
    dj = int(ds[j])
    rec += di * dj
print(rec)

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

# N = int(readline())
# D = [int(d) for d in readline().split()]

import itertools

N, *D = map(int, read().split())
# Dcum = itertools.accumulate(D)

S = sum(D)
T = sum([x * x for x in D])

ans = (S * S - T) // 2
print(ans)

# ans = 0
# for i in range(N):
#     for j in range(N):
#         if j <= i:
#             continue
#         ans += D[i] * D[j]
#
# print(ans)

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
D = [int(d) for d in readline().split()]

ans = 0
for i in range(N):
    for j in range(N):
        if j <= i:
            continue
        ans += D[i] * D[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(int(sum))

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 = sum +d[i]*d[j]
print(int(sum/2))

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

Solution code:
def main():
    from itertools import combinations 
    n = int(input())
    d = list(map(int, input().split()))

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

    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
d = [int(s) for s in input().split(' ')]

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import numpy as np

_ = input()
i = list(map(int, input().split()))

A = np.matrix(i)
mat = np.dot(A.T, A)

print(np.tril(mat, k = -1).sum())

Submission status: Accepted

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

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

Submission status: Accepted

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

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

ans = 0
d_sum = sum(d)

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

print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

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

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
#print(a)
y=[]
for i in range(n-1):
    for j in range(i+1,n):
        y.append(a[i]*a[j])
v=0
for k in y:
    v=v+k
print(v)

Submission status: Accepted

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

sum = 0
i = 0
while i<n:
    j = i + 1
    while j<n:
        sum += int(d[i]) * int(d[j])
        j+=1
    i+=1

print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    A = list(map(int,input().split()))
    
    ans = 0
    for i in range(N):
        for j in range(N-i-1):
            ans += A[i]*A[i+j+1]
            
    print(ans)
        
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(raw_input())
ds = map(int, raw_input().split())
t = 0
for i in range(n):
  for j in range(i+1, n):
    t += ds[i] * ds[j]
print(t)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
from itertools import permutations
n = int(input())
li = list(map(int, input().split()))
x = 0
for j in permutations(range(n), 2):
    x += li[int(j[0])] * li[int(j[1])]

print(x//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N = int(input())
d = [i for i in map(int,input().split())]
ans = 0
for combi in itertools.combinations(d,2):
  ans += combi[0]*combi[1]
  
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
d = [int(i) for i in 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())
nums = list(map(int, input().split()))
ans = []
for i in range(n):
    for j in range(i+1,n):
        ans.append(nums[i] * nums[j])
print(sum(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:
from sys import stdin
import sys
##  input functions for me
def ria(sep = ''):
    if sep == '' :
        return list(map(int, input().split())) 
    else: return list(map(int, input().split(sep)))
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    N = ri()
    D = ria()

    s = sum(D)
    s *= s
    d = sum(map(lambda x: x * x, D))
    print((s - d) //2)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
ds = [int(i) for i in input().split()]

len_ds = len(ds)
s = 0

# あえてitertoolsを使わないで解く
for i in range(len_ds-1):
    for j in range(i+1, len_ds):
        s += ds[i] * ds[j]
print(s)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    ll = input().split(" ")
    d = []
    result = 0
    for l in ll:
        d.append(int(l))
    for i in range(N):
        for j in range(i + 1, N):
            result += d[i] * d[j]
    print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import itertools

n = int(input())
d_lst = list(map(int,input().split()))
pair_lst = list(itertools.combinations(d_lst,2))

ans = 0
for i in range(len(pair_lst)):
    num = pair_lst[i][0]*pair_lst[i][1]
    ans += num
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 = int(input())
d = list(map(int, input().split()))

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
ans = 0
sq = 0
for i in d:
	ans += i
	sq += i ** 2
ans = ans ** 2
ans -= sq
ans //= 2
print(ans)

Submission status: Accepted

Solution code:
# TAKOYAKI FESTIVAL2019

# libraries
from itertools import combinations

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

# solve
res = 0
for i, j in combinations(range(N), 2):
    res += d[i] * d[j]

# output
print(res)

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:
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()))
res = 0
for i in range(n):
    for j in range(i+1, n):
        res += d[i]*d[j]
print(res)

Submission status: Accepted

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

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(n-1-i):
  ans += l[i]*l[i+1+j]
print(ans)

Submission status: Accepted

Solution code:
import itertools

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

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

Submission status: Accepted

Solution code:
import itertools

n = int(input())
d = [int(x) for x in input().split()]

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

print(sum)

Submission status: Accepted

Solution code:
n = int(input())
d_list = list(map(int,input().split()))
print((sum([i*j for i in d_list for j in d_list])-sum([k**2 for k in d_list]))//2)

Submission status: Accepted

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

sum_takos = sum(takos[1:])

result = 0

for i in range(N - 1):
  result += sum_takos * takos[i]
  sum_takos -= takos[i + 1]
  
print(result)

Submission status: Accepted

Solution code:
N = int(input())
D = input()
d = D.split()
for i in range(N):
        d[i] = int(d[i])

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

Submission status: Accepted

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

answers = [d_n[i]*d_n[j] for i in range(N-1) for j in range(i+1,N)]

#print(answers)

print(sum(answers))

Submission status: Accepted

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

import itertools

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sum = 0
n = int(input())
d_list = list(map(int,input().split()))

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

Submission status: Accepted

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

total = 0

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

print(total)

Submission status: Accepted

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

print(int(s/2))

Submission status: Accepted

Solution code:
n = int(input())
li = input().split()

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

Submission status: Accepted

Solution code:
import itertools

N = int(input())
d_list = input().split(" ")

sum = 0

for i, j in itertools.combinations(d_list, 2):
    sum += int(i) * int(j)

print(sum)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
p = sum(d)
q = sum([pow(x,2) for x in d])
print((pow(p,2)-q)//2)