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:
N = int(input())
d = list(map(int, input().split()))
s = sum(d)
ans = s**2
for i in range(N):
    ans-=d[i]**2
print(ans//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
import sys

input = sys.stdin.readline


def read_i():
    return list(map(int, input().split()))


def read_is(n=1):
    return [read_i() for _ in range(n)]


n = int(input())
ls = read_i()
res = 0
for x, y in itertools.combinations(ls, 2):
    res += x * y
print(res)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20

N = int(input())
a = list(map(int,input().split()))
ans = 0
for x,y in itertools.combinations(a,2):
    ans += x*y
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
dlist=list(int(i) for i in input().split())

kotae=0

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

print(kotae//2)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#ABC143 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
d = LI()
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:
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:
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Last Modified: 19/Oct/2019 05:32:47 PM


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    n = int(input())
    arr = get_array()
    ans = 0
    for i in range(n):
        for j in range(i + 1, n):
            ans += arr[i] * arr[j]
    print(ans)


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def get_array():
    return list(map(int, sys.stdin.readline().split()))


def get_ints():
    return map(int, sys.stdin.readline().split())


def input():
    return sys.stdin.readline().strip()


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def slove():
    import sys
    import itertools
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    d = list(map(int, input().rstrip('\n').split()))
    t = 0
    for v in itertools.combinations(d, 2):
        t += (v[0] * v[1])
    print(t)


if __name__ == '__main__':
    slove()

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 sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()

# int(input())
# map(int, input().split())

n = int(input())
d = tuple(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:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
D = list(map(int, sys.stdin.readline().split()))

ans = 0
for i, j in itertools.product(range(N), range(N)):
    if i < j:
        ans += D[i] * D[j]
print(ans)

Submission status: Accepted

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

total = 0

for i in range(n):
    for j in range(i):
        total += arr[i]*arr[j]

print(total)

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

        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:
N = int(input())
d = [int(i) for i in input().split()]

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

Submission status: Accepted

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

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:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))
S = sum(L)

ans = 0
for l in L:
    ans += l*(S-l)
    S -= l
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:
from itertools import combinations

N = int(input())
*D, = 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())
a_list = list(map(int, input().split()))

ans = 0

for i in range(N):
    for j in range(i+1, N):
        if i == j:
            continue
        else:
            ans += a_list[i] * a_list[j]
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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:
import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

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

    ans = 0
    for d1 in D:
        for d2 in D:
            ans += d1 * d2

    for d in D:
        ans -= d * d

    print(ans // 2)


sol()

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def main():
    n = ni()
    d = na()

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

main()

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
import sys
import heapq
import math

# input = sys.stdin.readline

sys.setrecursionlimit(1000000000)

MIN = -10 ** 9
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    d = [int(a) for a in input().split()]
    # H = [int(a) for a in input().split()]
    # xy = [
    #     [int(a) for a in input().split()]
    #     for _ in range(N)
    # ]
    s = 0
    for i in range(len(d)):
        for j in range(i + 1, len(d)):
            s += d[i] * d[j]
    print(s)


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 - 1):
  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 = [int(i) for i in 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:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, d: "List[int]"):

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

    return


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())
da=list(map(int,input().split()))
ans=0
for i in range(n):
    ans+=da[i]
ans*=ans
for i in range(n):
    ans-=da[i]**2
print(ans//2)

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N = I()
d = III()

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)

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

main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# input=lambda :sys.stdin.readline().rstrip()
def resolve():
    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)
resolve()

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

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    d = LI()
    ans = 0
    for i in range(n):
        for j in range(i):
            ans += d[i]*d[j]
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

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:
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
d = map(int, raw_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: Runtime Error

Solution code:
N = int(input())
d = [int(i) for i in 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: Runtime Error

Solution code:
n=int(input())
l=list(map(int,input().split()))
c=itertools.combinations(l,2)
ans=sum(x*y for x,y in c)
print(ans)

Submission status: Runtime Error

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

s = 0

for i in range(n):
  for j in range(n):
    if i < j:
      s += (di[i],di[j])

print(s)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

print(sam)

Submission status: Runtime Error

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

for i in range(n):
  for j in range(n):
if i ! = j:      
s = 0
s += (di[i] + di[j-1])/2

print(s)

Submission status: Runtime Error

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

for i in range(n):
  for j in range(n):
      
s = 0
s += (di[i] + di[j-1])/2

print(s)

Submission status: Runtime Error

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

for i in range(n):
  for j in range(n-1):
      
s = 0
s += (di[i] + di[j])/2

print(s)

Submission status: Runtime Error

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

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

print(sam)

Submission status: Runtime Error

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

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

print(sam)

Submission status: Runtime Error

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

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

print(sam)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys
import numpy as np

INF = float('inf')


def solve(N: int, d: "List[int]"):
    return sum(x * y for x, y in its.combinations(d, 2))


def main():

    sys.setrecursionlimit(10 ** 6)

    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]"
    print(f'{solve(N, d)}')


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from itertools import combinations

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

print(sum(d[a]*d[b] for a, b in combinations(range(n), 2)))

Submission status: Runtime Error

Solution code:
from itertools import combinations

n = int(input())
d = mapt(int, input().split(" "))

print(sum(d[a]*d[b] for a, b in combinations(range(n), 2)))

Submission status: Runtime Error

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

Solution code:
N=int(input())
List = list(map(int, input().split()))
wa = 0
k = 0
for i in range(N):
  if i + 1 == N:
    wa += List[0]*List[N-1]
  else:
    wa += List[i]*List[i+1]
print(res)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
import time
import math
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N = int(input())
d = [int(input()) for _ in range(N)]
ans = 0
for i in range(N-1):
	for j in range(i+1, N):
		ans += d[i] * d[j]
print(ans)
	

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from itertools import combinations

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

c=combinations(d,2)
print(d)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import itertools


def actual(n, D):
    comb = itertools.combinations(D, 2)

    # return sum([x * y for x, y in comb])

    """
    「順番を考慮しない2要素の選び方」を全探索する際のポイント
        内側のループ変数の始点を外側のループ変数 +1 から始めるとよい。
        これにより、内側のループで選ぶインデックスが必ず外側のループで選ぶインデックスより大きくなり、
        同じ選び方を 2 回見てしまうことを回避できます。"""
    s = 0
    for i in range(len(D)):
        for j in range(i + 1, len(D)):
            s += D[i] * D[j]

    return s

n = int(input())
s = input()

print(actual(n, s))

Submission status: Runtime Error

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


def combinations(d, tmp_out, i, j):
    if (j >= N):
        i += 1
        j = i + 1
        if (i >= N):
            return tmp_out
        elif (j >= N):
            return tmp_out
    if (j >= N) or (i >= N):
        return tmp_out
    else:
        tmp_out += d[i] * d[j]
        return combinations(d, tmp_out, i, j + 1)


out = combinations(d, 0, 0, 1)

print(out)

Submission status: Runtime Error

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


def combinations(d, tmp_out, i, j):
    if (i >= N):
        return tmp_out
    elif (j >= N):
        i += 1
        j = i + 1
        if (i >= N):
            return tmp_out
        elif (j >= N):
            return tmp_out
    tmp_out += d[i] * d[j]

    return combinations(d, tmp_out, i, j + 1)


out = combinations(d, 0, 0, 1)

print(out)

Submission status: Runtime Error

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


def combinations(d, tmp_out, i, j):
    if (j >= N):
        i += 1
        j = i + 1
        if (i >= N):
            return tmp_out
        elif (j >= N):
            return tmp_out
    tmp_out += d[i] * d[j]

    return combinations(d, tmp_out, i, j + 1)


out = combinations(d, 0, 0, 1)

print(out)

Submission status: Runtime Error

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


def combinations(d, out, i, j):
    if (j >= N):
        i += 1
        j = i + 1
        if (i >= N):
            return out
        else:
            if (j >= N):
                return out
    out += d[i] * d[j]

    return combinations(d, out, i, j + 1)


out = combinations(d, 0, 0, 1)

print(out)

Submission status: Runtime Error

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


def combinations(d, out, i, j):
    if (j >= N):
        i += 1
        if (i >= N):
            return out
        else:
            j = i + 1
            if (j >= N):
                return out
    out += d[i] * d[j]

    return combinations(d, out, i, j + 1)


out = combinations(d, 0, 0, 1)

print(out)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i< (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  int ans = 0;
  rep(i, n) for (int j = i+1; j<n; ++j) {
    ans += d[i]*d[j];
  }
  cout << ans << endl;
  return 0;
  }

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans = 0
for i in range(N):
    for i in range(i+1,N):
        ans += i*J

print(ans)

Submission status: Runtime Error

Solution code:
import itertools

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

list_ = itertools.combinations(range(n),2))
count = 0;

for i in range(len(list_)):
  count += D[list_[i][0]] + D[list_[i][1]];
  
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n = int(input())

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

s = 0

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

Submission status: Runtime Error

Solution code:
import sys
n = int(sys.stdin.radline())
li = list(map(int, sys.stdin.readline().split()))
s = 0
i = 0
while i < n-1:
  s += li[i] * li[i+1]
  i += 1
print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution 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(d[i]*d[j])
print(sum(wa))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
d = list(map(int,input().split()))
 
dd = 0
for i in range(n):
	for j in range((i+1),n):
		if i==j:
			continue
		dd += (d[i]*d[j])
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((i+1),n):
    if i==j:
      continue
     ans += (d[i]*d[j])
print(ans)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
if 1<= a <=9 or 1<= b <=9:
    print(b)
else:
    print(0)

Submission status: Runtime Error

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

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(n):
        if i != j:
            sum += d[i] * d[J]

sum = sum // 2

print(sum)

Submission status: Runtime Error

Solution code:
from itertools import *
n = int(input())
d = list(map(int,input().split()))
ans = 0
for i,j in comninations(d,2):
  ans += i*j
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from functools import reduce
import collections

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

ans = 0
for i in range(N):
    ans += reduce(mul, D)
    queue.popleft()
print(ans)