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

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

sums *= sums;
ans = sums;

for i in range(n):
    ans -= a[i]*a[i]
ans /= 2

ans %= 1000000007
print(ans)



#include <string>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <numeric>

using namespace std;
typedef long long ll;


#define all(x) x.begin(), x.end()
#define mod 1000000007


#include <string>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <numeric>

using namespace std;
typedef long long ll;


#define all(x) x.begin(), x.end()
#define mod 1000000007

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }

    ll ans = 0;
    ll sum = 0;
    ll sums = 0;

    ans = 0;

    for (int i = 0; i < n; i++)
    {
        sums += a[i];
    }

    ans += (sums%mod) * (sums%mod);

    for (int i = 0; i < n; i++)
    {
        ans -= (a[i] * a[i]) % mod;
    }

    if(ans < 0) {
        ans += mod;
    }
    ans %= mod;

    ans *= (1.0/2);
    ans %= mod;

    cout << ans  << endl;
}

/*
int main()
{
    int n;cin >> n;
    vector<ll> a(n);
    vector<ll> b(n-1);
    rep(i,n) {
        cin >> a[i];
    }

    ll ans = 0;
    ll sum = 0;
    for (int i = 1; i < n; i++)
    {
        sum += a[i];  
    }


    int i = 1;
    for(int j = 0; j < n - 1; j++) {
        b[j] = sum;
        sum -= a[i++];
    }

    for(int i = 0; i < n - 1; i++) {
        ans += (b[i]%mod)*(a[i]%mod);
        ans %= mod;
    }



    cout << ans << endl;

}
*/


#include <string>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <numeric>

using namespace std;
typedef long long ll;


#define all(x) x.begin(), x.end()
#define mod 1000000007

int main()
{
    int n;cin >> n;
    vector<ll> a(n);
    vector<ll> b(n-1);
    rep(i,n) {
        cin >> a[i];
    }

    ll ans = 0;
    ll sum = 0;
    ll sums = 0;
    for (int i = 1; i < n; i++)
    {
        sum += a[i];  
    }


    int i = 1;
    for(int j = 0; j < n - 1; j++) {
        b[j] = sum;
        sum -= a[i++];
    }

    for(int i = 0; i < n - 1; i++) {
        ans += b[i]*a[i];
        ans %= mod;
    }



    cout << ans << endl;

}

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

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

sums *= sums;
ans = sums;

for i in range(n):
    ans -= a[i]*a[i]
ans //= 2
ans %= 1000000007
print(int(ans))


Verdicts: Wrong Answer

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):
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>

#include <istream>
#include <iterator>
#include <map>

#include <set>
#include <stack>
#include <string>

#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;



ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;

void dfs(int x,vector<vector<int>> &v,vector<int> &g, int &num){
  int x_size = v[x].size();
  if(x > 0){
    rep(i,x_size){
      if(g[v[x][i]] == 0){
        g[v[x][i]] = num;
        dfs(v[x][i],v,g,num);
      }
    }
  }
}

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(M),B(M),group(N+10,0);
  rep(i,M)cin >> A[i] >> B[i];
  vector<vector<int>> G(N+10);
  rep(i,M){
    G[A[i]].push_back(B[i]);
    G[B[i]].push_back(A[i]);
  }
  int num = 1;
  for(int i = 1;i <= N;i++){
    if(group[i] == 0){
      group[i] = num;
      dfs(i,G,group,num);
      num++;
    }
  }
  vector<int> cnt(N+10,0);
  for(int i = 1;i <= N;i++){
    cnt[group[i]]++;
  }
  int ans = -1;
  for(int i = 1;i <= N;i++){
    if(ans < cnt[i])ans = cnt[i];
  }
  cout << ans << endl;
/*
  for(int i = 1;i <= N;i++){
    cout << group[i] << " ";
  }
  cout << endl;
  for(int i = 1;i <= N;i++){
    cout << G[i].size() << " ";
  }
  cout << endl;
*/
  return 0;
}


//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>

#include <istream>
#include <iterator>
#include <map>

#include <set>
#include <stack>
#include <string>

#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;



ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;

void dfs(int x,vector<vector<int>> &v,vector<int> &g, int &num){
  int x_size = v[x].size();
  if(x > 0){
    rep(i,x_size){
      if(g[v[x][i]] == 0){
        g[v[x][i]] = num;
        dfs(v[x][i],v,g,num);
      }
    }
  }
}

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(M),B(M),group(N+10,0);
  rep(i,M)cin >> A[i] >> B[i];
  vector<vector<int>> G(N+10);
  rep(i,M){
    G[A[i]].push_back(B[i]);
    G[B[i]].push_back(A[i]);
  }
  int num = 1;
  for(int i = 1;i <= N;i++){
    if(group[i] == 0){
      group[i] = num;
      dfs(i,G,group,num);
      num++;
    }
  }
  vector<int> cnt(N+10,0);
  for(int i = 1;i <= N;i++){
    cnt[group[i]]++;
  }
  int ans = -1;
  for(int i = 1;i <= N;i++){
    if(ans < cnt[i])ans = cnt[i];
  }
  cout << ans << endl;
/*
  for(int i = 1;i <= N;i++){
    cout << group[i] << " ";
  }
  cout << endl;
  for(int i = 1;i <= N;i++){
    cout << G[i].size() << " ";
  }
  cout << endl;
*/
  return 0;
}


n = int(input())

s = input().split(" ")

sumup = 0
for i in s:
  sumup += int(i) 

ans = 0
for i in s:
  r = int(i)
  
  sumup -= r
  
  ans += r*sumup
    
print(ans%(10**9+7))


Verdicts: Runtime Error

Runtime Error

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

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))
ans = 0
mod = 1e9 + 7
s = sum(A) % mod

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

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

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

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

print(int(ans))

Verdicts: Wrong Answer

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

Submission attempts (in order):
n = int(input())
mod = 10 ** 9 + 7
import numpy as np
a = np.array(map(int, input().split())
s=0
ss=0
for i in range(n):
  ss += a[i]%mod
  s += ss * a[i] % mod
print(s)

n = int(input())
mod = 10 ** 9 + 7
import numpy as np
a = np.array(map(int, input().split())
s=0
ss=0
for i in range(n):
    ss += a[i]%mod
    s += ss * a[i] % mod
print(s)

n = int(input())
mod = 10 ** 9 + 7
import numpy as np
a = list(map(int, input().split())
s=0
ss=0
for i in range(n):
    ss += a[i]%mod
    s += ss * a[i] % mod
print(s)


n = int(input())
mod = 10 ** 9 + 7
import numpy as np
a = list(map(int, input().split()))
s=0
ss=0
for i in range(n):
    ss += a[i]%mod
    s += ss * a[i] % mod
print(s)


n = int(input())
mod = 10 ** 9 + 7
import numpy as np
a = list(map(int, input().split()))
s=0
ss=0
for i in range(n):
    if i > 0:
        ss += a[i-1]%mod
    s += ss * a[i] % mod
print(s%mod)


Verdicts: Runtime Error

Runtime Error

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):
import sys
import numpy as np

readline = sys.stdin.readline
read = sys.stdin.read
MOD = 10**9 + 7

n = int(input())
a = np.array(readline().split(), dtype=np.uint64)
r = np.cumsum(a[::-1])[::-1]
r &= MOD
x = a[:-1] * r[1:]
x %= MOD
ans = np.sum(x) % MOD
print(ans)

import sys
import numpy as np

readline = sys.stdin.readline
read = sys.stdin.read
MOD = 10**9 + 7

n = int(input())
a = np.array(readline().split(), dtype=np.uint64)
r = np.cumsum(a[::-1])[::-1]
r %= MOD
x = a[:-1] * r[1:]
x %= MOD
ans = np.sum(x) % MOD
print(int(ans))

Verdicts: Wrong Answer

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

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
x=0
for i in range(0,n-1):
  x+=a[i]
y=0
for j in range(1,n):
  y+=a[j]
z=x+y
print(z%(10**9+7))

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

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

n=int(input())
a=list(map(int,input().split()))
x=(sum(a)-a[n-1])*(sum(a)-a[0])
print(x%(10**9+7))

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

n=int(input())
a=list(map(int,input().split()))
x=0
for i in range(0,n-1):
  x+=a[i]
y=0
for j in range(1,n):
  y+=a[j]
w=0
for k in range(1,n-1):
  w+=a[k]**2
z=(x+y-w)//2
print(z%(10**9+7))

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

n=int(inoput())
a=list(map(int,input()))
total=0
for i in range(0,n-1):
  for j in range(1,n):
    total+=a[i]*a[j]
print(total%(10**9+7))
    

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

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())
l = list(map(int,input().split()))
s = 0
s1 = sum(l)
for x in range(n-1):
  s+=l[x]*(s1-l[x])
print(s%1000000007)


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


Verdicts: Wrong Answer

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

Submission attempts (in order):
n = int(input())
a = map(int,input().split())
temp = sum(a)**2
for x in a:
  temp -= x**2
print(temp//2)

n = int(input())
a = map(int,input().split())
mod = 10**9 + 7
temp = sum(a)**2
for x in a:
  temp -= x**2
print((temp//2)%mod)

n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7
temp = sum(a)**2
for x in a:
	temp -= x**2
print((temp//2)%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()))

mod= 10**9+7

A = sum(a)

ans=0

for i in a:
  A -= i
  A%=mod
  ans += A*x
  ans%=mod
print(ans)
  


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

mod= 10**9+7

A = sum(a)

ans=0

for i in a:
  A -= i
  A%=mod
  ans += A*i
  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())
arr = list(map(int, input().split()))

ans = 0
sum_arr = sum(arr)

for x in arr:
    ans += x * (sum_arr - x) // 2
    ans %= MOD

print(ans)

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

MOD = 10**9 + 7

ans = 0
sum_arr = sum(arr)

for x in arr:
    ans += x * (sum_arr - x) // 2
    ans %= MOD

print(ans)

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

MOD = 10**9 + 7

ans = 0
sum_arr = sum(arr)

for x in arr:
    sum_arr -= x
    ans += x * sum_arr
    ans %= MOD

print(ans)

Verdicts: Runtime Error

Wrong Answer

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

Submission attempts (in order):
N = int(input())
A = list(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))
  

import numpy as np

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

B = np.array(A)

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

dot = np.dot(B,B.T)
print((dot - a)/2)

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])%(10**9 + 7)
  ans += A[i] * sum_A
  
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):
N = int(input())
A = list(map(int ,input().split()))
MOD = 1e9+7

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

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

ans = ans % MOD
print(ans)

import math

N = int(input())
A = list(map(int ,input().split()))
MOD = math.floor(1e9+7)

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

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

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):
from numpy.core import double

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

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

N = int(input())
A = list(map(int,input().split()))
MOD = 1000000007
S = sum(A) % MOD
ans = 0

for x in A:
    S -= x
    S %= MOD
    ans += S * x
    ans %= MOD
ans %= MOD
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):
def main():
    N = int(input())
    A = list(map(int, input().split()))

    mod = 10**9 + 7

    tmp = [0] * N

    s = 0
    for i in range(N):
        tmp[- i - 1] = s
        s += A[-i - 1]

    print(tmp)

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

    print(ans % mod)


if __name__ == '__main__':
    main()


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

    mod = 10**9 + 7

    tmp = [0] * N

    s = 0
    for i in range(N):
        tmp[- i - 1] = s
        s += A[-i - 1]

    # print(tmp)

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

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

sum1 = 0
sum2 = 0

for _ in a:
  sum1 += _
  sum2 += (_*_)
sum1 = (sum1 * sum1)
print(sum1 - sum2)


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

sum1 = 0
sum2 = 0

for _ in a:
  sum1 += _
  sum2 += (a*a)
sum1 = (sum1 * sum1)
print(sum1 - sum2)

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

sum1 = 0
sum2 = 0

for _ in a:
  sum1 += _
  sum2 += (_*_)
sum1 = (sum1 * sum1)
print(((sum1 - sum2)//2)%1000000007)


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):
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    long long ans = 0, sum =0;
    int mod = 1000000000+7;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
        sum += a.at(i);
        sum %= mod;
    }
    for (int i = 0; i < N; i++) {
        sum -= a.at(i);
        if(sum<0) sum += mod;
        ans += sum * a.at(i);
        ans %= mod;
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    long long ans = 0, sum =0;
    int mod = 1000000000+7;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
        sum += a.at(i);
    }
    for (int i = 0; i < N-1; i++) {
        sum -= a.at(i);
        if(sum<0) sum += mod;
        ans += sum * a.at(i);
        ans %= mod;
    }
    cout << ans << endl;
}
/*

*/


def main():
    n = int(input())
    a = []
    sum = 0             
    ans = 0             
    mod = 1_000_000_000 + 7
    x = list(map(int, input().split()))
    for i in range(n):
        sum += x[i]           
        a.append(x[i])
    
    sum % mod
    
    for i in range(n):
        sum -= a[i]
        if sum < 0:
            sum += mod
        ans += sum * a[i]
        ans %= mod
    print(ans)

if __name__ == "__main__":
    main()

    

Verdicts: Runtime Error

Runtime Error

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

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

N=int(input())
List = list(map(int, input().split()))
S=0
for i in range(len(List)):
    S+=List[i]
mod=10**9+7
S=S%mod
T=0
s=0
for i in range(len(List)):
    s+=List[i]
    s=s%mod
    T+=List[i]*(S-s)
    T=T%mod
print(T)

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
x = 0

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

print(ans)


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) % (1e9+7)

print(ans)


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)

ans %= 1000000007

print(int(ans))


Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
import 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)


import sys
from collections import defaultdict

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

D = defaultdict(int)
ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        v = A[i] * A[j] % MOD
        D[v] += 1
print(D)


import sys
input = sys.stdin.buffer.readline
from itertools import accumulate

MOD = 10**9 + 7

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

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

ans %= MOD
print(ans)


Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
import sys
from itertools import combinations

input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))
B = list(combinations(A,2))
sum = 0
for i in range(len(B)):
    sum += B[i][0]*B[i][1]





import sys
input = sys.stdin.readline

def multipleSum(A, n):
    sum = 0
    for i in range(n):
        sum += A[i]
    mulsum = sum*sum
    insum = 0
    for i in range(n):
        insum+=A[i]*A[i]
    return (mulsum-insum)//2

N = int(input())
A = list(map(int,input().split()))
n = len(A)
print(multipleSum(A,n)%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):
ans = 0

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

N = int(input())
A = [int(i) for i in input().split()]
S = []
e = 0
for i in A:
    e += i
    S.append(e)
    
ans = 0
for i in range(N-1):
    ans += A[i]%(10**9+7)*((S[N-1] - S[i])%(10**9+7))
    
print(ans%(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):
MOD = 1000000007

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

print(n_list)

result = 0

for i in range(n):
    for j in range(n-i-1)
        result += n_list[i] * n_list[j+1] % MOD
        result = result % MOD

print(result)



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

result = 0

s = sum(n_list)
m = 10**9+7

for num in n_list:
    s -= num
    result += num * s % m
    result %= m

print(result)


Verdicts: Runtime Error

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

Submission attempts (in order):
import numpy as np
 
N = int(input())
A = np.array(map(int, input().split()))
 
A %= (1000000000+7)
_sum = 0
 
for n in range(N-1):
  for i in range(n+1):
    _sum += A[n+1] * A[i]
    _sum %= (1000000000+7)
    
print(_sum)


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

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

#modulo
_sum = _sum % (1000000000+7)
  
print(_sum)


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

S = [0]*N
for n in range(N):
  S[n] = S[n-1] + A[n]
  
_sum = 0
for i in range(N-1):
  _sum = _sum + (A[i] * (S[N] - S[i+1]))
  _sum = _sum % (1000000000+7)
  
print(_sum)

import numpy as np

N = int(input())
A = np.array(map(int, input().split()))

A %= (1000000000+7)
_sum = 0

for n in range(N-1):
  for i in range(n+1):
    _sum += A[n+1] * A[i]
    _sum = %= (1000000000+7)
    
print(_sum)


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


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

_sum = 0
for i in range(N-1):
  _sum = _sum + (A[i] * (S[N] - S[i+1]))
  _sum = _sum % (1000000000+7)
  
print(_sum)



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

S = [0]*N
for n in range(N):
  S[n] = S[n-1] + A[n]
  
_sum = int(0)
for i in range(N-1):
  _sum = _sum + int((A[i] * (S[N] - S[i])))

#modulo
_sum = _sum % (1000000000+7)
  
print(_sum)


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


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

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

#modulo
_sum = _sum % (1000000000+7)
  
print(_sum)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):
import numpy
n=input()
l=list(map(int, input().split()))
res=0
#print(f"le{len(l)}")
l.append(0)
l.reverse()
for i in range(len(l)): 
    print(l[len(l)-1-i],numpy.cumsum(l)[len(l)-i-2])
    res+=l[len(l)-1-i]*numpy.cumsum(l)[len(l)-i-2]
    print(f"{res}レス")
print(res%(10**9+7))
#print(res)

import numpy
n=input()
l=list(map(int, input().split()))
res=0
#print(f"le{len(l)}")
l.append(0)
l.reverse()
for i in range(len(l)): 
    print(l[len(l)-1-i],numpy.cumsum(l)[len(l)-i-2])
    res+=l[len(l)-1-i]*numpy.cumsum(l)[len(l)-i-2]
    
print(res%(10**9+7))
#print(res)

import numpy
n=int(input())
l=list(map(int, input().split()))
res=0
mod=10**9+7
l.append(0)
l.reverse()
cum=numpy.cumsum(l)%mod
for i in range(n):
    res+=((l[n-i]%mod)*cum[n-i-1])%mod
print(res%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

for i in range(n):
    for j in range(i+1, n):
        ans += a[i] * a[j]
        print("i, j, a[i], a[j] = {}, {}, {}, {}".format(i, j, a[i], a[j]))

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


n = int(input())

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

S = sum(a)

S2 = sum(map(lambda x: x * x, a ))

ans = (S * S - S2) // 2 % 1000000007
print(ans)



Verdicts: Wrong Answer

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

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
l=list(map(lambda z:z**2,a))
x=sum(a)
y=sum(l)
t=(x-y)//2
print(t)


n=int(input())
a=list(map(int,input().split()))
if n==1:
print(a[0])
else:
l=list(map(lambda z:z**2,a)
x=sum(a)
y=sum(l)
t=(x-y)//2
print(t)

n=int(input())
a=list(map(int,input().split()))
l=list(map(lambda z:z**2,a)
x=sum(a)
y=sum(l)
t=(x-y)//2
print(t)


n=int(input())
a=list(map(int,input().split()))
if n==1:
  print(a[0])
else:
  l=list(map(lambda z:z**2,a))
  x=sum(a)
  y=sum(l)
  t=(x-y)//2
  print(t)


n=int(input())
a=list(map(int,input().split()))
if n==1:
print(a[0])
else:
l=list(map(lambda z:z**2,a)
x=sum(a)
y=sum(l)
t=(x-y)//2
if t>(10**9+7):
       print(t%(10**9+7))
else:
       print(t)


n=int(input())
a=list(map(int,input().split()))
l=list(map(lambda z:z**2,a))
x=sum(a)
y=sum(l)
t=(x-y)//2
if t>(10**9+7):
       print(t%(10**9+7))
else:
       print(t)


n=int(input())
a=list(map(int,input().split()))
l=list(map(lambda z:z**2,a))
x=sum(a)**2
y=sum(l)
t=(x-y)//2
if t>(10**9+7):
       print(t%(10**9+7))
else:
       print(t)


Verdicts: Wrong Answer

Runtime Error

Runtime Error

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):
N = int(input())
NUM = 1000000007
A = [list(map(int, input().split())) for _ in range(N)]
MASS = 0
for i in range (N):
    I = A[i] % NUM
    I = (I * (N - 1)) % NUM
    MASS += I
print(MASS % NUM)

N = int(input())
NUM = 1000000007
A = [int(input()) for _ in range(N)]
MASS = 0
for i in range (N):
    I = A[i] % NUM
    I = (I * (N - 1)) % NUM
    MASS += I
print(MASS % NUM)

for i in range (N):
    A = (int(input())
MASS = 0
for i in range (N - 1):
    T = 0
    for j in range (i + 1, N):
        T += (A[j] % NUM)
    MASS += ((A[i]%NUM) * (T%NUM))%NUM
print(MASS % NUM)

n = int(input())
a = list(map(int, input().split()))
total = 0
sub = 0
for i in a:
    total += i
    sub += i * i
print((((total * total) - sub) // 2) % (10 ** 9 + 7))

Verdicts: Runtime Error

Runtime Error

Runtime Error

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

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

MOD = (10**9)+7
a_sum = 0
ans = 0
for i in range(n-1):
    a_sum += a_list[n-i-1]
    print(a_sum)
    ans += a_sum * a_list[n-i-2]
    ans = ans % MOD

print(ans)


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

MOD = (10**9)+7
a_sum = 0
ans = 0
for i in range(n-1):
    a_sum += a_list[n-i-1]
    ans += a_sum * a_list[n-i-2]
    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=input()
A=list(map(int,input().split()))
count1=0
count2=0
for a in A[0:]:
    count1=count1+a
    count2=count2+a**2

B=(count1**2-count2)/2
C=B%(10**9+7)
print(C)

N=input()
A=list(map(int,input().split()))
count1=0
count2=0
for a in A[0:]:
    count1=count1+a
    count2=count2+a**2

B=(count1**2-count2)//2
C=B%(10**9+7)
print(C)

Verdicts: Wrong Answer

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

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

n = int(input())
mod = 10**9+ 7
a = list(map(int,input().split()))
ans = (sum(a)%mod)**2 - sum([x**2%mod for x in a])
ans *= 5*10**8+4
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())
a = [int(x) for x in input().split()]

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

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

n = int(input())
a = [int(x) for x in input().split()]
m = 1000000007
ans = 0

b = [0]
for i in range(1,n+1):
  b.append((a[i-1] + b[i-1]) % m)
#print(a,b)
           
for i in range(n):
	p = b[n] - b[i+1]
	p *= a[i]
	p = p % m
	ans += p
	ans = ans % m
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()))

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

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

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)

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)

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 os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy
import numpy 
 
def main():
    n = int(input())
    alist = list(map(int, input().split()))
    max_num = 10**9 + 7
    ans = 0
    for i in range(n):
        ans += numpy.cumsum(alist[:i+1])

    print(ans%max_num)

if __name__ == "__main__":
    main()

import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy
 

def cumsum(xs):
    pass

def main():
    n = int(input())
    alist = list(map(int, input().split()))
    max_num = 10**9 + 7
    ans = 0
    sum_num = sum(alist)

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

    print(ans%max_num)

if __name__ == "__main__":
    main()

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 = sum(a)
ans = 0
for x in a:
  ans += (s-x) * x
  ans %= mod
print(ans)

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

n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7
invtwo = pow(2, mod-2, mod)
s = sum(a) % mod
ans = 0
for x in a:
  ans += (s-x) * x
  ans %= mod
print((ans * invtwo) % 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):
import numpy as np
ans=0
n=int(input())
li=list(map(int,input().split()))
for i in range(1,n):
    L=li
    k=np.cumsum(L[:i])
    ans+=k*li[i]
print(ans%(10**9+7))

import itertools
ans=0
n=int(input())
li=list(map(int,input().split()))
L=list(itertools.accumulate(li))
for i in range(1,n):
    ans+=L[i-1]*li[i]
print(ans%(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()))
ans=0
for i in range(N):
    ans+=(sum(A)-A[i])*A[i]
print((ans/2)%(10**9+7))

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

mod = 10 ** 9 + 7
ans = 0

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

for i in range(1, N):
    ans += A[i] * A_sum[i-1]
    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):
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 29 22:19:15 2020

@author: naoki
"""

N = int(input())

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

count1 = 0
count2 = 0
count = 10**9 +7
for i in A:
    count1+=i
	count1=count1%count
for j in A:
    count2 = j*(count1-j)%count + count2
    count1 = count1 -j 
    
print(count2%count)
    
    
    

# -*- coding: utf-8 -*-
"""
Created on Sat Aug 29 22:19:15 2020

@author: naoki
"""

N = int(input())

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

count1 = 0
count2 = 0
count = 10**9 +7
for i in A:
    count1+=i

for j in A:
    count2 = (j*(count1-j) + count2)%count
    count1 = count1 -j 
    
print(count2%count)
    
    
    

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

    mod_value = 10**9 + 7
    sum = 0
    for i in range(len(A)-1):
        for j in range(i+1,len(A)):
           sum = sum + A[i]*A[j] % mod_value
    print(sum % mod_value)
main()


4
141421356 17320508 22360679 244949

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

    mod_value = 10**9 + 7
    sum_ = 0
    b_sum = 0
    for i in range(len(A)-1):
        b_sum = b_sum + A[len(A)-i-1]
        sum_ = sum_ + (A[len(A)- i - 2]*b_sum) % mod_value
    print(sum_%mod_value)
main()

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):
import itertools
import numpy as np

MOD = 1000000007
n = int(input())
ai = list(map(int,input().split()))
ans = 0

for v in itertools.permutations(ai, 2):
    print(v)
    ans += np.prod(v)
    
print(ans % MOD)

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

MOD = 10 ** 9 + 7
s =sum(a) % MOD
ans = 0

for i in a :
    s -= i
    s %= MOD
    ans += i * s
    ans %= MOD
    
print(ans)

Verdicts: Wrong Answer

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

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
    b=a[i]*sum(a[i+1:n])
    print(b)
    ans=ans+b
print(ans)

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

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


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

A = A % (1*10**9 + 7)
value = 0
plus = 0
ans = 0

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

print(value)


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

A_sum = sum(A)

value = 0
ans = 0

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

ans = value % (1*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):
def c_sum_of_product_of_pairs(MOD=10**9 + 7):
    import numpy
    N = int(input())
    A = [int(i) for i in input().split()]

    total = sum(A)
    cumsum = [0] + list(numpy.cumsum(A, dtype='int64'))
    return sum([(total - cumsum[i]) * A[i] for i in range(N)]) % MOD

print(c_sum_of_product_of_pairs())

def c_sum_of_product_of_pairs(MOD=10**9 + 7):
    N = int(input())
    A = [int(i) for i in input().split()]

    cumsum = [0]
    for a in A:
        cumsum.append(cumsum[-1] + a)
    return sum([(cumsum[N] - cumsum[i + 1]) * A[i] for i in range(N)]) % MOD

print(c_sum_of_product_of_pairs())

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):
for i in range(N-1):
    tmp+=A[i]
    ans+=tmp*A[i+1]
print(ans%((10**9)+7))

import math

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

for i in range(N-1):
    tmp+=A[i]
    ans+=tmp*A[i+1]
print(ans%((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()))
B=[A[N-1]]
#print(B[0])
for i in range(len(A)-2):
    #print(i)
    b=B[i]+A[N-2-i]
    B.append(b)
print(B)
total=0
for i in range(len(B)):
    total += A[i]*B[len(B)-1-i]

print(total%(10**9+7))
    #print(v)

N = int(input())
A=list(map(int, input().split()))
B=[A[N-1]]
#print(B[0])
for i in range(len(A)-2):
    #print(i)
    b=B[i]+A[N-2-i]
    B.append(b)

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

print(total%(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()))
b=sum(a)
score=0
for i in range(len(a)):
  b -= a[i]
  score=a[i]*b
  
print(score%(10**9+7))

n = int(input())
a = list(map(int,input().split()))
b=sum(a)
score=0
for i in range(len(a)):
  b -= a[i]
  score=a[i]*b
  
print(score)

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

print(score%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):
def square(list):
    return [i ** 2 for i in list]
m = 1000000007
n = int(input())
A = list(map(int, input().split()))
sq = square(A)
s1 = sum(A)
s2 = sum(sq)

result = (s1**2-s2)/2
print(result%m)

def square(list):
    return [i ** 2 for i in list]
m = 1000000007
n = int(input())
A = list(map(int, input().split()))
sq = square(A)
s1 = sum(A)
s2 = sum(sq)
 
result = (s1**2-s2)//2
print(result%m)

Verdicts: Wrong Answer

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

Submission attempts (in order):
# Date [ 2020-08-29 21:10:46 ]

# Author Koki_tkg

import sys
# import math

# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict


MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    n = read_int()
    a = read_int_list()
    
    ans = 0

    total = sum(a)
    for i in range(n):
        ans += (a[i] * (total - a[i])) / 2
        ans %= MOD

    print(ans % MOD)

if __name__ == '__main__':
    Main()

# Date [ 2020-08-29 21:10:46 ]

# Author Koki_tkg

import sys
# import math

# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict


MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    n = read_int()
    a = read_int_list()
    
    ans = 0

    total = sum(a)
    floatcnt = 0
    for i in range(n):
        ans += a[i] * (total - a[i])
        ans %= MOD
        total -= a[i]

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

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

ans = ans % 10**9+7

print(int(ans))

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

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

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

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

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

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

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

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

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

n=int(input())
array=list(map(int,input().split()))
list2=[]
for i in range(n):
  for j in range(i+1,n):
    list2.append(array[i]*array[j])
a=n*(n-1)/2
ans=0
for m in range(a):
  ans=ans+list2[m]
  if ans>=10**9+7:
    ans=ans-(10**9+7)
print(ans)

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

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

n=int(input())
array=list(map(int,input().split()))
list2=[]
for i in range(n):
  for j in range(i+1,n):
    list2.append(array[i]*array[j])
a=n*(n-1)
ans=0
for m in range(a):
  ans=ans+list2[m]
  if ans>10**9+7:
    ans=ans-10**9+7
print(ans//10**9+7)

n=int(input())
array=list(map(int,input().split()))
list2=[]
for i in range(n-1):
  for j in range(i+1,n):
    list2.append(array[i]*array[j])
a=n*(n-1)/2
ans=0
for m in range(a):
  ans=ans+list2[m]
  if ans>=10**9+7:
    ans=ans-(10**9+7)
print(ans)

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

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,m = (int(x) for x in input().split())
friendlist = [0]*n
classes = 1
for i in range(m):
    a,b = (int(x)-1 for x in input().split())
    if friendlist[a]!=0 and friendlist[b]!=0:
        continue
    elif friendlist[a]!=0:
        friendlist[b] = friendlist[a]
    elif friendlist[b]!=0:
        friendlist[a] = friendlist[b]
    else:
        friendlist[a] = classes
        friendlist[b] = classes
        classes += 1

count = [0]*classes
maxa = 0
for i in range(n):
    count[friendlist[i]] += 1
    maxa = max([count[friendlist[i]],maxa])

print(maxa)

n = int(input())

An = [int(i) for i in input().split()]
S = sum(An)
Sn = S**2
Sn2 = 0
for a in An:
    Sn2 += a**2

ans = ((Sn - Sn2)//2)%(10**9+7)
print(ans)


Verdicts: Runtime Error

Accepted