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: Runtime Error

Solution code:
import copy

def j(n):
    if n:print("yes")
    else:print("no")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

n = ip()
a = iprow()
s = 0
for i in range(n-1):
    for k in range(i+1,n):
        s+=a[i]*a[j]
print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
input()
takos1 = input()
takos = takos1.split(' ')
hp = 0

for i in range(len(takos)-1):
    for j in range(len(takos)-i-j):
        hp += int(takos[i]) * int(takos[i+j]+1)
    
print(hp)

Submission status: Runtime Error

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

for x in range(N):
  for y in range(x+1,N):
    ans += D[x] * D[y]

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

recover = []

c = 0
for i in d:
    c += 1
    recover.append(i * sum(d[c:N]))

print(sum(recover))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

kazu = list(len(d))

for n in kazu:
  for i in map(d[n-1]*d[n]):
    kaihuku = sum(i)
    
print(kaihuku)

Submission status: Runtime Error

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

point_sum = 0

for n in range(N):
    head = d.pop(0)
    point_sum += sum(list(map(lambda x : x * head, d)))
    
print(point_sum)

Submission status: Runtime Error

Solution code:
N = str(input())
Ds = str(input()).split(" ")
answer = 0

for di in range(len(Ds)):
  for dii in range(di):
    sum = Ds[di] + Ds[dii] 
    answer += sum

print answer

Submission status: Runtime Error

Solution code:
N = int(input())

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

S = sum(d)

ans = 0

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

Submission status: Runtime Error

Solution code:
N = map(int, input())
takoyaki = map(int, input().split(" "))
takoyaki_list = [ i for i in takoyaki]
takoyaki = 0
deli_point = []
for i in takoyaki_list:
    point = i * takoyaki
    takoyaki = i
    deli_point.append(point)
print(deli_point.sum())

Submission status: Runtime Error

Solution code:
N = int(input())

d = [int(input()) for i in range(N)]

point_sum = 0

for n in range(N):
    head = d.pop(0)
    point_sum += sum(list(map(lambda x : x * head, d)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
d=[input() for i in range(N)]
s=0
for i in range(0,len(d)):
  t=0
  for j in range(0,len(d)):
    t+=d[i]*d[j]
  s+=t
print(s)

Submission status: Runtime Error

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

d_sum = sum(d)

m = 0
for k in d:
    m += k **2
    
print((d_sum**2 - m)　//　2)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())

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

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

print(s)

Submission status: Runtime Error

Solution code:
from itertools import combinations
import sys
sys.setrecursionlimit(10**6)

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

comb = list(combinations(d, 2))
ans = 0

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

print(ans)

Submission status: Runtime Error

Solution code:
import itertools
n = int(input())
li = list(map(int,input().split()))
i = n*n-1
tako = list(itertools.combinations(li,2))
print(tako)
ans = 0
for num in range(n):
  ans += (tako[num][0])*(tako[num][1])
print(ans)

Submission status: Runtime Error

Solution code:
Last login: Fri Oct 18 22:40:34 on ttys000

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python a.py
  File "a.py", line 3
    s = A - 2B
             ^
SyntaxError: invalid syntax
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python a.py
12 4
Traceback (most recent call last):
  File "a.py", line 1, in <module>
    A, B = map(int, input().split)
TypeError: 'builtin_function_or_method' object is not iterable
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python a.py
12 4
4
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ vim k.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python k.py
(2, 3, 4)
nakamurashuntaMacBook-Pro:~ n.shunta$ vi k.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python k.py
4
nakamurashuntaMacBook-Pro:~ n.shunta$ rm k.py
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python a.py
  File "a.py", line 17
    for r in data
                ^
SyntaxError: invalid syntax
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python a.py
3
3 1 2
22
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python a.py
3
3 1 2
(3, 1)
(3, 2)
(1, 3)
(1, 2)
(2, 3)
(2, 1)
22
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python a.py
  File "a.py", line 9
    for i in itertools.combinations(box, 2)
                                          ^
SyntaxError: invalid syntax
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python a.py
3
3 1 2
(3, 1)
(3, 2)
(1, 2)
11
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py

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

import itertools

boxes = []
data = []

for i in itertools.combinations(box, 2): 
    boxes.append(i)

for k in boxes:
    data.append(k[0] * k[1])

i = 0 

for r in data:
    i = r + i 

print(i)

Submission status: Runtime Error

Solution code:
n = int(input())
d = set(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: Runtime Error

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

s = int(0)
s += d[0] * d[n]

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

print(s)

Submission status: Runtime Error

Solution code:
from itertools import combinations

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

comb = list(combinations(d, 2))
ans = 0

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

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 0
while len(d) > 1:
    current = d[0]
    for y in range(len(d)):
        ans += current * d[y]
#         print(ans)
    ans -= current ** 2
    d.pop(0)
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

s = int(0)

s += d[0] * d[n]


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

print(s)

Submission status: Runtime Error

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: Runtime Error

Solution code:
import unittest

from A02 import solve
from A02 import parse_input

class TestA02Solve(unittest.TestCase):


    def test_solve(self):
        lines_as_string = """
3
3 1 2
"""
        r = parse_input(lines_as_string)
        for i, e in enumerate(r):
            print("e[%d]=%s" % (i, e))
        print("")
        self.assertEqual(solve(*r), 11)

        lines_as_string = """
7
5 0 7 8 3 3 2
"""
        r = parse_input(lines_as_string)
        for i, e in enumerate(r):
            print("e[%d]=%s" % (i, e))
        print("")
        self.assertEqual(solve(*r), 312)

if __name__ == '__main__':
    unittest.main()

Submission status: Runtime Error

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

total = 0

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


print(total)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution 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

Submission status: Runtime Error

Solution code:
n = int(input())
d = [int(i) for input().split()]
s = []
for i in range(n):
	for j in range(i):
		s.append(d[i]*d[j])
l = s.size()
for i in range(l):
	print(s[i])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n= int(input())
a=list(map(int,input().split()))
i=0
j=0
p=0
while(i<len(a)):
  j=i+1
  s=0
  while(j<len(a)):
    s=s+a[j]
   	j=j+1
  p=p+s*a[i]
  i=i+1
print(p)

Submission status: Runtime Error

Solution code:
n = int(stdin.readline().rstrip())
d = stdin.readline().rstrip().split()
res = 0
count1 = 0
for el1 in d:
    count2 = 0
    for el2 in d:
        if (count2 > count1):
            res += int(el1) * int(el2)
        count2 += 1
    count1 += 1

print(res)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
d = [int(i) for input().split()]
s = []
for i in range(n):
	for j in range(i):
		s.append(d[i]*d[j])
n = s.size()
for i in range(n):
	print(s[i])

Submission status: Runtime Error

Solution code:
N = int(input())
tako = []
ans = 0
for i in N:
  tako.append(int(input()))
for j in range(len(tako)-1):
  ans += tako[j]*tako[j+1]
ans += tako[1] * tako[-1]
print(ans)

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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