alexjercan/bugnet huggingface dataset:
Problem p02572 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

// const ll INF = 1e18L + 5;
// const int INF = 1e9 + 5;
// const double pi = 3.14159265358979323846;
const int mod = 1e9 + 7;

void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  int ans = 0;
  int x = 0;
  rep(i, n) {
    ans = (ans + (ll)v[i] * x) % mod;
    x = (x + v[i]) % mod;
  }
  cout << ans << endl;
}

int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);

  solve();
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

// const ll INF = 1e18L + 5;
// const int INF = 1e9 + 5;
// const double pi = 3.14159265358979323846;
const int mod = 1e9 + 7;

void solve() {
  int n;
  cin >> n;
  vector<unsigned long long> v(n);
  rep(i, n) cin >> v[i];
  unsigned long long ans = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      ans += (v[i] * v[j]) % mod;
    }
  }
  cout << ans % mod << endl;
}

int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);

  solve();
}
Problem p02572 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define lmin LONG_MIN
#define lmax LONG_MAX
#define imin ll_MIN
#define imax ll_MAX
#define ffor(i, a, b) for (i = a; i < b; i++)
#define bfor(i, a, b) for (i = a - 1; i >= b; i--)
#define mset(f, a) memset(f, a, sizeof(f))
#define pb push_back
#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define MAXN 10000009

ll mod = 1e9 + 7;

int main() {
  ll t = 1, temp;
  // cin>>t;
  ffor(temp, 0, t) {
    fastio;
    ll n;
    cin >> n;
    ll arr[n];
    ll i;
    ffor(i, 0, n) cin >> arr[i];

    ll sum = 0;
    ffor(i, 0, n) sum = (sum + arr[i]);
    ll s[n];
    ffor(i, 0, n) {
      s[i] = sum - arr[i];
      sum = sum - arr[i];
    }
    ll ans = 0;
    ffor(i, 0, n) { ans = (ans + ((arr[i] % mod) * (s[i] % mod)) % mod) % mod; }
    cout << ans << endl;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define lmin LONG_MIN
#define lmax LONG_MAX
#define imin ll_MIN
#define imax ll_MAX
#define ffor(i, a, b) for (i = a; i < b; i++)
#define bfor(i, a, b) for (i = a - 1; i >= b; i--)
#define mset(f, a) memset(f, a, sizeof(f))
#define pb push_back
#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define MAXN 10000009

ll mod = 1e9 + 7;

int main() {
  ll t = 1, temp;
  // cin>>t;
  ffor(temp, 0, t) {
    fastio;
    ll n;
    cin >> n;
    ll arr[n];
    ll i;
    ffor(i, 0, n) cin >> arr[i];
    ll j;
    ll ans = 0;
    ffor(i, 0, n - 1) {
      ffor(j, i + 1, n) { ans = (ans + (arr[i] * arr[j]) % mod) % mod; }
    }
    cout << ans << endl;
  }
}
Problem p02572 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  rep(i, n) {
    cin >> a.at(i);
    sum += a.at(i);
  }

  ll ans = 0;
  ll b = 1e9 + 7;
  ll c = 0;
  rep(i, n - 1) {
    sum -= a.at(i);
    if (sum >= b) {
      c = sum % b;
    } else {
      c = sum;
    }

    ans += a.at(i) * c;
    if (ans >= b) {
      ans %= b;
    }
  }
  cout << ans << endl;

  return 0;
}

// vector<int> a(3);
// a.at(0);
// a.size();
// vector<vector<int>> a(3, vector<int>(3));
// uint64_t sum = 0;
// max(a, b);
// min(a, b);
// swap(a, b);
// sort(vec.begin(), vec.end());  昇順
// reverse(vec.begin(), vec.end());  降順


Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);

  rep(i, n) { cin >> a.at(i); }

  ll ans = 0;
  ll b = 1e9 + 7;
  rep(i, n - 1) {
    for (int j = i + 1; j < n; j++) {

      ans += a.at(i) * a.at(j);

      if (ans >= b) {
        ans %= b;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

// vector<int> a(3);
// a.at(0);
// a.size();
// vector<vector<int>> a(3, vector<int>(3));
// uint64_t sum = 0;
// max(a, b);
// min(a, b);
// swap(a, b);
// sort(vec.begin(), vec.end());  昇順
// reverse(vec.begin(), vec.end());  降順
Problem p02572 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<long long> B(N + 1, 0); // 累積和テーブル
  int mod = 1000000007;

  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i + 1] = B[i] + A[i];
  }

  long ans = 0;

  // i について全探索する
  for (int i = 0; i < N; i++) {
    // 累積和を使ってA[i+1] + ... + A[N] を求める
    long long sum = (B[N] - B[i + 1]) % mod;

    ans += A[i] * sum;
    ans %= mod;
  }

  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define ld long double
#define uint unsigned int
#define endl '\\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pll pair<long long, long long>
#define ppll pair<pll, pll>
#define pd pair<int, int>
#define ppdd pair<pd, pd>
#define vd vector<int>
#define sd(x) scanf("%d", &x)
#define sld(x) scanf("%lld", &x)
#define deb(x)                                                                 \\
  { cerr << #x << '=' << x << '\\n'; }
#define tc(x)                                                                  \\
  sd(x);                                                                       \\
  while (x--)
#define INF 1e18
#define eps 0.00001
#define le length
#define inc(il)
using namespace std;

void solve() {
  // code goes here
  int n;
  cin >> n;
  ll arr[n], res = 0;
  for (int i = 0; i < n; ++i)
    cin >> arr[i];
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      res += (arr[i] * arr[j]) % MOD;
      res %= MOD;
    }
  }
  cout << res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
Problem p02572 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <string>

using namespace std;
const int mod = 1e9 + 7;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for (long long i = 0; i < n; i++)
int main() {
  long long N;
  int A[300000];
  long long sum = 0;
  long long ans = 0;
  cin >> N;
  REP(i, N) {
    cin >> A[i];
    sum += A[i];
  }
  // cout<<ans<<endl;
  for (int i = 0; i < N; i++) {
    sum -= A[i];
    ans = (A[i] * (sum % mod) + ans) % mod;
    // cout<<ans<<endl;
  }
  cout << ans;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#include <string>

using namespace std;
const int mod = 1e9 + 7;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for (long long i = 0; i < n; i++)
int main() {
  long long N;
  long long A[100000];
  long long sum = 0;
  long long ans = 0;
  cin >> N;
  REP(i, N) {
    cin >> A[i];
    sum += A[i];
  }
  // cout<<ans<<endl;
  for (int i = 0; i < N; i++) {
    sum -= A[i];
    ans = (A[i] * (sum % mod) + ans) % mod;
    // cout<<ans<<endl;
  }
  cout << ans;
  return 0;
}
Problem p02572 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long N;
  cin >> N;
  long long ans = 0;
  long long sum_vec = 0;

  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    ans += sum_vec * A.at(i);
    ans %= 1000000007;

    sum_vec += A.at(i);
    sum_vec %= 1000000007;
  }

  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  long long N;
  cin >> N;
  long long ans = 0;

  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    for (int j = 0; j < i; j++) {
      ans += A.at(i) * A.at(j);
      ans %= 1000000007;
    }
  }

  cout << ans << endl;
}
Problem p02572 (C++) — buggy submission, verdict: Time Limit Exceeded


#include <bits/stdc++.h>
#define ll long long int
#define endl "\\n"
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define all(p) p.begin(), p.end()
#define F first
#define S second
#define mp make_pair
#define MOD 1000000007
using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  int t = 1;
  while (t--) {
    ll c_sum = 0, sum = 0, x = 0, y;
    int n, a;
    cin >> n;
    vi v;

    for (int i = 0; i < n; i++) {
      cin >> a;
      v.pb(a);
      c_sum += a;
      c_sum %= MOD;
    }

    for (int i = 0; i < v.size(); i++) {
      c_sum -= v[i];
      if (c_sum < 0)
        c_sum += MOD;
      sum += c_sum * v[i];
      sum %= MOD;
    }

    cout << sum << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:


#include <bits/stdc++.h>
#define ll long long int
#define endl "\\n"
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define all(p) p.begin(), p.end()
#define F first
#define S second
#define mp make_pair
#define MOD 1000000007
using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  int t = 1;
  // cin>>t;
  while (t--) {
    ll n, a, sum = 0;
    cin >> n;
    vll v;
    for (int i = 0; i < n; i++) {
      cin >> a;
      v.pb(a);
    }
    sort(all(v));
    for (int i = 0; i < v.size() - 1; i++) {
      for (int j = i + 1; j < v.size(); j++) {
        sum += (v[i] * v[j]) % MOD;
      }
    }
    cout << sum % MOD << endl;
  }

  return 0;
}
Problem p02572 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef vector<int> vi;
typedef unsigned long ul;
typedef vector<ll> vl;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef set<int> si;
typedef multiset<int> mi;

const ll INF = 1e18;
const int MOD = 1e9 + 7;

int main() {

  cin.tie(NULL);
  ios_base::sync_with_stdio(false);

  ll ans = 0, sum = 0, sqr = 0;
  int N;
  cin >> N;
  vl v(N);
  for (auto &q : v)
    cin >> q, sum += q, sum %= MOD, sqr += (q % MOD) * (q % MOD), sqr %= MOD;

  ans = (sum * sum - sqr);
  if (ans % 2 != 0)
    ans += MOD;
  ans /= 2;
  ans %= MOD;

  cout << ans << "\\n";
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef vector<int> vi;
typedef unsigned long ul;
typedef vector<ll> vl;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef set<int> si;
typedef multiset<int> mi;

const ll INF = 1e18;
const int MOD = 1e9 + 7;

int main() {

  cin.tie(NULL);
  ios_base::sync_with_stdio(false);

  ll ans = 0;
  int N;
  cin >> N;
  vl v(N);
  for (auto &q : v)
    cin >> q;

  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      ans += (v[i] % MOD * v[j] % MOD) % MOD;
      ans %= MOD;
      // cout << ans << "\\n";
    }
  }

  cout << ans << "\\n";
  return 0;
}
Problem p02572 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
// rep…「0からn-1まで」の繰り返し
#define rep2(i, s, n) for (long long i = s; i <= (long long)(n); i++)
// rep2…「sからnまで」の繰り返し
#define repr(i, s, n) for (long long i = s; i >= (long long)(n); i--)
// repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9 + 7;
const int mod = 1e9 + 7;

int main() {
  ll n, ans = 0;
  cin >> n;

  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i] %= mod;
  }

  vector<ll> A(n);
  A[n - 1] = a[n - 1];
  repr(i, n - 2, 0) { A[i] = (a[i] + A[i + 1]) % mod; }

  rep(i, n - 1) { ans += (a[i] * A[i + 1]) % mod; }

  cout << ans % mod << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
// rep…「0からn-1まで」の繰り返し
#define rep2(i, s, n) for (long long i = s; i <= (long long)(n); i++)
// rep2…「sからnまで」の繰り返し
#define repr(i, s, n) for (long long i = s; i >= (long long)(n); i--)
// repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9 + 7;
const int mod = 1e9 + 7;

int main() {
  ll n, ans = 0;
  cin >> n;

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

  rep2(i, 0, n - 2) {
    rep2(j, i + 1, n - 1) {
      ll A = a[i] % mod;
      ll B = a[j] % mod;

      ans += (A * B) % mod;
    }
  }

  cout << ans % mod << endl;
}
Problem p02572 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower, islower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <math.h>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
long long n, m, x, y, z;
const long long template_arry_size = 1000625;
long long a[template_arry_size];
long long b[template_arry_size];
long long c[template_arry_size];
string s, t;
long long ans = 0;
long long mod = 1'000'000'007;

void solve() {
  cin >> n;
  rep(i, n) { cin >> a[i]; }
  int x = 0;
  rep(i, n) {
    ans = (ans + (ll)a[i] * x) % mod;
    x = (x + a[i]) % mod;
  }
  cout << ans << endl;
}

int main() { solve(); }

Error: TLE

Fixed submission:

#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower, islower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <math.h>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
// using ll = long long; using ld = long double;
// using P = pair<int, int>;
long long n, m, x, y, z;
const long long template_arry_size = 1000625;
long long a[template_arry_size];
long long b[template_arry_size];
long long c[template_arry_size];
string s, t;
long long ans = 0;
long long mod = 1000000007;

void solve(int tc = 0) {
  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, n) {
    for (int j = i + 1; j < n; ++j) {
      ans += (a[i] * a[j]) % mod;
      ans %= mod;
    }
  }
  cout << ans << endl;
}

int main() { solve(); }
Problem p02572 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n;
  const int q = 1000000007;
  cin >> n;
  vector<long long> a(n, 0);
  vector<long long> b(n, 0);
  long long s = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s = (s + a[i]) % q;
    if (i == 0)
      b[i] = a[i];
    else
      b[i] = (a[i] + b[i - 1]) % q;
  }
  long long sum = (s * s) % q;
  // cout << sum << endl;
  for (int i = 0; i < n; i++) {
    long long ab = (a[i] * b[i]) % q;
    // cout << a[i] <<"*" << b[i] << "="<<ab << endl;
    sum = (sum - ab) % q;
    if (sum < 0)
      sum += q;
  }
  // cout << -4/3 <<"," <<-4%3<< endl;
  // long long sum = 0;
  // for (int i=0; i<n-1; i++) {
  //     // cout << s << "-" << b[i]<< "="<< (s - b[i])%q<< endl;
  //     sum=(sum+(a[i]*(s - b[i])%q)%q)%q;
  // }
  cout << sum << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  vector<long long> a(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  const int q = 1000000007;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      sum += ((long long)(a[i] * a[j])) % q;
      sum %= q;
    }
  }
  cout << sum << endl;
  return 0;
}
Problem p02572 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define fast_IO                                                                \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define endl '\\n'
#define pb push_back
#define F first
#define S second
#define int long long int
#define ll long long
#define ld long double

int mod = 1e9 + 7;

bool isPrime(ll n) {
  if (n < 2)
    return false;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

ll lcm(ll x, ll y) { return (x * y) / (__gcd(x, y)); }

signed main() {
  fast_IO;
  int t = 1;
  // cin>>t;
  while (t--) {
    string s;
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      sum += a[i];
      sum %= mod;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      sum -= a[i];
      if (sum < 0)
        sum += mod;
      ans += sum * a[i];
      ans %= mod;
    }
    cout << ans % mod;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

#define fast_IO                                                                \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define endl '\\n'
#define pb push_back
#define F first
#define S second
#define int long long int
#define ll long long
#define ld long double

bool isPrime(ll n) {
  if (n < 2)
    return false;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

ll lcm(ll x, ll y) { return (x * y) / (__gcd(x, y)); }

signed main() {
  fast_IO;
  int t = 1;
  // cin>>t;
  while (t--) {
    int n;
    cin >> n;
    int mod = 1e9 + 7;
    vector<int> a(n);
    int x;
    for (int i = 0; i < n; i++) {
      cin >> x;
      a[i] = x % mod;
    }
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
      for (int j = i + 1; j < n; j++) {
        ans += ((a[i] % mod) * (a[j] % mod)) % mod;
      }
    }
    cout << ans % mod;
  }
  return 0;
}
Problem p02572 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
  ll N;

  cin >> N;

  ll A[N];
  ll sum = 0;
  ll modulo = 1000000007;
  ll res = 0;

  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  for (int i = 0; i < N; i++) {
    sum += A[i];
    sum %= modulo; // Die Summe begrenzen
  }

  for (int j = 0; j < N; j++) {
    sum -= A[j];

    if (sum < 0)
      sum += modulo; // When the first case of the table is 1000000008 then with
                     // % modulo it will be 1 instead of 1000000008 which will
                     // make the sum negative so in this case we have to add to
                     // the sum the amount that we lost which is 1000000007

    res +=
        A[j] *
        sum; // for sure when multiplying the 100000000 with a big numer it will
             // stay supportable since we use long long int as a variable

    res %= modulo;
  }

  cout << res;

  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
  ll N;

  ll A[N];
  ll sum = 0;

  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      sum += A[i] * A[j];
    }
    sum = sum % 1000000007;
  }

  cout << sum;

  return 0;
}