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 sys

def main():
    input = sys.stdin.readline
    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = [0]*(n+1)
    MOD = 10**9 + 7

    for i in range(n):
        b_list[i+1] = b_list[i] + a_list[i]
    
    ans = 0
    for i in range(n):
        ai_sum = b_list[n] - b_list[i+1]
        ans += ai_sum * a_list[i]
        ans %= MOD
    print(ans)

import sys

def main():
    input = sys.stdin.readline
    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = [0]*(n+1)
    MOD = 10**9 + 7

    for i in range(n):
        b_list[i+1] = b_list[i] + a_list[i]
    
    ans = 0
    for i in range(n):
        ai_sum = b_list[n] - b_list[i+1]
        ans += ai_sum * a_list[i]
        ans %= MOD
    print(ans)




    


if __name__ == '__main__':
    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):
MOD = 1000000007

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

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

array_sum_square = pow(array_sum,2,MOD)

individual_square_sum = 0
for i in range(0, n, 1): 
    individual_square_sum+= pow(a[i],2,MOD)
    individual_square_sum%=MOD

ans=(array_sum_square - individual_square_sum+MOD) / 2
print(int(ans%MOD))

MOD = 1000000007

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

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

array_sum_square = pow(array_sum,2,MOD)

individual_square_sum = 0
for i in range(0, n, 1): 
    individual_square_sum+= pow(a[i],2,MOD)
    individual_square_sum%MOD

ans=(array_sum_square - individual_square_sum+MOD) / 2
print(int(ans%MOD))

MOD = 1000000007

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

array_sum = 0
for i in range(0, n, 1): 
    array_sum += a[i]
    #array_sum%=MOD

array_sum_square = pow(array_sum,2)

individual_square_sum = 0
for i in range(0, n, 1): 
    individual_square_sum+= pow(a[i],2)
    #individual_square_sum%=MOD

ans=(array_sum_square - individual_square_sum) //2
print(ans%MOD)

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

ans = 0
Q = 1e9 + 7

for i in range(N-1):
    for j in range(i+1, N):
        print(A[i], A[j])
        ans += (A[i] * A[j])
        ans %= Q

print(int(ans))

N = int(input())
A = list(map(int, input().split()))
 
ans = 0
Q = int(1e9 + 7)
 
sumA = sum(A)
 
for i in range(N-1):
    sumA -= A[i]
    ans += sumA * A[i]
    ans %= Q
 
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):
import sys
input = sys.stdin.readline
n = int(input())
tmp = list(map(int, input().split()))
A = [a % M for a in tmp]
M = 1000000007
ans = 0
for i in range(1,n):
    ans += (A[i-1] * ((sum(A[i::])%M)))%M
print(ans%M)

import sys
input = sys.stdin.readline
M = 1000000007
n = int(input())
A = list(map(int, input().split()))
ans = 0
s = 0
for i in range(n):
    s += A[i]
    s %= M

for i in range(n):
    s = s - A[i]
    if s < 0:
        s += M
    ans += A[i] * s
    ans %= M
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):
from itertools import accumulate
mod = 1e9 +7
def main():
    n = int(input())
    a = list(map(int,input().split()))
    ans =0
    ac = list(accumulate(a))
    
    for i in range(n):
        ans += a[i]* (ac[-1]-ac[i])
        ans %=mod
    print(ans)

if __name__ == '__main__':
    main()

mod = 1e9 + 7

n = int(input())
a = list(map(int, input().split()))
pref = [0 for x in range(n)]
pref[0] = a[0]
for i in range(1, n):
    pref[i] += ((pref[i - 1] + a[i]))

ans = 0
for i in range(n - 1, 0, -1):
    ans = (ans + a[i] * pref[i - 1]) % mod

print(ans)

from itertools import accumulate
mod = 10**9 +7

def main():
    n = int(input())
    a = list(map(int,input().split()))
    ans =0
    ac = list(accumulate(a))

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

if __name__ == '__main__':
    main()

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):
n = int(input())
a = list(map(int, input().split()))
 
# required function 
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 
    return (array_sum_square - 
            individual_square_sum) / 2
 
print(int(findProductSum(a, n))%10**9+7) 

n = int(input())
a = list(map(int, input().split()))
 
# required function 
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 
    return (array_sum_square - 
            individual_square_sum)
mod = 10**9+7
  
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
  
print(modinv(2)*int(findProductSum(a, n))%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)
A = [int(x) for x in input().split(" ")]

from itertools import combinations

mod = 1000000007  
s = 0
for c in combinations(A, 2):
    s += c[0] * c[1]

print(s % mod)

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

from itertools import combinations

mod = 1000000007  

s = 0
ans = 0
for n in A:
    s += n
    s %= mod

for i in range(N):
    s -= A[i]
    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):
N = int(input())
alist = list(map(int, input().split()))
Sum_a = 0
for i in range(N):
  for j in range(i+1, N):
    Sum_a += alist[i]*alist[j]
print(Sum_a%(1e9+7))

N = int(input())
alist = list(map(int, input().split()))
import numpy as np
Sum_a = 0
Sum_j_list = np.cumsum(alist)
for i in range(N-1):
  Sum_j = int((Sum_j_list[N-1] - Sum_j_list[i]) % int(1e9+7))
  Sum_a += (alist[i] * Sum_j) % int(1e9+7)
print(int(Sum_a % int(1e9+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 = list(map(int, input().split()))
 
s = 0
for i in a_list:
    for j in a_list:
        s += i*j

s_2 = 0
for i in a_list:
    s_2 += i**2
    
ans = int((s - s_2)/2)
ans %(10**9+7)

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

s_2 = 0
for i in a_list:
    s_2 += i**2

ans = (sum(a_list)**2 - s_2)/2  

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

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

s_2 = 0
for i in a_list:
    s_2 += i**2

ans = (sum(a_list)**2 - s_2)//2  

ans = ans%(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):
ans = 0
mod = 1e9+7

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

A_sum = sum(A)
A_squared = sum([num**2 for num in A])

ans = (A_sum**2 - A_squared)/2
ans = int(ans%mod)
print(ans-1)


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

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

print(ans%(1e9+7))

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

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):
s=input()
t=input()
len_s=len(s)
len_t=len(t)
len_n=len_s-len_t
ans=100000
for i in range(0,len_n+1):
    cnt=0
    for j in range(len_t):
        if s[i+j]!=t[j]:
            cnt+=1

    ans=min(ans,cnt)
print(ans)


n=int(input())
lst=list(map(int,input().split()))
aa=sum(lst) % (10**9+7)
# print(sum(lst) % (10**9+7) )
new_lst=[]
temp_1=aa
for i in range(n-1):
    temp_1-=lst[i]
    new_lst.append(temp_1)
# print(new_lst)

tem=0
for i in range(n-1):
    tem+=(lst[i] )*new_lst[i]
        # print(tem)
print(tem % (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 = sum(a)
num = 0
for i in range(n):
  num = num - a[i]
  num = a[i]*num
else:
  print(num)

n=int(input())

l = 1000000007
a=list(map(int,input().split()))
s = sum(a)
num = 0
for i in range(n):
  s = s- a[i]
  num =num+a[i]*s
else:
  print(num%l)



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
t = n-1
for i in a:
    for j in range(t):
        sum += i * a[-(j+1)]
    t -= 1
ans = sum % (10**9 + 7)

n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
s = sum(a)
for i in a:
    s -= i
    ans = (ans + (i * s))
ans = 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,*l=map(int,open(0).read().split())
print((sum(l)**2-sum(i**2 for i in l)//2)%(10**9+7))

n,*l=map(int,open(0).read().split())
print((sum(l)**2-sum(i**2 for i in l))//2%(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(" ")))

res = 1
for j in range(n):
    for i in range(j+1):
        res = res * a[j] * a[i] % ((10**9) + 7)
print(res)
        

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

res = 0
ruiseki = 0
for j in range(n):
    if j == 0:
        continue
    ruiseki += a[j-1]
    res = res + a[j]*ruiseki
print(res % ((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):
# C - Sum of product of pairs
import numpy as np

N = int(input())
A = list(int(a) for a in input().split())
MOD = 10**9 + 7
A = np.array(A)
csA = np.zeros((N+1), np.object)
for i in range(N):
    csA[i+1] = csA[i] + A[i]
    
ans = 0
for i in range(N-1):
    ans += (A[i] * (csA[N] - csA[i+1])) % MOD
print(ans%MOD)

# C - Sum of product of pairs
import numpy as np

N = int(input())
A = list(int(a) for a in input().split())
MOD = 10**9 + 7
A = np.array(A)
csA = np.zeros((N+1), np.int64)
for i in range(N):
    csA[i+1] = (csA[i] + A[i]) % MOD
    
ans = 0
for i in range(N-1):
    ans += (A[i] * (csA[N] - csA[i+1])) % MOD
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):
n = int(input())
a = list(map(int, input().split()))
ans = 0
c = sum(a)

for i in range(n - 1):
    ans += a[i] * (c - a[i])

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


n = int(input())
a = list(map(int, input().split()))
ans = 0
c = sum(a)

for i in range(n - 1):
    c = c - a[i]
    ans += a[i] * c

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()))
for i in range(n):
  for j in range(i + 1, n):
    result += (a[i] % (10**9 + 7)) * (a[i] % (10**9 + 7))
result = result % (10**9 + 7)
print(result)

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


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

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):
def solve():
  N = int(input())
  AA = list(map(int,input().split()))
 
  ans = 0
  for a in AA:
    ans += a
  ans = ans**2
  for a in AA:
    ans -= a**2
  ans = (ans+(10**9+7)**2//2) % (10**9+7)
  print(ans)
solve()

def solve():
  N = int(input())
  AA = list(map(int,input().split()))
 
  ans = 0
  for a in AA:
    ans += a
  ans = ans**2
  for a in AA:
    ans -= a**2
  ans = ans//2
  print(ans%(10**9+7)
solve()

def solve():
  N = int(input())
  AA = list(map(int,input().split()))
 
  ans = 0
  for a in AA:
    ans += a
  ans = ans**2
  for a in AA:
    ans -= a**2
  ans = ans//2
  print(ans%(10**9+7))
solve()

Verdicts: 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):
#from statistics import median
#import collections

from fractions import gcd
from itertools import combinations,permutations,accumulate, product 
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#

#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)

#



#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n = I()
A = readInts()
a = 0
for i in range(n):
    a += A[i]
    a %= mod
a = pow(a,2,mod)
nya = 0
for i in range(n):
    nya += A[i] * A[i]
    nya %= mod
if nya > a:
    a += mod
ans = (a-nya)//2
ans %= mod
print(ans)


#from statistics import median
#import collections

from fractions import gcd
from itertools import combinations,permutations,accumulate, product 
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#

#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)

#



#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n = I()
A = readInts()
a = 0
for i in range(n):
    a += A[i]
    a %= mod
a = pow(a,2,mod)
nya = 0
for i in range(n):
    nya += A[i] * A[i]
    nya %= mod
ans = ((a-nya + mod)//2)%mod
print(ans)


#from statistics import median
#import collections

from math import gcd
from itertools import combinations,permutations,accumulate, product 
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#

#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)

#



#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n = I()
A = readInts()
cum = list(accumulate(A))
ans = 0
for i in range(n-1):
    ans += A[i] * (cum[n-1]-cum[i])
    ans%=mod
print(ans%mod)


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):
from itertools import accumulate
def main():
    n=int(input())
    a=list(map(int,input().split()))
    aa=list(accumulate(a))
    mod=10**9+7
    ans=0
    print(aa)
    for i in range(n):
        ans += a[i]*(aa[-1]-aa[i])%mod
    print(ans%mod)
    
if __name__ == "__main__":
    main()

from itertools import accumulate
def main():
    n=int(input())
    a=list(map(int,input().split()))
    aa=list(accumulate(a))
    mod=10**9+7
    ans=0
    for i in range(n):
        ans += a[i]*(aa[-1]-aa[i])%mod
    print(ans%mod)
    
if __name__ == "__main__":
    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())
l = list(map(int,input().split()))
ans = 0
for i in range(1,n):
  l[i] += l[i-1]
i = 0
while i<n-1:
  ans += l[i]*(l[n] - l[i])
  i += 1
print(ans)

n = int(input())
l = list(map(int,input().split()))
x = [*l]
ans = 0
mod = 1000000007
for i in range(1,n):
  l[i] += l[i-1]
i = 0
while i<n-1:
  ans += (x[i])*(l[n-1] - l[i])
  i += 1
print(ans%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):
n = int(input())
A = [int(x)%(1e9+7) for x in input().split()]

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

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

# 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])%(1e9+7)
    individual_square_sum = individual_square_sum%(1e9+7)

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


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

partial_sum = copy.deepcopy(A)
sum_now = A[N-1]
for j in range(N-2,-1,-1):
    sum_now = int((sum_now+A[j])%mod)
    partial_sum[j] = sum_now
res = 0
for i in range(N-1):
    res = (res + (A[i]*partial_sum[i+1])%mod) %mod
print(int(res))


N = int(input())
A = [int(x) for x in input().split()]
 
partial_sum = A.copy()
sum_now = A[N-1]
for j in range(N-2,-1,-1):
    sum_now = int((sum_now+A[j])%(10**9+7))
    partial_sum[j] = sum_now
res = 0
for i in range(N-1):
    res = (res + (A[i]*partial_sum[i+1])%(10**9+7)) %(10**9+7)
print(int(res))

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

sum = 0

for i in range(n-1):
    sum_i = 0
    for j in range(n-i-1):
        sum_i += a[-(j+1)]
    print(sum_i)
    sum += (sum_i * a[i])

print(sum%((10 ** 9)+7))

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

sum_a = 0
sum_i = sum(a)

for i in range(n-1):
    sum_i -= a[i]
    sum_a += (a[i] * sum_i)

print(sum_a%((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())
i = list(map(int, input().split())) 

m=sum(i)

ans=0
for k in range(n-1):
    ans+=(i[k]+(m-i[k]))
ans=ans//2
ans=ans%(10**9+7)
print(ans)

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

ans=0
for k in range(n-1):
    for j in range(i+1,n):
        ans+=(i[k]*i[j])%(10**9+7)

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


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

m=sum(i)

ans=0
for k in range(n-1):
    ans+=(i[k]*(m-i[k]))
ans=ans//2
ans=ans%(10**9+7)
print(ans)


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

m=sum(i)

ans=0
for k in range(n):
    ans+=(i[k]*(m-i[k]))
ans=ans//2
ans=ans%(10**9+7)
print(ans)

Verdicts: Wrong Answer

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):
i = 0
j = i+1
ans = 0
while i != n - 1:
    ans = (ans+(a[i] * a[j])) % 1000000007
    j += 1
    if j == n:
        i += 1
        j = i + 1
print(ans)


i = 0
j = i+1
ans = 0
while i != n - 1:
  ans += a[i] * a[j]
  j += 1
  if j == n:
    i += 1
    j = i + 1
print(ans % 1000000007)

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

sum = [0 for i in range(n+1)]
for i in range(n - 1, -1, -1):
    sum[i] = sum[i + 1] + a[i]
ans = 0
for i in range(n):
    ans = (ans+(a[i]*sum[i+1])) % 1000000007
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= list(map(int,input().split()))
s2=int(sum(a)*sum(a))
a2=[int(i*i) for i in a]
ans1=int((s2-sum(a2))/2)
print(int(ans1%10**9+7))


n=int (input())
a= list(map(int,input().split()))
s2=int(sum(a)*sum(a))
a2=[int(i*i) for i in a]
ans1=(s2-sum(a2))//2

print(int(ans1%((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 = input()
vals = list(map(int, input().split()))
s = sum(vals)
ret = 0
for i, val in enumerate(vals):
    ret += val * (s - val)

mod = 10 ** 9 + 7
print(int(ret/2) % mod))

n = input()
vals = list(map(int, input().split()))
s = sum(vals)
ret = 0
for i, val in enumerate(vals):
    ret += val * (s - val)

mod = 10 ** 9 + 7
print(int(ret/2) % mod))

n = input()
vals = list(map(int, input().split()))
s = sum(vals)
ret = 0
for i, val in enumerate(vals):
    ret += val * (s - val)

mod = 10 ** 9 + 7
print(int(ret//2) % 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())
a = list(map(int, input().split()))
sum = 0
b = [i % (10**9+7) for i in a if i % (10**9+7) != 0]
print(b)
for j in range(0,len(b)-1):
    for k in range(j+1,len(b)):
        c = b[j]*b[k]
        sum = sum + c
print(sum%(10**9+7))

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

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

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):
N = int(input())
s = list(map(int, input().split()))
 
add = 0
j = 0
 
for i in range(N):
  for j in range(i+1, N):
    a = s[i] * s[j]
    add += a
 
a = add % (10**9 + 7)    
print(sum)

n=int(input())
a=list(map(int,input().split()))
mod = 10**9 + 7

sum = 0
f = 0

for i in range(n-1):
    f = f + a[i]
    sum += f * a[i+1]
 
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):
N = int(input())
X = list(map(int, input().split()))
p = 0
for n in range(N):
  for m in range(n+1, N):
    p += X[n]*X[m]
    if p >= 10**9 + 7:
  while p >= 10**9 + 7:
    p -= 10**9 + 7
      
print(p)

N = int(input())
X = list(map(int, input().split()))
p = 0
s = sum(X)
for n in range(N):
  s -= X[n] 
  s = s % (10**9 + 7)
  p += s * X[n]
  p = p % (10**9 + 7)

print(p)

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):
sum_ = 0
temp = 0
for i in range(len(a)-1):
    temp += a[-i-1]
    sum_ += temp * a[-i-2]

print(sum_%(10**9 + 7))

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

sum_ = 0
temp = 0
for i in range(len(a)-1):
    temp += a[-i-1]
    sum_ += temp * a[-i-2]

print(sum_%(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):
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
s = 0
Sum = 0
for i in range(n):
    s = (s+a[i]) % mod
for i in range(n):
    Sum = (Sum+a[i]*(mod+s-a[i])) % mod
print(int(Sum/2)+1)


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


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


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


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


Verdicts: Wrong Answer

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

out = (sum(As)**2 - sum([a**2 for a in As]))/2
print(out % (10**9+7))

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

out = (sum(As)**2 - sum([a**2 for a in As]))//2
print(out % (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 math
from fractions import Fraction as frac

MOD = 1e9 + 7

def solve(case_no):
    n = int(input())
    a = list(map(int, input().split()))
    ps = [a[0]]
    for i in range(1, n):
        ps.append(ps[i - 1] + a[i])
    ans = 0
    for i in range(n - 2, -1, -1):
        ans += a[i + 1] * ps[i]
        ans %= MOD
    print(ans)

t = 1
# t = int(input())
for i in range(1, t + 1):
    solve(i)


import math
from fractions import Fraction as frac

MOD = 1000000007

def solve(case_no):
    n = int(input())
    a = list(map(int, input().split()))
    ps = [a[0]]
    for i in range(1, n):
        ps.append(ps[i - 1] + a[i])
    ans = 0
    for i in range(n - 2, -1, -1):
        ans += a[i + 1] * ps[i]
        ans %= MOD
    print(int(ans))

t = 1
# t = int(input())
for i in range(1, t + 1):
    solve(i)


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()))
left = 0
right = 0
for i in range(n):
  left += a[i]
  left %= (10**9+7)
for j in range(n):
  right += a[j]
  right %= (10**9+7)
c = (left*right)%(10**9+7)
l = [(k**2)%(10**9+7) for k in a]
print(((c+(10**9+7)-sum(l))**(10**9+5))%(10**9+7))

n = int(input())
a = list(map(int, input().split()))
left = 0
right = 0
for i in range(n):
  left += a[i]
  left %= (10**9+7)
for j in range(n):
  right += a[j]
  right %= (10**9+7)
c = (left*right)%(10**9+7)
l = [(k**2)%(10**9+7) for k in a]
print(((c+(10**9+7)-sum(l)%(10**9+7))*pow(2, 10**9+5, 10**9+7))%(10**9+7))

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

mod = 1000000007

ans = 0
tmp1, tmp2 = 0, 0

for m in A:
  tmp1 = (tmp1+m) %mod
  tmp2 = (tmp2+m*m%mod)%mod
  
ans = ((tmp1*tmp1)%mod-tmp2)%mod

if ans%2 ==0:
  ans = ans/2
else:
  ans =(ans+mod)/2

print(float(ans))

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

mod = 1000000007

ans = 0
tmp1, tmp2 = 0, 0

for m in A:
  tmp1 = (tmp1+m) %mod
  tmp2 = (tmp2+m*m%mod)%mod
  
ans = ((tmp1*tmp1)%mod-tmp2)%mod

if ans%2 ==0:
  ans = ans/2
else:
  ans =(ans+mod)/2

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 itertools
# import math
# import sys

import numpy as np

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()


# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

A = np.array(A)
cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)


#     for l in tree[s]:


#             dfs(tree, l[0])
# dfs(tree, 1)


#     arr = []
#     temp = n

#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr

sum_A = sum(A)

tot = 0
for i in range(N):
    tot += A[i] * (sum_A - A[i])
        
print(tot % 1000000007)

# import itertools
# import math
# import sys

import numpy as np

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()


# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

sum_A = sum(A)
A = np.array(A)

cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)


#     for l in tree[s]:


#             dfs(tree, l[0])
# dfs(tree, 1)


#     arr = []
#     temp = n

#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr



tot = 0
for i in range(N):
    tot += int(A[i]) * (sum_A - int(cum_A[i]))
        
print(tot % 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):
import sys
import numpy as np

def main():
    n = int(input())
    A_ = [int(x) for x in input().split()]
    A = [a for a in A_ if a != 0]
    N = len(A)

    mod = 10**9+7
    PR = 2
    order = [1]
    x = PR
    while x != 1:
        order.append(x)
        x *= PR
        x %= mod

    order_l = len(order)
    where = np.zeros(mod, int)
    for i in range(order_l):
        where[order[i]] = i
    prevCnt = np.zeros(mod, int)
    resCnt = np.zeros(mod, int)
    for n in range(N):
        if A[n] != 0:
            prevCnt[where[A[n]]] += 1
            resCnt[(A[n] * A[n]) % mod ] -= 1
    N_=1
    while N_ < 2*len(prevCnt): N_ *= 2
    nf = np.zeros(N_,int)
    nf[:len(prevCnt)]=prevCnt
    nf=np.fft.rfft(nf)
    fftRes = np.rint( np.fft.irfft(nf*nf))
    for r in range(len(fftRes)):
        if fftRes[r] != 0:
            resCnt[order[r % order_l]] += fftRes[r]
    ans = 0
    for p in range(mod):
        if resCnt[p] != 0:
            ans += (resCnt[p] // 2) * p
    print(ans)

if __name__ == '__main__':
    main()

def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    mod = 10**9+7
    
    a_cum = [0] * (n+1)
    for i in range(n):
        a_cum[i + 1] = a_cum[i] + A[i]
    ans = 0
    for i in range(len(A)-1):
        ans += A[i] * (a_cum[n] - a_cum[i+1])
    ans %= mod
    print(ans)

if __name__ == '__main__':
    main()


Verdicts: 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 = list(map(int, input().split()))
sum = 0

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

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

print(ans)


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

sum = 0

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

print(ans)


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

sum = 0

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

print(ans)

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

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

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

print(ans)


Verdicts: Runtime Error

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

n=int(input())  #->n=5
a=list(map(int,input().split()))  #->nl=[1,2,-,n]

temp = 0
for i in range(n-1):
    for j in range(i+1,n):
        temp = temp + a[j]
    temp = temp*a[i]
    temp = temp % (10**9+7)

print(temp)



#!/usr/bin/env python3

n=int(input())  #->n=5
a=list(map(int,input().split()))  #->nl=[1,2,-,n]
mod=int(1e9+7)


pre=[0]*n
pre[0]=a[0]
for i in range(1,n):  pre[i]=pre[i-1]+a[i]
ans=0
for i in range(1,n):  ans=(ans+(a[i-1]*(pre[n-1]-pre[i-1]))%mod)%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()))
MOD=7+10**9
ans=0
for i in range(len(A)-1):
    for j in range(i+1,len(A)):
        print(A[i],A[j])
        ai= A[i] % MOD
        aj=A[j] % MOD
        ans = ans +ai*aj % MOD
print(ans%MOD)

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

MOD=7+10**9
SUM=sum(A)
ans=0

for i in range(N-1):
    SUM-=A[i]
    ans += A[i]*SUM %MOD
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):
n=int(input())
a=list(map(int,input().split()))
b=0
for i in range(n-1):
  for j in range(i+1,n):
    b=(b+i*j)%(10^9+7)
print(b)


n=int(input())
a=list(map(int,input().split()))
b=sum(a)%(10^9+7)
for i in range(len(a)):
  a[i]=(a[i]%(10^9+7))*b
print(sum(a))

n=int(input())
a=list(map(int,input().split()))
b=sum(a)
l=[]
for i in range(len(a)-1):
  b-=a[i]
  l.append(a[i]*b)
print(sum(l)%(1000000007))


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 itertools

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

result = 0
for aa in itertools.combinations(aaa, 2):
  result += aa[0] * aa[1]
  
print(result % 10 ** 9 + 7)

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

sum_a = 0
sum_aa = 0
for a in aaa:
  sum_a += a
  sum_aa += a ** 2
  
print(((sum_a ** 2 - sum_aa) // 2) % (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()))
count = 0
su = sum[a]
for i in range(n-1):
	su -= a[i]
	count += a[i]*su
print(count%(10**9+7))

n = int(input())
a = list(map(int,input().split()))
count = 0
su = sum(a)
for i in range(n-1):
	su -= a[i]
	count += a[i]*su
print(count%(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):
A = list(map(int, input().split()))

B = [0]*N

num = 0
for i in reversed(range(N)):
    B[i] = A[i] + num
    num = B[i]
    
ans = 0
for i in range(N-1):
    ans += A[i]*B[i+1] 

print(ans%1000000007)

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

B = [0]*N

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

print(ans%1000000007)

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()))
mod = 1000000000 + 7
add = 0
for i in range(N):
    tmp = sum(A[i+1:N])
    add += tmp * A[i]
print(add%mod

N = int(input())
A = list(map(int,input().split()))
mod = 1000000000 + 7
add = 0
tmp = sum(A)
for i in range(N):
    tmp -= A[i]
    add += tmp * A[i]
print(add%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):
n = int(input())
a = list(map(int,input().strip().split()))

m = 10 ** 9 + 7
def main():
    r = 0
    for nn in range(n):
        r += a[nn]
    print(r)
    return

main()


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


m = 10 ** 9 + 7
def main():
    s = sum(a)
    ss = 0
    r = 0
    for nn in range(n):
        ss += a[nn]
        r += a[nn] * (s - ss)
    print(r % m)
    return

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

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

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

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

print(ans)


N = int(input())

A = list(map(int, input().split()))
S = sum(A)
ans = 0
for i in range(N):
    S -= A[i]
    ans += A[i] * S
    

ans = 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):
mod = 10 ** 9 + 7
n = int(input())
a_list = list(map(int, input().split()))
result = 0
a_sum = sum(a)
for i in a_list:
    a_sum -= i
    result += i * a_sum
print(result % mod)

mod = 10 ** 9 + 7
n = int(input())
a_list = list(map(int, input().split()))
result = 0
a_sum = sum(a)
for i in a_list:
    a_sum -= i
    result += i * a_sum
print(result % mod)

mod = 10 ** 9 + 7
n = int(input())
a_list = list(map(int, input().split()))
result = 0
a_sum = sum(a_list)
for i in a_list:
    a_sum -= i
    result += i * a_sum
print(result % 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())
a = list(map(int,input().split()))
def p(val):
    print(val)
 
sho = 10**9 +7
a1 = sum(a)**2
b1 = list(map(lambda y:y**2,a))
b2=sum(b1)
result = ((a1-b2)/2)% sho
p(result)

n=int(input())
a = list(map(int,input().split()))
def p(val):
    print(val)
 
sho = 10**9 +7
a1 = sum(a)**2
b1 = list(map(lambda y:y**2,a))
b2=sum(b1)
result = ((a1-b2)//2)% sho
p(result)

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
import itertools as it

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

combinations_lis = list(it.combinations(a, 2))
print(combinations_lis)

sum = 0
for i in range(len(combinations_lis)):
    sum += combinations_lis[i][0] * combinations_lis[i][1]
print(sum % (10 ** 9 + 7))




#print(sum)

# ans = int(sum * np.prod(a))



# import numpy as np
# import itertools as it

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

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

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





#print(sum)

# ans = int(sum * np.prod(a))



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 functools
import operator

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

for i in range(2**len(A)):\
    list2 = []
    for j in range(len(A)):
        if (i >> j) &1 == 1:
            list2.append(A[j])
    if len(list2) == 2:
        ans += list2[0]*list2[1]
#        print(ans)
#    print(list2)
    ans = ans%mod
print(ans)


import functools
import operator

N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
ans = 0
v = sum(A)
for i in range(N-1):
    v -= A[i]
    ans += A[i]*v
print(ans%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):
N = int(input())
A = list(map(int, input().split()))
 
s = 0
for i in range(N):
  s += A[i]
  s %= (10**9+7)
s = s**2
s %= (10**9+7)
 
t = 0
for i in range(N):
  t += (A[i]**2 % (10**9+7))
t %= (10**9+7)

ans = (s-t) % (10**9+7)
tmp = (2**1000000005) % (10**9+7)
ans *= tmp
ans %= (10**9+7)
print(ans)

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


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

ans = (ans * 500000004) % mod

print(ans)

Verdicts: 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):
input()
a = list(map(int, input().split()))
c = 1000000007
print(((sum(a)**2-sum(map(lambda x: x**2, a)))/2)%c)

input()
a = list(map(int, input().split()))
c = 1000000007
print(((sum(a)**2-sum(map(lambda x: x**2, a)))//2)%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()))
mod = 1000000007
res = 0

for i in range(n - 1):
    for j in range(n - (i + 1)):
        print(a[i] , '*' , a[i + (j + 1)])
        res =  (res + a[i] * a[i + (j + 1)] % mod) % mod

print(res)


n = int(input())
a = set(list(map(int, input().split())))
mod = 1000000007
res = 0


for i in range(n - 1):
    main = a.pop(0)
    res =  (res + main * sum(a) % mod) % mod
print(res)

n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
res = 0
a_sum = sum(a)

for i in range(n - 1):
    main = a[i]
    a_sum = a_sum - main
    res =  (res + main * a_sum % mod) % mod
print(res)

Verdicts: 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):
N = int(input())
A = list(map(int,input().split()))
summ1 = 0
answer = 0
temp = 0
summ2 = 0
summ3 = 0
for i in range(N):
    summ1 += A[i]
for l in range(N):
    summ3 += A[l]
    summ2 += A[l]*(summ1-summ3)
    print(summ3)
    print(summ2)
answer = summ2 % 1000000007
print(answer)

N = int(input())
A = list(map(int,input().split()))
summ1 = 0
answer = 0
temp = 0
summ2 = 0
summ3 = 0
for i in range(N):
    summ1 += A[i]
for l in range(N):
    summ3 += A[l]
    summ2 += A[l]*(summ1-summ3)
answer = summ2 % 1000000007
print(answer)

Verdicts: Wrong Answer

Accepted