ZhenlongDai/ACPR huggingface dataset:
Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
a = list(map(int, input().split()))

mod = 10 ** 9 + 7

b = [[0, 0] for _ in range(n)]
for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            if i > j:
                b[i][0] += 1
            else:
                b[i][1] += 1
ans = 0
sigmakp = int(k*(k+1)/2)
sigmakn = int(k*(k-1)/2)
for i in range(n):
    ans = ((sigmakp * b[i][1] % mod) + (sigmakn * b[i][0] % mod) + ans) % mod
print(ans)

Failing test case input:
10 998244353
20 9 8 7 8 10 0 4 1 2

Expected output:
37991573


Actual output:
37991538


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
a = list(map(int, input().split()))

mod = 10 ** 9 + 7
k = k % mod

b = [[0, 0] for _ in range(n)]
for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            if i > j:
                b[i][0] += 1
            elif i < j:
                b[i][1] += 1
    b[i][0] = b[i][0] % mod
    b[i][1] = b[i][1] % mod
ans = 0

if k%2 == 0:
    sigmakp = (int(k/2) * (k+1)) % mod
    sigmakn = (int(k/2) * (k-1)) % mod
else:
    sigmakp = (int((k+1)/2) * k) % mod
    sigmakn = (int((k-1)/2) * k) % mod

for i in range(n):
    mae = (sigmakp * b[i][1]) % mod
    ushiro = (sigmakn * b[i][0]) % mod
    ans = ((mae + ushiro) % mod + ans) % mod 
print(ans)

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

prime = 10**9+7

def sowa(num):
  return int((1+num)*num/2)

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

tento1 = [sum([1 if a[i]>a[j] else 0 for j in range(i+1,n)]) for i in range(n-1)]
tento2 = [sum([1 if a[i]>a[j] else 0 for j in range(n)]) for i in range(n)]


ret = (sum(tento1) *k %prime) + (sum(tento2) *(sowa(k) %prime) %prime)
print(ret%prime)


Failing test case input:
10 1652783124
20 9 1 7 5 4 0 4 0 2

Expected output:
245707207


Actual output:
315383020


Fixed submission (verdict: Accepted):

prime = 10**9+7

def sowa(num):
  return int((1+num)*num

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

tento1 = [sum([1 if a[i]>a[j] else 0 for j in range(i+1,n)]) for i in range(n-1)]
tento2 = [sum([1 if a[i]>a[j] else 0 for j in range(n)]) for i in range(n)]


ret = (sum(tento1) *k %prime) + (sum(tento2) *(sowa(k-1) %prime) %prime)
print(int(ret%prime))
Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int,input().split())
An = list(map(int,input().split()))
f_count = 0
r_count = 0

for i in range(N):
    for j in range(N):
        if i < j:
            if An[i] < An[j]:
                f_count += 1
            elif An[i] > An[j]:
                r_count += 1

Ans = f_count + (f_count * K*(K-1)/2 + r_count * K*(K+1)/2) % (10**9+7)

print(int(Ans))

Failing test case input:
10 872422839
13 9 8 7 3 5 5 4 4 1

Expected output:
908226379


Actual output:
908227007


Fixed submission (verdict: Accepted):
N, K = map(int,input().split())
An = list(map(int,input().split()))
f_count = 0
r_count = 0

for i in range(N):
    for j in range(N):
        if i < j:
            if An[i] < An[j]:
                f_count += 1
            elif An[i] > An[j]:
                r_count += 1

Ans = (f_count * K*(K-1)

print(int(Ans))

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
la = list(map(int, input().split()))

count = 0
for i in range(n):
    for j in range(n-i-1):
        jj = j+1+i
        if la[i] > la[jj]:
            count += 1

count2 = 0
laa = sorted(la)
for i in range(n):
    for j in range(n-i-1):
        jj = j+1+i
      
        if laa[i] < laa[jj]:
            count2 += 1

a = count * k
b = count2 * int((0.5)*(k-1)*k)
result = a+b

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


Failing test case input:
10 1652783124
20 9 1 7 5 4 0 4 0 2

Expected output:
245707207


Actual output:
245710045


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
la = list(map(int, input().split()))
mod = pow(10,9)+7

c = 0
for i in range(n):
    for j in range(n-i-1):
        jj = j+1+i
        if la[i] > la[jj]:
            c += 1

c2 = 0
for i in range(n):
    for j in range(n):
        if la[i] > la[j]:
            c2 += 1

a = c*k
b = c2*((k*(k-1))


print((a+b)%mod)

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

prime = 10**9+7

def sowa(num):
  return int((1+num)*num/2)

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


tento1 = [sum([1 if a[i]>a[j] else 0 for j in range(i+1,n)]) for i in range(n-1)]
tento2 = [sum([1 if a[i]>a[j] else 0 for j in range(n)]) for i in range(n)]


ret = sum(tento1) *k %prime + sum(tento2) *sowa(k-1) %prime
print(ret%prime)


Failing test case input:
10 727991293
10 9 10 7 5 3 0 4 4 1

Expected output:
225136212


Actual output:
225135954


Fixed submission (verdict: Accepted):

prime = 10**9+7

def sowa(num):
  return int((1+num)*num

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

tento1 = [sum([1 if a[i]>a[j] else 0 for j in range(i+1,n)]) for i in range(n-1)]
tento2 = [sum([1 if a[i]>a[j] else 0 for j in range(n)]) for i in range(n)]


ret = (sum(tento1) *k %prime) + (sum(tento2) *(sowa(k-1) %prime) %prime)
print(int(ret%prime))
Problem: p02928
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n, k = map(int, input().split())
a = list(map(int, input().split()))
count = 0
b, c = [], []

for i in range(n):
    count1, count2 = 0, 0
    for j in range(n):
        if a[i] > a[j] and i < j:
            count1 += 1
        elif a[i] > a[j] and i > j:
            count2 += 1
    b.append(count1)
    c.append(count2)

if k == 1:
    print(sum(b))
else:
    print(int(sum(b)*k*(k+1)/2+sum(c)*(k-1)*k/2)%(10**9+7))

        


Failing test case input:
10 727991293
10 9 10 7 3 3 0 6 4 0

Expected output:
646142975


Actual output:
646142828


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
a = list(map(int, input().split()))
count1, count2 = 0, 0

for i in range(n-1):
    for j in range(i+1, n):
        if a[i] > a[j]:
            count1 += 1

for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            count2 += 1
            
print((count1*k+count2*(k*(k-1)

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
mod = 10 ** 9 + 7
for i in range(N):
    
    for j in range(N):
        if a[i] > a[j]:
            cnt += 1
ans = cnt * ((K - 1) * K) % mod * 500000004 % mod
for i in range(N - 1):
    for j in range(i + 1, N):
        if a[i] > a[j]:
            ans += K % mod
print(ans)

Failing test case input:
10 998244353
10 9 8 7 5 6 3 4 4 1

Expected output:
27457649


Actual output:
41027457936


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
mod = 10 ** 9 + 7
for i in range(N):
    
    for j in range(N):
        if a[i] > a[j]:
            cnt += 1
ans = cnt * ((K - 1) * K) * 500000004 % mod
for i in range(N - 1):
    for j in range(i + 1, N):
        if a[i] > a[j]:
            ans += K % mod
print(ans % mod)

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int,input().split())
li = list(map(int,input().split()))
mod = 10**9 +7

ans_1 = 0
ans_2 = 0
for i in range(n-1):
  for j in range(i+1,n):
    if li[i] > li[j]:
      ans_1+= 1
for i in range(n):
  for j in range(n):
    if li[i] < li[j]:
      ans_2 += 1
ans = k*ans_1 + 0.5*k*(k-1)%mod*ans_2
print(int(ans%mod))

Failing test case input:
10 727991293
0 9 10 7 5 3 0 4 4 1

Expected output:
401205910


Actual output:
401205652


Fixed submission (verdict: Accepted):
n,k = map(int,input().split())
li = list(map(int,input().split()))
mod = 10**9 +7
 
ans_1 = 0
ans_2 = 0
for i in range(n):
  for j in range(i+1,n):
    if li[i] > li[j]:
      ans_1+= 1
for i in range(n):
  for j in range(n):
    if li[i] > li[j]:
      ans_2 += 1
ans = k*ans_1%mod + (k*(k-1)
print(int(ans%mod))
Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
a = list(map(int, input().split()))

mod = 10 ** 9 + 7
b = [[0, 0] for _ in range(n)]
for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            if i > j:
                b[i][0] += 1
            else:
                b[i][1] += 1
ans = 0
sigmakp = int(k*(k+1)/2) % mod
sigmakn = int(k*(k-1)/2) % mod
for i in range(n):
    ans = (ans + sigmakp * b[i][1]) % mod
    ans = (ans + sigmakn * b[i][0]) % mod
print(ans%mod)

Failing test case input:
10 727991293
10 9 10 7 5 3 0 4 4 0

Expected output:
102125547


Actual output:
102125406


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
a = list(map(int, input().split()))

mod = 10 ** 9 + 7
k = k % mod

b = [[0, 0] for _ in range(n)]
for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            if i > j:
                b[i][0] += 1
            elif i < j:
                b[i][1] += 1
    b[i][0] = b[i][0] % mod
    b[i][1] = b[i][1] % mod
ans = 0

if k%2 == 0:
    sigmakp = (int(k/2) * (k+1)) % mod
    sigmakn = (int(k/2) * (k-1)) % mod
else:
    sigmakp = (int((k+1)/2) * k) % mod
    sigmakn = (int((k-1)/2) * k) % mod

for i in range(n):
    mae = (sigmakp * b[i][1]) % mod
    ushiro = (sigmakn * b[i][0]) % mod
    ans = ((mae + ushiro) % mod + ans) % mod 
print(ans)

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=map(int,input().split())

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

d=10**9+7

c=0

for i in range(N-1):
    for j in range(i+1,N):
        if A[i]>A[j]:
            c+=1
            c=c%d


cc=0

for i in range(N):
    for j in range(N):
        if A[i]>A[j]:
            cc+=1
            cc=cc%d



e=(K*(K-1)/2)%d

print(int(((c*K)%d+(cc*e)%d)%d))




Failing test case input:
10 1652783124
20 9 1 7 5 4 0 4 0 2

Expected output:
245707207


Actual output:
245710045


Fixed submission (verdict: Accepted):
N,K=map(int,input().split())

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

d=10**9+7

c=0

for i in range(N-1):
    for j in range(i+1,N):
        if A[i]>A[j]:
            c+=1
c=c%d

cc=0

for i in range(N):
    for j in range(N):
        if A[i]>A[j]:
            cc+=1

cc=cc%d

e=(K*(K-1)

print(int(((c*K)%d+(cc*e)%d)%d))
Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    def c(x,y):
        if x > y:
            return 1
        else:
            return 0
    n,k = map(int,input().split())
    x = 1000000007
    kk = int(k*(k-1)/2)%x
    a = list(map(int,input().split()))
    c1 = []
    c2 = []
    for i in range(n):
        l = [c(a[i],p) for p in a]
        c1.append(sum(l))
        c2.append(sum(l[i+1:]))
    ans = (sum(c1)%x)*kk+(sum(c2)%x)*k
    print(ans%x)
    
if __name__ == '__main__':
    main()

Failing test case input:
10 727991293
10 9 10 7 5 3 0 4 4 0

Expected output:
102125547


Actual output:
102125295


Fixed submission (verdict: Accepted):
def main():
    def c(x,y):
        if x > y:
            return 1
        else:
            return 0
    n,k = map(int,input().split())
    x = 1000000007
    kk = int(k*(k-1)
    a = list(map(int,input().split()))
    c1 = []
    c2 = []
    for i in range(n):
        l = [c(a[i],p) for p in a]
        c1.append(sum(l))
        c2.append(sum(l[i:]))
    ans = ((sum(c1)%x)*kk)%x+((sum(c2)%x)*k)%x
    print(ans%x)
    
if __name__ == '__main__':
    main()

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
la = list(map(int, input().split()))

count = 0
for i in range(n):
    for j in range(n-i-1):
        jj = j+1+i
        if la[i] > la[jj]:
            count += 1

num = len(set(la)) - 1
result = (count*k) + ((1/2)*(num)*(num+1))*((1/2)*(k-1)*(k))
print(int(result%(pow(10,9)+7)))

Failing test case input:
3 5
0 1 1

Expected output:
20


Actual output:
10


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
la = list(map(int, input().split()))
mod = pow(10,9)+7

c = 0
for i in range(n):
    for j in range(n-i-1):
        jj = j+1+i
        if la[i] > la[jj]:
            c += 1

c2 = 0
for i in range(n):
    for j in range(n):
        if la[i] > la[j]:
            c2 += 1

a = c*k
b = c2*((k*(k-1))


print((a+b)%mod)

Problem: p02928
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
A = list(map(int, input().split()))

x = 0
for l in range(N - 1):
  for r in range(l + 1, N):
    if A[l] > A[r]:
      x += 1

      
AA = A + A
y = 0
for l in range(2 * N - 1):
  for r in range(l + 1, 2 * N):
    if AA[l] > AA[r]:
      y += 1
y -= 2 * x

  


kkmod = (K * (K - 1)) % (10 ** 9 + 7)
ans = (K * x + 1 / 2 * kkmod * y) % (10 ** 9 + 7)
print(int(ans))

Failing test case input:
10 1468376359
10 1 17 7 9 0 1 4 4 2

Expected output:
954097170


Actual output:
454097166


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
A = list(map(int, input().split()))

x = 0
for l in range(N - 1):
  for r in range(l + 1, N):
    if A[l] > A[r]:
      x += 1

      
AA = A + A
y = 0
for l in range(2 * N - 1):
  for r in range(l + 1, 2 * N):
    if AA[l] > AA[r]:
      y += 1
y -= 2 * x

  
print(int((K * x + K * (K - 1) * y
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
m=1e9+7

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

	array_sum_square = (array_sum * array_sum )%m

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

	return (array_sum_square -
			individual_square_sum) / 2

n = int(input())
A = list(map(int,input().split()))
 
print(int(int(findProductSum(A, n))%m)) 
	


Failing test case input:
4
2519048 4102 176 11813

Expected output:
585259054


Actual output:
85259050


Fixed submission (verdict: Accepted):
m = 1000000000+7


def findProductSum(A, n):

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

    array_sum_square = (array_sum * array_sum) % m

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

    aaa=(array_sum_square-individual_square_sum+m)%m
    inv=pow(2,m-2,m)
    anss=aaa*inv

    return anss


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

print(int(int(findProductSum(A, n)) % m))

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    n = int(input())
    A = list(map(int, input().split()))

    mod = 10**9 + 7
    s = sum(A)
    ans = 0
    for i in range(n):
        print(ans)
        s -= A[i]
        ans += A[i]*s
    print(ans%mod)


if __name__ == '__main__':
    main()


Failing test case input:
4
6341164 101747 435150 75715

Expected output:
599495990


Actual output:
0
3884673160368
3936652141523
3969599523773
599495990


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    n = int(input())
    A = list(map(int, input().split()))

    mod = 10**9 + 7
    s = sum(A)
    ans = 0
    for i in range(n):
        s -= A[i]
        ans += A[i]*s
    print(ans%mod)


if __name__ == '__main__':
    main()

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
sum = 0
sum_1 = 0

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

for j in range(N):
    sum_1 += (A[j]**2)%mod
sum2=sum-sum_1
if sum2<0:
    sum2+=mod
ans=(sum2/2)%mod
print(int(ans))


Failing test case input:
4
141421356 15438004 44188846 176612

Expected output:
24018621


Actual output:
524018624


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
sum = 0
sum_1 = 0

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

for j in range(N):
    sum_1 += (A[j]**2)%mod
sum2=sum-sum_1
if sum2<0:
    sum2+=mod
ans=(sum2*500000004)%mod
print(int(ans))
Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

from itertools import combinations

num = 10**9 + 7
ans = 0

B = []
b = 0
for i in reversed(A[1:]):
    b += i
    B.append(b)
B.reverse()
print(B)
for x, y in zip(A[:-1], B):
    ans += x*y
    ans %= num
print(ans)


Failing test case input:
4
3855157 98660 9743 12204

Expected output:
243111622


Actual output:
[120607, 21947, 12204]
243111622


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))

from itertools import combinations

num = 10**9 + 7
ans = 0

B = []
b = 0
for i in reversed(A[1:]):
    b += i
    B.append(b)
B.reverse()
for x, y in zip(A[:-1], B):
    ans += x*y
    ans %= num
print(ans)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

ans = 0
x = 0

for a in A:
    ans = (ans + a * x) % (1e9+7)
    x = (x + a) % (10e9+7)

print(ans)


Failing test case input:
4
14846625 2224125 5164610 29158

Expected output:
853759681


Actual output:
853759681.0


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))


sum_a = sum(A)
ans = 0
mod = int(1e9+7)

for a in A:
    sum_a -= a
    ans += (sum_a * a) % mod

ans %= mod
print(int(ans))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys

input = sys.stdin.buffer.readline

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

cumsum = [0]
for i in range(1, N):
    v = (A[0] * A[i]) % MOD
    cumsum.append((cumsum[-1] + v) % MOD)
print(cumsum)

ans = 0
for i in range(N):
    ans += (A[i] * (cumsum[-1] - cumsum[i])) % MOD
    ans %= MOD
print(ans)


Failing test case input:
4
36257838 139427 593808 70292

Expected output:
485012386


Actual output:
[0, 321543441, 515659835, 151590688]
396482968


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.buffer.readline
MOD = 10**9 + 7

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

C = [0]
for i in range(1, len(A)):
    C.append(C[-1] + A[i])

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

ans %= MOD
print(ans)
Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):

import collections
from functools import lru_cache
import bisect

INF = float("inf")
ZERO = 0
ONE = 1


def read():
    return input().strip()


def readInt():
    return int(input().strip())


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


def solve(N, arr):
    s = sum(arr)
    ans = 0
    MOD = 10**9 + 7

    for num in arr:
        ans = (ans + (s-num)*num) % MOD

    return (ans % MOD) 


N = readInt()
arr = readList()

print(solve(N, arr))


Failing test case input:
4
2509638 64145 5782 5951

Expected output:
213332794


Actual output:
426665588


Fixed submission (verdict: Accepted):

import collections
from functools import lru_cache
import bisect

INF = float("inf")
ZERO = 0
ONE = 1


def read():
    return input().strip()


def readInt():
    return int(input().strip())


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


def solve(N, arr):
    ans = 0
    MOD = 10**9 + 7
    prefixSums = [0]

    for num in arr:
        prefixSums.append(prefixSums[-1] + num)

    for i, num in enumerate(arr):
        ans = (ans + num * (prefixSums[-1] - prefixSums[i+1])) % MOD

    return ans % MOD


N = readInt()
arr = readList()

print(solve(N, arr))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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

for i in range(1, t + 1):
    solve(i)


Failing test case input:
4
3855157 98660 9743 12204

Expected output:
243111622


Actual output:
243111622.0


Fixed submission (verdict: Accepted):
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

for i in range(1, t + 1):
    solve(i)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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))

Failing test case input:
4
141421356 2224125 5164610 29158

Expected output:
658249038


Actual output:
658249038.0


Fixed submission (verdict: Accepted):
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))
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

M = 0

for i in range(1,N-1):
  for j in range(i+1,N):
    M  += A[i] * A[j]
    if  M > 10**9 + 7:
      M = M %(10**9 +7)
print(M)

Failing test case input:
4
141421356 2224125 4405286 29158

Expected output:
57428667


Actual output:
207020751


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))

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

for i in range(N-1):
  sum = sum - A[i]
  M += A[i] * sum
  if M > 10 ** 9 + 7:
    M = M % (10 ** 9 + 7)
print(M)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
sum_A = sum(A)
ans = 0

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

Failing test case input:
4
1069110 84292 143968 6344

Expected output:
400912688


Actual output:
18


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
sum_A = sum(A)
ans = 0

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

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
s=sum(a[1:])
ans=0
for i in range(1,n):
    ans+=a[i-1]*s
    s-=a[i]
print(ans)

Failing test case input:
4
6341164 105854 435150 70292

Expected output:
418782092


Actual output:
3960418809812


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

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
sum = 0
for i in range(1, N):
   sum +=A[i-1]
   sum = sum % (10**9 + 7)
   ans = (sum * A[i]) % (10**9 + 7)
print(ans)

Failing test case input:
4
6341164 105854 435150 75715

Expected output:
740778897


Actual output:
83346473


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

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
ans=0
for i in a:
    ans+=i*(s-i)
    s=(s-i)
print(ans)


Failing test case input:
4
10344776 230 6 33

Expected output:
782753898


Actual output:
2782753912


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
m=10**9+7
s=sum(a)%m
ans=0
for i in a:
    ans+=i*(s-i)
    ans%=m
    s=(s-i)%m
print(ans)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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)


Failing test case input:
4
2519048 3927 176 1307

Expected output:
634103362


Actual output:
634103362.0


Fixed submission (verdict: Accepted):
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))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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)))

Failing test case input:
4
1988253 116846 9743 12204

Expected output:
638919417


Actual output:
669689782


Fixed submission (verdict: Accepted):
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)))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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)%(10^9+7))

Failing test case input:
4
141421356 2224125 5164610 29158

Expected output:
658249038


Actual output:
4


Fixed submission (verdict: Accepted):
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))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import copy
mod=(10**9)+7
def calc(nums,n):
    if n==1:
        return 0
    if n==2:
        return nums[0]*nums[1]
    cpy=copy.deepcopy(nums)    
    save=nums[n-2]
    nums[n-2]=nums[n-1]
    for i in range(n-3,-1,-1):
        s=nums[i]
        nums[i]=save+nums[i+1]
        save=s
    ans=0  
    print(nums)
    for i in range(n-1):
        ans=((ans%mod)  +  ((cpy[i]%mod)*(nums[i]%mod))%mod)%mod
    return ans       
       





n=int(input())
nums=list(map(int,input().split()))
print(calc(nums,n))


Failing test case input:
4
27651699 119786 2501999 47420

Expected output:
82206585


Actual output:
[2669205, 2549419, 47420, 47420]
82206585


Fixed submission (verdict: Accepted):
import copy
mod=10**9+7
def calc(nums,n):
    if n==2:
        return ((nums[0]%mod)*(nums[1]%mod))%mod
    cpy=copy.deepcopy(nums)    
    save=nums[n-2]
    nums[n-2]=nums[n-1]
    for i in range(n-3,-1,-1):
        s=nums[i]%mod
        nums[i]=(save%mod+nums[i+1]%mod)%mod
        save=s%mod
       
    ans=0  
    
    for i in range(n-1):
        ans=((ans%mod)  +  ((cpy[i]%mod)*(nums[i]%mod))%mod)%mod
    return ans       
    





n=int(input())
nums=list(map(int,input().split()))
print(calc(nums,n))
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
wa = 0
a = 0
for l in range(N-1):
    a += A[N-l-1]
    wa += a * A[N-l-2]
print(wa)

Failing test case input:
4
141421356 1512598 4405286 176612

Expected output:
478491412


Actual output:
869600484578612


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
wa = 0
a = 0
for l in range(N-1):
    a += A[N-l-1]
    wa += a * A[N-l-2]
print(wa % (10**9+7))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():

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


    m = 10**9 + 7
    ans = 0
    s = sum(a)
    for i in a:
        tmp = (s - i) % m
        ans += tmp * i
    ans 
    print(ans%m)

if __name__=='__main__':
    main()


Failing test case input:
4
1069110 84292 143968 43424

Expected output:
507391952


Actual output:
14783897


Fixed submission (verdict: Accepted):
def main():

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


    m = 10**9 + 7
    ans = 0
    s = []
    total = sum(a)
    s.append(total-a[0])
    for i in range(1,n):
        s.append(s[i-1] - a[i])
    for i in range(n):
        tmp = s[i] % m
        ans += tmp * a[i]
    
    print(ans%m)

if __name__=='__main__':
    main()

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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))

Failing test case input:
4
3646424 64145 127 11813

Expected output:
205559645


Actual output:
3646424 64145
3646424 127
3646424 11813
64145 127
64145 11813
127 11813
205559645


Fixed submission (verdict: Accepted):
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)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

import sys

MOD = 1000000007  


def solve(N: int, A: "List[int]"):
    x = sum(A)

    ans = 0

    for i in range(N):
        x -= A[i]
        y = x%MOD
        z = (y*A[i])%MOD

        ans +=z

    return print(ans)



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)

if __name__ == '__main__':
    main()


Failing test case input:
4
6341164 105854 435150 75715

Expected output:
740778897


Actual output:
1740778904


Fixed submission (verdict: Accepted):

import sys
from itertools import accumulate
MOD = 1000000007  


def solve(N: int, A: "List[int]"):
    aa = list(accumulate(A))
    
    x = sum(A)
    

    ans = 0

    for i in range(N):
        ans += A[i]*(aa[N-1]-aa[i])%MOD
        ans %= MOD
    return print(ans)



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)

if __name__ == '__main__':
    main()

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
S = [A[0]]
for i in range(1, N):
  S.append(S[i-1] + A[i])
print(S)
x = 0
for i in range(N):
  x += (A[i] * (S[-1] - S[i])) % 1000000007
x = x % 1000000007
print(x)

Failing test case input:
4
141421356 2224125 4405286 176612

Expected output:
735073075


Actual output:
[141421356, 143645481, 148050767, 148227379]
735073075


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
S = [A[0]]
for i in range(1, N):
  S.append(S[i-1] + A[i])
x = 0
for i in range(N):
  x += (A[i] * (S[-1] - S[i])) % 1000000007
x = x % 1000000007
print(x)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
m = 10 ** 9 + 7

total_A = 0
for i in range(N):
    total_A = (total_A + A[i]) % m

total = (total_A * total_A) % m

total_sq = 0
for i in range(N):
    total_sq = (total_sq + A[i] * A[i]) % m

divide = total - total_sq
if divide < 0:
    divide += m

print(int(divide / 2))


Failing test case input:
4
6341164 105854 435150 75715

Expected output:
740778897


Actual output:
240778893


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
m = 10 ** 9 + 7

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

total_rev = [0] * (N + 1)
for i in range(N):
    total_rev[i] = total[N] - total[i]

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

print(ans)
Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))

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

Failing test case input:
4
12645692 101747 435150 75715

Expected output:
828976092


Actual output:
7831829030909


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))

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

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
arr = list(map(int, input().split(" ")))

mod = 10 ** 9 + 7

slist = sum(arr)

result = 0
for i in arr:
  result += i * (slist - i)
  result %= mod
print(result)


Failing test case input:
4
3646424 64145 903 6247

Expected output:
436075051


Actual output:
872150102


Fixed submission (verdict: Accepted):
N = int(input())
arr = list(map(int, input().split(" ")))

mod = 10 ** 9 + 7

s = sum(arr) % mod

result = 0
for i in arr:
  s -= i
  s %= mod
  result += s * i
  result %= mod
print(result)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline

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



mass = [0]*(N+1)
for i in range(N):
    mass[i+1] = mass[i] + A[i]
print(mass)
answer = 0
for i in range(N-1):
    answer += (A[i]*(mass[N]-mass[i+1]))
    print(answer)

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

Failing test case input:
4
27651699 119786 2426618 72528

Expected output:
279308277


Actual output:
[0, 27651699, 27771485, 30198103, 30270631]
72417919365468
72717282068224
72893279818528
279308277


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline

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

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

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


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

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = sorted(list(map(int, input().split())))

ans = 0
MOD = 10**9+7
total = 0

for i in range(N):
    total += A[i]
    total %= MOD

for i in range(N-1):
    tmp = A[i]
    total -= tmp
    total = total if total >= 0 else total + MOD

    ans += (tmp * total) % MOD

print(ans)

Failing test case input:
4
2509638 64145 5782 12204

Expected output:
343352627


Actual output:
2343352641


Fixed submission (verdict: Accepted):
N = int(input())
A = sorted(list(map(int, input().split())))

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

for i in range(N-1):
    tmp = A[i]
    total -= tmp
    ans += (tmp * total) % MOD
    ans %= MOD

print(ans)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
LI = lambda: list(map(int, input().split()))

N = int(input())
A = LI()

MOD = 10 ** 9 + 7


def main():
    s = sum(A) % MOD
    ans = s * s % MOD
    for a in A:
        ans = (ans - a ** 2) % MOD
    ans = ans 
    print(ans)


if __name__ == "__main__":
    main()


Failing test case input:
4
28568719 211119 10406344 94229

Expected output:
766457999


Actual output:
532915991


Fixed submission (verdict: Accepted):
LI = lambda: list(map(int, input().split()))

N = int(input())
A = LI()

MOD = 10 ** 9 + 7


def modinv(x):
    return pow(x, MOD - 2, MOD)


def main():
    s = sum(A) % MOD
    ans = s * s % MOD
    for a in A:
        ans = (ans - a ** 2) % MOD
    ans = ans * modinv(2) % MOD
    print(ans)


if __name__ == "__main__":
    main()

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))

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

ans = ans
print(ans)

Failing test case input:
4
1069110 84292 143968 6344

Expected output:
400912688


Actual output:
264400914536


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))

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

ans = ans % 1000000007
print(ans)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
mod = 10 ** 9 + 7


N = int(input().rstrip())
As = list(map(int, input().rstrip().split()))
ans = 0
add = 0

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

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

ans *= (mod + 1) / 2

print(ans % mod)

Failing test case input:
4
4932847 3416 189 862

Expected output:
38780529


Actual output:
38780529.0


Fixed submission (verdict: Accepted):

mod = 10 ** 9 + 7


N = int(input().rstrip())
As = list(map(int, input().rstrip().split()))
ans = 0
add = 0

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

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

ans *= int((mod + 1) / 2)
ans %= mod

print(ans)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
s,ss =0,0
for i in range(N):
    s += A[i]
    ss += A[i]**2
    s %= mod
    ss %=mod
a = int((s**2-ss)/2)
print(a%mod)

Failing test case input:
4
28568719 211119 10406344 94229

Expected output:
766457999


Actual output:
266457995


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
a,s = 0,0
for i in range(N):
    a += s*A[i]
    s += A[i]
    a %= mod
print(a)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
import collections
import itertools

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

    B=[0]*N
    B[N-1]=A[N-1]
    MOD=10**9+7
    for j in range(N-2,0,-1):
        B[j]=(B[j+1]+A[j])%MOD
   
    ans=0
    for i in range(N-1):
        ans=ans%MOD+(A[i]*B[i+1])%MOD

    print(ans)

resolve()

Failing test case input:
4
27651699 119786 2426618 72528

Expected output:
279308277


Actual output:
1279308284


Fixed submission (verdict: Accepted):
import math
import collections
import itertools

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

    B=[0]*N
    B[N-1]=A[N-1]
    MOD=10**9+7
    for j in range(N-2,0,-1):
        B[j]=(B[j+1]+A[j])%MOD
   
    ans=0
    for i in range(N-1):
        ans=ans%MOD+(A[i]*B[i+1])%MOD

    print(ans%MOD)

resolve()

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7

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

ans += (A[0] * A[-1])

print(ans % mod)


Failing test case input:
4
2519048 3927 227 749

Expected output:
354895035


Actual output:
780129823


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7

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

print(ans % mod)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import itertools
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    hoge = tuple(map(int, input().split()))
    sumn = 0
    for pair in list(itertools.combinations(hoge, 2)):
        sumn += (pair[0] * pair[1])
    print(sumn)

if __name__ == '__main__':
    main()

Failing test case input:
4
6160134 101747 435150 75715

Expected output:
698346407


Actual output:
3858698373413


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()


def main():
    _ = int(input())
    nums = tuple(map(int, input().split()))
    mod = 10 ** 9 + 7

    num_sum = sum(nums)
    part_sum = sum(map(lambda x: x**2, nums)) 

    print((num_sum**2 - part_sum) 


if __name__ == '__main__':
    main()

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = input()
 
max = 10**9 + 7
 
a_list = [int(a) % max for a in input().split(" ")]

print(sum(a_list))
total = 0
for i in range(0, len(a_list)-1):
    total += a_list[i] * sum(a_list[i+1:])
total = total % max
print(total)


Failing test case input:
4
2519048 3927 176 749

Expected output:
226185111


Actual output:
2523900
226185111


Fixed submission (verdict: Accepted):
n = input()
 
max = 10**9 + 7
 
a_list = [int(a) % max for a in input().split(" ")]
a_sum = sum(a_list)

total = 0
for i in range(0, len(a_list)-1):
    a_sum -= a_list[i]
    total += a_list[i] * a_sum
total = total % max
print(total)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import functools
import operator

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

for i in range(1,N):
    tmp = A[i:]

    ans += i*sum(tmp)%mod
print(ans)


Failing test case input:
4
14846625 2224125 5164610 29158

Expected output:
853759681


Actual output:
17892903


Fixed submission (verdict: Accepted):
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)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

MOD = 10 ** 9 + 7

total = 0
for a in A:
    total += a
    total %= MOD

ans = 0
for a in A:
    ans += (a * total) % MOD
    ans -= a * a
    ans %= MOD

ans 
ans %= MOD

print (ans)

Failing test case input:
4
4932847 3416 189 33

Expected output:
946461856


Actual output:
892923705


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))

MOD = 10 ** 9 + 7

B = [0] * (N + 1)
for i in range(N):
    B[i + 1] = (B[i] + A[i]) % MOD

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

print (ans)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))











ans = 0
x = 0

for a in A:
    ans = (ans + a * x) % (10e9+7)
    x = (x + a) % (10e9+7)

print(int(ans))


Failing test case input:
4
141421356 15438004 44188846 176612

Expected output:
24018621


Actual output:
5081664916


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))


sum_a = sum(A)
ans = 0
mod = int(1e9+7)

for a in A:
    sum_a -= a
    ans += (sum_a * a) % mod

ans %= mod
print(int(ans))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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]


Failing test case input:
4
3646424 64145 903 6247

Expected output:
436075051


Actual output:

Fixed submission (verdict: Accepted):
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)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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)

Failing test case input:
4
1988253 98660 9743 12204

Expected output:
81422469


Actual output:
81422469.0


Fixed submission (verdict: Accepted):
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)
p(result)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
mod = 1000000007
sum_A = (sum(A)**2) % mod
B = map(lambda x: (x**2)% mod,A)
sum_B = sum(B) % mod
answer = int(((sum_A-sum_B)/2)%mod)
print(answer)

Failing test case input:
4
1069110 84292 143968 6344

Expected output:
400912688


Actual output:
900912691


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
mod = 1000000007
sum_A = (sum(A)**2) % mod
B = list(map(lambda x: (x**2)% mod,A))
sum_B = sum(B) % mod
print(((sum_A-sum_B)*500000004)%mod)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = list(map(int, input().split()))

total = 0 

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

print(total)

Failing test case input:
4
3646424 64145 127 11813

Expected output:
205559645


Actual output:
278205561591


Fixed submission (verdict: Accepted):
n = int(input())
s = list(map(int, input().split()))

ans= 0
total = sum(s)

for i in range(len(s)-1):
  total -= s[i]
  ans += total * s[i]

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

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):



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

sum = 0
B = []
B.append(0)

for t in range(N):
    B.append(A[t] + B[t])
    
B.remove(0)
    
print(B)
    
for i in range(N):
    sum += A[i] * (B[N-1] - B[i])
            
        
print(sum % (10**9+7))

Failing test case input:
4
2519048 2493 176 11813

Expected output:
512820549


Actual output:
[2519048, 2521541, 2521717, 2533530]
512820549


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))

sum = 0
B = []
B.append(0)

for t in range(N):
    B.append(A[t] + B[t])
    
B.remove(0)
    
for i in range(N):
    sum += A[i] * (B[N-1] - B[i])
        
print(sum % (10**9+7))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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)

Failing test case input:
4
27898610 139427 593808 94229

Expected output:
980131219


Actual output:
23085095425040
96026198244
55980131604
980131219


Fixed submission (verdict: Accepted):
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)