TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
import numpy as np

N = int(input())
A = np.asarray(input().split()).astype(np.int)

a = np.tile(A,(N, 1))
a = a * a.T

a_diag = np.diag(a).sum()
a = ((a.sum()-a_diag)/2)
#print(a/10e9+7)
print(int(np.mod(a, 10**9+7)))

import numpy as np

N = int(input())
A = np.asarray(input().split()).astype(np.int)
A_sq = np.square(A)

print(int(np.mod(((A.sum())*(A.sum())-A_sq.sum())/2, 10**9+7)))

import numpy as np

N = int(input())
A = np.asarray(input().split()).astype(np.int)
A_sq = np.square(A)
Ans = np.mod(((A.sum())**2 - A_sq.sum()) / 2 ,(10**9+7)).astype(np.int)
print(Ans) 

import numpy as np

N = int(input())
A = np.asarray(input().split()).astype(np.int)

ans = 0
for i in range(N):
    pA = A[i] * A[i+1:]
    ans += pA.sum()

print(int(ans % (1e9+7)))

import numpy as np

N = int(input())
A = np.asarray(input().split()).astype(np.int)
A_sq = np.square(A)
Ans = ((A.sum())**2 - A_sq.sum()) // 2 % (10**9+7)
print(Ans) 

import numpy as np
 
N = int(input())
A = np.asarray(input().split()).astype(np.int)
 
ans = 0
for i in range(N):
    pA = A[i] * A[i+1:].sum()
    ans += pA
 
print(int(ans % (10e9+7)))

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


ans = 0
B = [0] * (N + 1)

for i in range(N-1, -1, -1):
    print(i)
    B[i] = (B[i+1] + A[i]) % D

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

print(int(ans % D))

import numpy as np
A = np.asarray(input().split()).astype(np.int)
 
ans = 0
mod = 10**9 + 7
for i in range(N):
    pA = (A[i] % mod) * (A[i+1:].sum() % mod)
    ans += pA
 
print(int(ans % mod))

import numpy as np
N = int(input())
A = np.asarray(input().split()).astype(np.int)
 
ans = 0
mod = 10**9 + 7
for i in range(N):
    pA = (A[i] % mod) * (A[i+1:].sum() % mod)
    ans += pA
 
print(int(ans % mod))

A = np.asarray(input().split()).astype(np.int)
 
ans = 0
mod = 10**9 + 7
for i in range(N):
    pA = (A[i] % mod) * (A[i+1:].sum() % mod)
    ans += pA
 
print(int(ans % mod))

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


ans = 0
B = [0] * (N + 1)

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

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

print(int(ans % D))

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
import itertools

N = int(input())
A = list(int(x) for x in input().split())

mod = 10**9+7
ans = 0
summ = 0

for i in range(N):
    summ += A[i]
    summ %= mod

for i in range(N):
    summ -= A[i]
    print(summ)
    if summ < 0:
        sum += mod
    ans += A[i] * summ
    print(ans)
    ans %= mod
    print(ans)
print(ans)


import itertools

N = int(input())
A = list(int(x) for x in input().split())

mod = 10**9+7

sum_ = 0
ans = 0

for i in range(N):
    ans += sum_ * A[i]
    ans %= mod
    sum_ += A[i]
    sum_ %= mod

print(ans)


Verdicts: Runtime Error

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
N = int(input())
 
A = list(map(int, input().split()))
 
c = 0
 
for i in range(N-2):
  for j in range(int(i)+1, N):
    d = A[i] 
    e = A[j] 
    c = (c + d*e) % (10**9+7)
    
    
 
c = c % (10**9+7)
 
print(c)

N = int(input())

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

S = 0
for i in range(N):
  S += A[i]

c = S
d = 0
for j in range(N):
  c -= A[j]
  c = c%(10**9+7)
  d += A[j]*c
  d = d%(10**9+7)
  
print(d)

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
n=int(input())
A=list(map(int,input().split()))
Ar=list(itertools.accumulate(A))
ans=0
for i in range(n-1):
    ans+=A[i]*(Ar[n-1]-Ar[i])
    ans%=10**9+7
print(ans)

import itertools
#h,w=map(int,input().split())
#S=[list(map(int,input().split())) for _ in range(h)]
n=int(input())
A=list(map(int,input().split()))
Ar=list(itertools.accumulate(A))
ans=0
for i in range(n-1):
    ans+=A[i]*(Ar[n-1]-Ar[i])
    ans%=10**9+7
print(ans)


Verdicts: Runtime Error

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
ut())
A = list(input().split())
B = [int(a) for a in A]
x = 10**9+7
summation = sum((B[i] * (sum(B[j] for j in range(i+1,N)) % x)) % x for i in range(N-1)) % x
print(summation)

N = int(input())
A = list(input().split())
B = [int(a) for a in A]
x = 10**9+7
summation1 = sum(B) ** 2
summation2 = sum(b ** 2 for b in B)
summation = ((summation1 - summation2) // 2) % x
print(summation)


Verdicts: Runtime Error

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
l = input()
a = l.split(' ')

tmp = 0
tmp2 = 0

for i in range(n):
    tmp += int(a[i])

for i in range(n):
    tmp2 += int(a[i])*int(a[i])

print((tmp*tmp-tmp2)//2%1000000007)

m = 1000000007

N, *A = map(int, open(0).read().split())

result = 0
c = 0
for i in range(1, N + 1):
    result += c * A[N - i]
    result %= m
    c += A[N - i]
    c %= m
print(result)


Verdicts: Runtime Error

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
from C import ans


n = int(input())
n_list = [int(i) for i in input().split()]

s = sum(a**2 for a in n_list)
ans = sum(n_list) ** 2 - s

print((ans//2)%(10**9+7))

n = int(input())
n_list = [int(i) for i in input().split()]

s = sum(a**2 for a in n_list)
ans = sum(n_list) ** 2 - s

print((ans//2)%(10**9+7))

Verdicts: Runtime Error

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
int_n = int(input())
list_tmp = list(map(int, input().split()))

print(int_n, list_tmp)

int_sum = 0
int_divide = (10**9) + 7

for i in range(0, len(list_tmp) - 1):
  for j in range(i + 1, len(list_tmp)):
    #print(i, j)
    # print(list_tmp[i] * list_tmp[j])
    int_sum = ((int_sum + (list_tmp[i] * list_tmp[j])) % int_divide) #((list_tmp[i] * list_tmp[j]) )
#print(int_sum)
print(int_sum)


int_n = int(input())
list_tmp = list(map(int, input().split()))
 
int_sum = 0
int_divide = (10**9) + 7
int_sum_tmp = sum(list_tmp)

for i in range(0, len(list_tmp) - 1):
  int_sum_tmp = int_sum_tmp - list_tmp[i]
  int_sum = int_sum + (int_sum_tmp * list_tmp[i])
print(int_sum % int_divide)
#  for j in range(i + 1, len(list_tmp)):
#    if list_tmp[i] >= int_divide:
#      list_tmp_i = list_tmp[i]%int_divide
#    else:
#      list_tmp_i = list_tmp[i]
#      
#    if list_tmp[j] >= int_divide:
#      list_tmp_j = list_tmp[j]%int_divide
#    else:
#      list_tmp_j = list_tmp[j]    
#    

#    


#      
#print(int_sum)

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))
sum = 0
# temp1 = 0
# temp2 = 0
MOD = 1000000007
for i in range(0, N-1):
    A[i] = A[i] % MOD
print(A)
for i in range(0, N-1):
    for j in range(i+1, N):
        #print(i, j)
        temp1 = 0
        temp2 = 0
        temp3 = 0
        # temp1 = A[i] % MOD
        # temp2 = A[j] % MOD
        # temp3 = temp1 * temp2
        temp3 = (A[i] * A[j]) % MOD
        sum = (sum + temp3) % MOD

print(sum)

MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))
ans = 0
B = [0]*(N-1)
sumA = sum(A)
for i in range(1, N):
    sumA -= A[i-1]
    B[i-1] = sumA
for i in range(0, N-1):
    ans += A[i] * B[i]
    ans %= MOD
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))

sum=0

print(n)
print(a)

for i in range(n) :
  for j in range(n) :
    if i < j :
      sum += a[i]*a[j]
      sum = sum%1000000007

print(sum)

n = int(input())
a = list(map(int, input().split()))
ans = 0
r_wa = [a[0]]
for i in range(n) :
  if i>0 :
    r_wa.append(r_wa[i-1]+a[i])

for i in range(n-1) :
  ans += a[i]*(r_wa[n-1]-r_wa[i])
  ans = ans%1000000007
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
N = int(input())
A = []
A += list(map(int,input().split()))
S = 0
k = 0

B = A[1:N]   

C = []

Num = 0
Dum = 0
Gum = 0

for i in range(N-1):
    Num = i
    for j in range(Num+1):
        Dum += A[j]
    C.append(Dum)
    Dum = 0

for k in range(N-1):
    Gum += B[k] * C[k]

print(B)
print(C)
print(Gum % 1000000007)

N = int(input())
A = []
A += list(map(int,input().split()))
S = 0
k = 0

Dum = 0
Gum = 0

for i in range(0, N-1):
    Dum += A[i]
    Gum += Dum * A[i+1]

print(Gum % 1000000007)

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
n = int(input())
x = list(map(int, input().strip().split()))
sum=0
minsum=0
for i in range(0,n):
    minsum += x[i]
for i in range(0,n-1):
    minsum-=x[i]
    sum += x[i]*minsum
    print(sum)
    if(sum>10**9+7):
        sum%=(10**9+7)
print(sum)

n = int(input())
x = list(map(int, input().strip().split()))
sum=0
minsum=0
for i in range(0,n):
    minsum += x[i]
for i in range(0,n-1):
    minsum-=x[i]
    sum += x[i]*minsum
    if(sum>10**9+7):
        sum%=(10**9+7)
print(sum)

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
def findProductSum(A, n): 
      
    # calculating array sum (a1 + a2 ... + an) 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum = array_sum + A[i] 
  
    # calcualting square of array sum 
    # (a1 + a2 + ... + an)^2 
    array_sum_square = array_sum * array_sum 
  
    # calcualting a1^2 + a2^2 + ... + an^2 
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 
  
    # required sum is (array_sum_square - 
    # individual_square_sum) / 2 
    temp=int(array_sum_square - 
            individual_square_sum) / 2
    return temp%1000000007








list=list()
n=int(input())
for i in range(n):
	l=int(input())
	list.append(l)
print(findProductSum(list,n))	
	

def findProductSum(A, n): 
      
    # calculating array sum (a1 + a2 ... + an) 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum = array_sum + A[i] 
  
    # calcualting square of array sum 
    # (a1 + a2 + ... + an)^2 
    array_sum_square = array_sum * array_sum 
  
    # calcualting a1^2 + a2^2 + ... + an^2 
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 
  
    # required sum is (array_sum_square - 
    # individual_square_sum) / 2 
    temp=int(array_sum_square - 
            individual_square_sum) / 2
    return temp%1000000007








n = int(input())
l = list(map(int, input().split()))
print(findProductSum(l,n))	
	

def findProductSum(A, n): 
      
    # calculating array sum (a1 + a2 ... + an) 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum = array_sum + A[i] 
  
    # calcualting square of array sum 
    # (a1 + a2 + ... + an)^2 
    array_sum_square = array_sum * array_sum 
  
    # calcualting a1^2 + a2^2 + ... + an^2 
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 
  
    # required sum is (array_sum_square - 
    # individual_square_sum) / 2 
    temp=int(array_sum_square - 
            individual_square_sum) 
    temp=temp//2
    return temp%1000000007








n = int(input())
l = list(map(int, input().split()))
print(findProductSum(l,n))	
	

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
from itertools import combinations
import math
N = int(input())
A = list(map(int, input().split()))
mod = 1000000007

def add(a, b):
    return (a + b) % mod

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def cumsum(xs):
    result = [xs[0]]
    for x in xs[1:]:
        result.append(add(result[-1], x))
    return result

#N = int(input())
#C = input()
#D, T, S=map(int,input().split())
#C = []

#    C.append(list(map(int,input().split())))

inv = cumsum(list(reversed(A)))
c = 0
for i in range(0,N-1):
    print(N-i-2)
    c = add(c,mul(A[i],inv[N-i-2]))

print(c)


from itertools import combinations
import math
N = int(input())
A = list(map(int, input().split()))
mod = 1000000007

def add(a, b):
    return (a + b) % mod

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def cumsum(xs):
    result = [xs[0]]
    for x in xs[1:]:
        result.append(add(result[-1], x))
    return result

#N = int(input())
#C = input()
#D, T, S=map(int,input().split())
#C = []

#    C.append(list(map(int,input().split())))

inv = cumsum(list(reversed(A)))
c = 0
for i in range(0,N-1):
    c = add(c,mul(A[i],inv[N-i-2]))

print(c)


Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))

for i in range(N-1): 
	for	j in range(i+1, N):
		t = A[i]*A[j] % (10**9+7)
		sum = sum(t)

print(sum)

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

for i in range(N-1) and j in range(i+1, N):
	t = A[i]*A[j] % (10**9+7)
	sum = sum(t)

print(sum)

#N = int(input())
#A = list(map(int, input().split()))
n, a = input().split("\n")
N = int(n)
A = list(map(int, a.split()))

mod = 7 + 10**9
s = 0

for i in range(N-1): 
	for	j in range(i+1, N):
		t = A[i] * A[j] % mod
		s += t

ans = s % mod
print(ans)

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

mod = 7 + 10**9
for i in A:
	A[i] %= mod
for j in range(N-1): 
	for	k in range(j+1, N):
		t = A[j] * A[k] 
		ans += t

ans %= mod
print(ans)

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

ans = 0
mod = 7 + 10**9

s = sum(A)
for i in range(N):
	s -= A[i]
	ans += s * A[i]
	ans %= mod

print(ans)	

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
total = sum(a)
total %= mod
total = total ** 2
total %= mod
cnt = 0
for i in range(n):
  cnt += a[i]**2
  cnt %= mod

ans = total - cnt
ans %= mod
ans *= pow(2, mod - 2)
ans %= mod
print(ans)
  


n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
total = sum(a)
total %= mod
total = total ** 2
total %= mod
cnt = 0
for i in range(n):
  cnt += a[i]**2
  cnt %= mod

ans = total - cnt
ans %= mod
print(ans)
  

n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
total = sum(a)
total = total ** 2
cnt = 0
for i in range(n):
  cnt += a[i]**2

ans = (total - cnt) // 2
ans %= mod

print(ans)
  


Verdicts: Time Limit Exceeded

Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))



A_sum = 0
for i in range(0, N, 1):
    A_sum = A_sum + A[i]

A_sum_sq = A_sum * A_sum

idv_sq_sum = 0
for i in range(0, N, 1):
    idv_sq_sum += A[i] * A[i]

Answer = (A_sum_sq -
          idv_sq_sum) / 2
print(Answer%(10**9 + 7))

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



A_sum = 0
for i in range(0, N, 1):
    A_sum = A_sum + A[i]

A_sum_sq = A_sum * A_sum

idv_sq_sum = 0
for i in range(0, N, 1):
    idv_sq_sum += A[i] * A[i]

Answer = (A_sum_sq -
          idv_sq_sum) // 2
print(Answer%(10**9 + 7))

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
from numba import jit
@jit
def main():
  n=int(input())
  a=list(map(int,input().split()))
  mod=10**9+7
  ans=0
  for i in range(n-1):
    ans=ans+(a[i]*(sum(a[i+1:n])%mod))%mod
  print(ans)
main()

n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
s=sum(a[1:n])
for i in range(n-1):
  ans=(ans+(a[i]*(s%mod))%mod)%mod
  s=s-a[i+1]
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
def findProductSum(A, n): 
    s = 0
    for i in range(n): 
        s = s + A[i] 
    array_sum_square = s * s 
    individual_square_sum = 0
    for i in range(n): 
        individual_square_sum += A[i] * A[i] 
    return (array_sum_square -individual_square_sum) / 2
n=int(input())
a=list(map(int,input().split()))
print(findProductSum(a,n))

M=1000000007
def findProductSum(A, n): 
    s = 0
    for i in range(n): 
        s+=A[i] 
    array_sum_square = s*s
    individual_square_sum = 0
    for i in range(n): 
        individual_square_sum += A[i]*A[i]
    return (array_sum_square -individual_square_sum) // 2
n=int(input())
a=list(map(int,input().split()))
print(findProductSum(a,n)%M)

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))
ans = 0
a = 7 + 10**9 
for i in range(N-1):
  for j in range(i+1,N):
    B = A[i] * A[j]
    ans += int(str(B)[-9:]) - 7*int(str(B)[:1])
print(ans % a)

N = int(input())
A = list(map(int, input().split()))
a = 0
ans = 0
mod = 10**9 + 7
for i in range(N-1):
  a += A[N-i-1]
  ans += A[N-i-2] * a
print(ans%mod)

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
def findProductSum(A, n):
    tmp = (10**9)+7

    array_sum = 0
    for i in range(0, n, 1):
        array_sum = array_sum + A[i]

    array_sum_square = array_sum * array_sum

    individual_square_sum = 0
    for i in range(0, n, 1):
        individual_square_sum += A[i] * A[i]
        individual_square_sum = individual_square_sum

    return ((array_sum_square - individual_square_sum) // 2) % tmp

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

print(float(findProductSum(a,n)))


# required function
def findProductSum(A, n):
    tmp = (10**9)+7

    # calculating array sum (a1 + a2 ... + an)
    array_sum = 0
    for i in range(0, n, 1):
        array_sum = array_sum + A[i]

    # calcualting square of array sum
    # (a1 + a2 + ... + an)^2
    array_sum_square = array_sum * array_sum

    # calcualting a1^2 + a2^2 + ... + an^2
    individual_square_sum = 0
    for i in range(0, n, 1):
        individual_square_sum += A[i] * A[i]
        individual_square_sum = individual_square_sum

    # required sum is (array_sum_square -
    # individual_square_sum) / 2
    return ((array_sum_square -
            individual_square_sum) / 2) % tmp

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

print(findProductSum(a,n))


def findProductSum(A, n):
    tmp = (10**9)+7

    array_sum = 0
    for i in range(0, n, 1):
        array_sum = array_sum + A[i]

    array_sum_square = array_sum * array_sum

    individual_square_sum = 0
    for i in range(0, n, 1):
        individual_square_sum += A[i] * A[i]
        individual_square_sum = individual_square_sum

    return ((array_sum_square - individual_square_sum) / 2) % tmp

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

print(findProductSum(a,n))


def findProductSum(A, n):
    tmp = (10**9)+7

    array_sum = 0
    for i in range(0, n, 1):
        array_sum = array_sum + A[i]

    array_sum_square = array_sum * array_sum

    individual_square_sum = 0
    for i in range(0, n, 1):
        individual_square_sum += A[i] * A[i]
        individual_square_sum = individual_square_sum

    return ((array_sum_square - individual_square_sum) // 2) % tmp

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

print(findProductSum(a,n))


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
if sum(a)==0:
    print(0)
    exit()
else:
    k=1
    for i in range(n-1):
        for j in range(i+1,n):
            k*=a[i]*a[j]
            k/=10**9+7
print(k)


n=int(input())
a=list(map(int,input().split()))
if sum(a)==0:
    print(0)
    exit()
else:
    k=0
    s=sum(a)
    for i in range(n-1):
        s-=a[i]
        s1=s%(10**9+7)
        k+=(s1*a[i])%(10**9+7)
print(k%(10**9+7))

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split()))
S = 0
S2 = 0
MOD = 1000000007
for i in range(N):
  S += A[i]
  S2 += A[i]*A[i]
print((S*S-S2)/2%MOD)


N = int(input())
A = list(map(int,input().split()))
S = 0
S2 = 0
MOD = 1000000007
for i in range(N):
  S += A[i]
  S2 += A[i]*A[i]
print((S*S-S2)//2%MOD)


Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
n= int(input())
mod=10**9+7
a= [int(x ) for x in input().split()]
b= a[:]

s=0
for i in range(n-2,-1,-1):
    b[i]=b[i+1]+b[i]

for i in range(n):
    s += (b[i]-a[i])*a[i]


n= int(input())
mod=10**9+7
a= [int(x ) for x in input().split()]
b= a[:]

s=0
for i in range(n-2,-1,-1):
    b[i]=b[i+1]+b[i]
for i in range(n):
    s += (b[i]-a[i])*a[i]
print(s%mod)

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
N=int(int(input))
A=list(map(int,input().split()))
sum=sum[A]
b=0
c=0
for i in range(N-1):
    b+=A[i]
    c=(c+(A[i]*(sum-b))) %(10**9+7)
print(c)

N=int(int(input))
A=list(map(int,input().split()))
sum=sum[A]
b=0
c=0
for i in range(N-1):
    b+=A[i]
    c=(c+(A[i]*(sum-b))) %(10**9+7)
print(c)

N=int(input())
a=list(map(int, input().split()))
sum=sum(a)
b=0
c=0
for i in range(N-1):
    b+=a[i]
    c=(c+(a[i]*(sum-b))) %(10**9+7)
print(c)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
def main():
    N = int(input())
    A_list = list(map(int, input().split()))
    mod = 10**9 + 7

    ans = 0
    A_ = sum(A_list) % mod
    for i in range(N):
        A = A_list[i]
        A_ = A_ - A
        ans = (ans + (A * A_) % mod)) % mod
    print(ans)
    return


if __name__ == '__main__':
    main()

def main():
    N = int(input())
    A_list = list(map(int, input().split()))
    mod = 10**9 + 7

    ans = 0
    A_ = sum(A_list) % mod
    for i in range(N-1):
        A = A_list[i]
        A_ = A_ - A
        ans = (ans + (A * A_) % mod)) % mod
    print(ans)
    return


if __name__ == '__main__':
    main()

def main():
    N = int(input())
    A_list = list(map(int, input().split()))
    mod = 10**9 + 7

    ans = 0
    A_ = sum(A_list) % mod
    for i in range(N-1):
        A = A_list[i]
        A_ = A_ - A
        ans = (ans + (A * A_) % mod) % mod
    print(ans)
    return


if __name__ == '__main__':
    main()
    

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
ans=0
suma=sum(a)
for i in range(n):
  ans+=(a[i]*(suma-a[i]))
  ans/=2
print(int(ans%(10**9+7)))

n=int(input())
a=list(map(int,input().split()))
ans=0
suma=sum(a)
for i in range(n):
  suma-=a[i]
  ans+=(a[i]*(suma))%(10**9+7)
print(int(ans%(10**9+7)))


Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
import numpy as np
n = int(input())
num_list = list(map(int, input().split()))

mod = 1e+7+9
cumsum_list = np.cumsum(num_list[::-1])[::-1][1:]
score = 0
for i in range(n-1):
    score += num_list[i] * cumsum_list[i] % mod
    
print(score % mod)

import numpy as np
n = int(input())
num_list = list(map(int, input().split()))
mod = int(1e+9+7)
cumsum_list = np.cumsum(num_list[::-1])[::-1][1:]
all_sum = sum(num_list)
score = 0
for i in range(n-1):
    
    score += (num_list[i] * (cumsum_list[i]%mod)) % mod
print(score % mod)

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
MOD = 1000000007
n = int(input())
nums = list(map(int, input().split()))
x = sum(sums)
y = sum([(x[i]**2) for i in range(n)])
print(((x**2 - y)//2)% MOD)

MOD = 1000000007
n = int(input())
nums = list(map(int, input().split()))
x = sum(nums)
y = sum([(nums[i]**2) for i in range(n)])
print(((x**2 - y)//2)% MOD)

Verdicts: Runtime Error

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
l = int(input())
num = input().split(' ')
num = [int(i) for i in num]
ans = 0
s = sum(num)
for i in range(l):
    print(s)
    s -= num[i]
    ans += num[i] * s
    print(ans)
print(ans%(10**9+7))

l = int(input())
num = input().split(' ')
num = [int(i) for i in num]
ans = 0
s = sum(num)
for i in range(l):
    s -= num[i]
    ans += num[i] * s
print(ans%(10**9+7))

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
N=int(input())
A=list(map(int, input().split()))
p=10**9+7
S=sum(A)
S2=S**2
T=0
for i in range(N):
    T+=A[i]**2
ans=((S2-T)//2)%p
print(ans,S2)

N=int(input())
A=list(map(int, input().split()))
B=[A[0]]
for i in range(1,N):
    B.append(B[i-1]+A[i])
p=10**9+7
ans=0
for i in range(1,N):
    ans+=A[i]*B[i-1]
ans%=p
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
# -*- coding: utf-8 -*-



n = int(input())

zzz = list(map(int, input().split()))
b=sum(zzz)**2
a=0
for i in range(n):
  # print(i)
  x=zzz[i]**2
  print(x)
  a +=x
# print(b)
# for a in zzz:
#   print(a)

# print(b)
# print(a)

ans = (b-a)//2%(10**9+7)
print(ans)


# -*- coding: utf-8 -*-



n = int(input())

zzz = list(map(int, input().split()))
b=sum(zzz)**2
a=0
for i in range(n):
  # print(i)
  x=zzz[i]**2
  print(x)
  a +=x
# print(b)
# for a in zzz:
#   print(a)

# print(b)
# print(a)

ans = (b-a)//2%(10**9+7)
print(ans)


# -*- coding: utf-8 -*-



n = int(input())

zzz = list(map(int, input().split()))
b=sum(zzz)**2
a=0
for i in range(n):
  # print(i)
  x=zzz[i]**2
  # print(x)
  a +=x
# print(b)
# for a in zzz:
#   print(a)

# print(b)
# print(a)

ans = (b-a)//2%(10**9+7)
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
import numpy as np

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

mod = 1000000007
res = np.cumsum(A, dtype=np.float64)
ans = 0

for i in range(N-1):
    S = (res[N-1]-res[i]) % mod
    ans += A[i]*S
    ans %= mod

print(ans)



import numpy as np

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

mod = 1000000007
res = np.cumsum(A, dtype=np.float64)
ans = 0

for i in range(N-1):
    S = (int(res[N-1])-int(res[i])) % mod
    ans += A[i]*S
    ans %= mod

print(int(ans))

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
import numpy as np

N=int(input())
A=np.array(list(map(int,input().split())))
mod=10**9+7

ans = np.sum(A)- np.sum(A*A)

print(ans//2%mod)

n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
aa = 0
b = 0
for i in range(n):
    aa += a[i] ** 2  
    b += a[i]
    
    #b %= mod
print((b ** 2 - aa)//2%mod)


Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
input_num = int(input())
input_list = list(map(int, input().split()))

sum = 0

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

print(sum % 1000000007)



input_num = int(input())
input_list = list(map(int, input().split()))

sum = 0

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

print(sum % 1000000007)


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

sum_tmp = sum(A)
mod = 10 ** 9 + 7
squ = 0
sum = 0

for i in range(N):
    sum += A[i]*sum_tmp
    squ +=  A[i] ** 2

sum = (sum - squ) / 2
print(sum % mod)

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

mod = 10 ** 9 + 7
sum = sum(A) **  2

squ = 0
for i in range(N):
    squ +=  A[i] ** 2

answer = int(((sum - squ)  //  2 ) % mod)
print(answer)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
N = int(input())
A = [int(num) for num in input().split()]

sumA = sum(A)
ans = 0
for i in range(len(A)):
    sumA = sumA - A[i]
    ans += A[i] * sumA


ans = ans % (10**9)+7)
print(ans)

N = int(input())
A = [int(num) for num in input().split()]

sumA = sum(A)
ans = 0
for i in range(len(A)):
    sumA = sumA - A[i]
    ans += A[i] * sumA


ans = ans % (10**9)+7))
print(ans)

N = int(input())
A = [int(num) for num in input().split()]

sumA = sum(A)
ans = 0
for i in range(len(A)):
    sumA = sumA - A[i]
    ans += A[i] * sumA


ans = ans % (10**9+7)
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
N = int(input())
Al = input().split()

A = range(N)
for i in range(Al):
  A[i] = int(i)

num = 0

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

num = num % (10**9 + 7)
print(num)

N = int(input())
Al = input().split()
A = list( map((lambda x: int(x)), Al))
num = 0
ma = 10**9 + 7
li = 0

for i in range(N-1, 0, -1):
  li += A[i]
  num += A[i-1] * li

num = num % ma
print(num)


Verdicts: Runtime Error

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
M = 1000000007
n = int(input())
a = list(map(int,input().split()))
S = [0]
for i in range(n):
 S.append(S[-1]+a[i])%M
sum = 0
for i in range(n-1):
 sum += (a[i]*(S[n]-S[i+1]))%M
print(sum%M)


M = 1000000007
n = int(input())
a = list(map(int,input().split()))
S = [0]
for i in range(n):
 S.append((S[-1]+a[i])%M)
sum = 0
for i in range(n-1):
 sum += (a[i]*(S[n]-S[i+1]))%M
print(sum%M)

Verdicts: Runtime Error

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
MAX=101010
is_prime=[True]*MAX
is_prime[0]=False
is_prime[1]=False
for i in range(2,MAX):
  if is_prime[i]==False:
    continue
  for j in range(i*2,MAX,i):
    is_prime[j]=False

a=[0]*MAX
for i in range(MAX):
  if i%2==0:
    continue
  if is_prime[i] and is_prime[(i+1)//2]:
    a[i]=1

s=[0]
for x in a:
  s.append(s[-1]+x)

Q=int(input())
for _ in range(Q):
  l,r=map(int,input().split())
  print(s[r+1]-s[l])


mod=10**9+7

N=int(input())
A=list(map(int,input().split()))
B=[0]
for x in A:
  B.append(B[-1]+x)

ans=0
for i in range(N):
  s=(B[N]-B[i+1])%mod
  ans+=A[i]*s
  ans%=mod

print(ans)


Verdicts: Runtime Error

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
mod = 10**9+7
N = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)%mod
sum_a2 = sum([x**2 for x in a])%mod
ans = ((sum_a**2 - sum_a2)%mod)/2
print(ans)

mod = 10**9+7
N = int(input())
a = list(map(int, input().split()))
sum_a = 0
sum_a2 = 0
for x in a:
  sum_a += x
  sum_a2 += x**2

ans = ((sum_a**2 - sum_a2))//2
print(ans%mod)


Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
L=[int(x) for x in input().split()]
sum=0
product=0
mod=1000000007
for i in range(n):
    sum+=L[i]%mod
for i in range(n-1):
    sum-=(L[i]%mod)
    product+=sum*(L[i]%mod)
print(product)

L=[int(x) for x in input().split()]
sum=0
product=0
mod=1000000007
for i in range(n):
    sum+=L[i]%mod
for i in range(n-1):
    sum-=(L[i]%mod)
    product+=sum*(L[i]%mod)
print(product)


n=int(input())
L=[int(x) for x in input().split()]
sum=0
product=0
mod=1000000007
for i in range(n):
    sum+=L[i]%mod
for i in range(n-1):
    sum-=(L[i]%mod)
    product+=sum*(L[i]%mod)
print(product%mod)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
n= int(input())
lst = [int(i) for i in input().split()]
lst = sorted(lst)
count = 0
d_lst = []
for i in range(len(lst)):
    if lst[i] not in d_lst:
        if lst[i] == lst[i+1]:
            d_lst.append(lst[i])
for d in d_lst:
    count += d**2
lst = set(lst)

for i in range(len(lst)):
    for j in range(i+1,len(lst)):
        a = lst[i] * lst[j]
        count += a

if count > ( 10**9 + 7 ):
    print(count % (10**9 + 7))
else:
    print(count)

n= int(input())
lst = [int(i) for i in input().split()]
lst = sorted(lst)
count = 0
d_lst = []
for i in range(len(lst)):
    if lst[i] not in d_lst:
        if lst[i] == lst[i+1]:
            d_lst.append(lst[i])
for d in d_lst:
    count += d**2
lst = list(set(lst))

for i in range(len(lst)):
    for j in range(i+1,len(lst)):
        a = lst[i] * lst[j]
        count += a

if count > ( 10**9 + 7 ):
    print(count % (10**9 + 7))
else:
    print(count)

n = int(input())
a = list(map(int, input().split()))
ruiseki = 0
count = 0
for i in range(n-1):
    ruiseki += a[i]
    count += ruiseki * a[i+1]
mod = 10**9 + 7
if count >= mod:
    print(count%mod)
else:
    print(count)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
n = input()
a_list = list(map(int, input().split()))
sum_ = 0
mod = 10 ** 9 + 7
for i in range(len(a_list) - 1):
  sum_ += ((a_list[i] % mod) * (a_list[i + 1] % mod)) % mod 
print(sum_ % mod)

n = input()
a_list = list(map(int, input().split()))
ruisekiwa = [0] * (len(a_list) + 1) 
for i in range(len(a_list)):
    ruisekiwa[i + 1] = ruisekiwa[i] + a_list[i]
sum_ = 0
mod = 10 ** 9 + 7
for i in range(len(a_list)):
    sum_ += ((a_list[i] % mod) * ((ruisekiwa[-1] % mod) - (ruisekiwa[i + 1] % mod))) % mod
print(sum_ % mod)

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):

def findProductSum(A, n):

    array_sum = 0
    for i in range(0, n, 1):
        array_sum = array_sum + A[i]

    # calcualting square of array sum
    # (a1 + a2 + ... + an)^2
    array_sum_square = array_sum * array_sum

    # calcualting a1^2 + a2^2 + ... + an^2
    individual_square_sum = 0
    for i in range(0, n, 1):
        individual_square_sum += A[i] * A[i]

    # required sum is (array_sum_square -
    # individual_square_sum) / 2
    return (array_sum_square -
            individual_square_sum) / 2

# Driver code
if __name__ == '__main__':
    n = int(input())
    A = [int(x) for x in input().split()]
    # n = len(A)
    print((findProductSum(A, n)%(10**9 +7)))




def findProductSum(A, n):

    array_sum = 0
    for i in range(0, n, 1):
        array_sum = array_sum + A[i]

    # calcualting square of array sum
    # (a1 + a2 + ... + an)^2
    array_sum_square = array_sum * array_sum

    # calcualting a1^2 + a2^2 + ... + an^2
    individual_square_sum = 0
    for i in range(0, n, 1):
        individual_square_sum += A[i] * A[i]


    return (array_sum_square - individual_square_sum) // 2


def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    # n = len(A)
    mod = (10**9) + 7
    print(int(findProductSum(A, n))%mod)

main()



Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
n=int(input())
ai = list(map(int,input().split()))
sum = 0
i=0
k=1
while i<n-1:
    while k<n-i:
    sum += ai[i]*ai[i+k]
    k++
  i++
sum %= 1000000007
print(sum)

N=int(input())
A=list(map(int,input().split()))
ans = 0
last = 0

for i in range(N):
    ans += A[i]
last += sum(A)
last -= ans
last //= 2
print(last % 1000000007)

N=int(input())
A=list(map(int,input().split()))
ans = 0
last = 0

for i in range(N):
    ans += A[i]*A[i]
last += sum(A)*sum(A)
last -= ans
last //= 2
print(last % 1000000007)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
N=int(input())
A=list(int(i) for i in input().split())
print(A)
S=0
for i in range(N):
    for j in range(i+1,N):
        S+=A[i]*A[j]
print(S%((pow(10,9)+7)))

N=int(input())
A=input().split()
A=[int(i) for i in A]
S=0
A_sum=0
for i in range(N):
    A_sum+=A[i]
    

B=A_sum
for i in range(N):
    B-=A[i]
    S+=A[i]*B

print(S%(pow(10,9)+7))

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
N = int(input())
A = [int(a) for a in input().split()]
mod = 10 ** 9 + 7
ans = 0
for i in range(N - 1):
  for j in range(i+1, N):
    a = (A[i] * A[j]) % mod
    ans += a
    ans = ans % mod
  print(a)
print(ans)

N = int(input())
A = [int(a) for a in input().split()]
mod = 10 ** 9 + 7
ans = 0
#TLE
'''
for i in range(N - 1):
  for j in range(i+1, N):
    a = A[i] % mod
    b = A[j] % mod
    ans += (a * b) % mod
    ans = ans % mod
'''
tot = 0
for i in range(N):
  A[i] %= mod
  tot += A[i]
  tot %= mod
for i in range(N-1):
  tot -= A[i]
  ans += (A[i] * tot) % mod
  ans %= mod
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
i = 0
tmp = 0
tmpura = 0
while(i < n):
    tmp += a[i]
    i+=1
tmp=tmp **2
i = 0
while (i < n):
    tmpura += a[i]**2
    i+=1
tmpura=tmpura
ans = ((tmp - tmpura)/2)%(10**9+7)
print(ans)

n = int(input())
a = list(map(int, input().split()))
i = 0
tmp = 0
tmpura = 0
while(i < n):
    tmp += a[i]
    i+=1
tmp=tmp **2
i = 0
while (i < n):
    tmpura += a[i]**2
    i+=1
tmpura=tmpura
ans = ((tmp - tmpura)//2)%(10**9+7)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))

a2=[a[n-1]]
for i in range(n-1,0,-1):
    a2.append(a2[-1]+a[i-1])
print(a2)
ans=0
for i in range(n-1):
    ans = ( ans + (a[i]*a2[-i-2]) )%(10**9+7)
print(ans)


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

ans=0

for i in range(N):
    ans=(ans+A[i])%(10**9+7)
print(ans)
ans=ans**2

for i in range(N):
    ans=(ans-A[i]**2)%(10**9+7)

print(ans/2)


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

ans=0

for i in range(N):
    ans=(ans+A[i])%(10**9+7)
ans=ans**2

for i in range(N):
    ans=(ans-A[i]**2)%(10**9+7)

print(ans/2)


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

a2=[a[n-1]]
for i in range(n-1,0,-1):
    a2.append(a2[-1]+a[i-1])
ans=0
for i in range(n-1):
    ans = ( ans + (a[i]*a2[-i-2]) )%(10**9+7)
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
mport sys
import numpy as np
import math
import collections
import copy
import decimal
import itertools
from collections import deque 
from functools import reduce
from itertools import product
from itertools import combinations

# input = sys.stdin.readline
N = int(input())
An = list(map(int, input().split()))
An_l = list(itertools.accumulate(An))
An_l.insert(0, 0)
ans = 0
for i, A in enumerate(An):
    tt = An_l[-1] - An_l[i+1]
#     print(i, An_l[-1], An_l[i], tt)
    At = A * tt
#     print(A, tt, At)
    ans = (ans+At) % (10**9+7)
#     print(ans)
print(ans)



N = int(input())
An = list(map(int, input().split()))
An_s = collections.Counter(An)
total = 0
for k in An_s:
    total += k
ans = 0
for A, v in An_s.items():
    At = A * (total-A)*v
#     print(A, total, At, ans)
    ans = (ans+At) % (10**9+7)
#     print(ans)
print(ans//2)

import sys
import numpy as np
import math
import collections
import copy
import decimal
import itertools
from collections import deque 
from functools import reduce
from itertools import product
from itertools import combinations
 
# input = sys.stdin.readline
N = int(input())
An = list(map(int, input().split()))
An_l = list(itertools.accumulate(An))
An_l.insert(0, 0)
ans = 0
for i, A in enumerate(An):
    tt = An_l[-1] - An_l[i+1]
#     print(i, An_l[-1], An_l[i], tt)
    At = A * tt
#     print(A, tt, At)
    ans = (ans+At) % (10**9+7)
#     print(ans)
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
N=int(input())
a=[int(i) for i in input().split()]
mod=10**9+7
S=sum(a)%mod
T=sum([i*i for i in a])%mod
print((S*S-T)%mod)


import numpy as np
N=int(input())
P=10**9+7
a=[int(i) for i in input().split()]
b=[0 for i in range(P)]
for i in range(N):
    b[a[i]]+=1
M=1<<19
c=np.zeros(M)
for i in range(P-1):
    c[i]=b[pow(2,i,P)]
X=[int(i+0.1) for i in np.real(np.fft.ifft(np.fft.fft(c)*np.fft.fft(c)))]
ans=0
for k in range(M):
    ans+=X[k]*pow(2,k,P)
for i in range(N):
    ans-=(a[i]*a[i])%P
print((ans//2)%P)


N=int(input())
a=[int(i) for i in input().split()]
mod=10**9+7
S=sum(a)%mod
T=sum([i*i for i in a])%mod
print((pow(2,mod-2,mod)*(S*S-T))%mod)


Verdicts: Wrong Answer

Time Limit Exceeded

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
n = int(input())
a = [int(s) for s in input().split()]
b = []
val = 0
for i in range(0, n):
    b.append(a[i] * sum(a[:i])) 
val = sum(b)
print(b)
print(val % (10 ** 9 + 7))

n = int(input())
a = [int(s) for s in input().split()]
b = []
val = 0
sum_val= 0
for i in range(0, n):
    b.append(a[i] * sum_val) 
    sum_val+= a[i] 
val = sum(b)
print(val % (10 ** 9 + 7))

Verdicts: Wrong Answer

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
n=int(input())
a=list(input().split(' '))
total=0
S_i=0
for i in range(n-1):
    S_i+=a[n-1-i]
    S_i=S_i%(7+10**9)
    total+=S_i*a[n-2-i]
    total=total%(7+10**9)
print(total)

n=int(input())
a=list(input().split(' '))
total=0
S_i=0
for i in range(n-1):
    S_i+=int(a[n-1-i])
    S_i=S_i%(7+10**9)
    total+=S_i*int(a[n-2-i])
    total=total%(7+10**9)
print(total)

Verdicts: Runtime Error

Accepted
Problem: Given are N integers A_1,\ldots,A_N.  Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Submission attempts (in order):
S=list(str(input()))
T=list(str(input()))
ans=10000
for i in range(len(S)-len(T)+1):
    s=0
    for u in range(len(T)):
        if S[i+u]==T[u]:
            s+=1
            #print(s)
    s=len(T)-s
    ans=min(ans,s)
print(ans)

from collections import deque
N = int(input())
A = list(map(int, input().split()))
#N=3
#A=[1,2,3]
q=deque(A)
#print(q)
ans=0
sums=sum(q)
#print(sums)
for i in range(N-1):
    qwe=q.popleft()
    ans+=qwe *(sums-qwe)
    sums-=qwe
print(ans%(10**9+7))

Verdicts: Wrong Answer

Accepted