buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<long long, long long> #define ii pair<int, int> #define mod 1000000007 #define endl '\n' #define IOS \ std::ios::sync_with_stdio(false); ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<long long, long long> #define ii pair<int, int> #define mod 1000000007 #define endl '\n' #define IOS \ std::ios::sync_with_stdio(false); ...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 17, 109], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 12, 22], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25]]
1
325
#ifdef LOCAL #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> using namespace std; #define rep(i, s, t) for (ll i = (ll)(s); i < (ll)(t); i++) #define rrep(i, s, t) for (ll i = (ll)(s - 1); (ll)(t) <= i; i--) #define all(x) (x).begin(), (x).end() typedef long long ll; typedef long double ld; typedef pair<ll, ll> ...
#ifdef LOCAL #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> using namespace std; #define rep(i, s, t) for (ll i = (ll)(s); i < (ll)(t); i++) #define rrep(i, s, t) for (ll i = (ll)(s - 1); (ll)(t) <= i; i--) #define all(x) (x).begin(), (x).end() typedef long long ll; typedef long double ld; typedef pair<ll, ll> ...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
1,345
#include <bits/stdc++.h> #define ll long long int #define yorn(f) cout << ((f) ? "Yes" : "No") << endl; #define YORN(f) cout << ((f) ? "YES" : "NO") << endl; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repi(i, n) for (int i = 1; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() #define put(x) co...
#include <bits/stdc++.h> #define ll long long int #define yorn(f) cout << ((f) ? "Yes" : "No") << endl; #define YORN(f) cout << ((f) ? "YES" : "NO") << endl; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repi(i, n) for (int i = 1; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() #define put(x) co...
[["+", 51, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 51, 16, 12, 23, 0, 16, 31, 23, 0, 25], ["+", 49, 50, 51, 16, 12, 23, 0, 16, 17, 109], ["+", 49, 50, 51, 16, 12, 23, 0, 16, 12, 22]]
1
195
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower) using namespace std; using ll = long long; int INF = 1001001001; ll m = 1000000007; int main() { int n; cin >> n; vector<ll> a(n); rep(i, n) { cin >> a[i]; } ll temp =...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower) using namespace std; using ll = long long; int INF = 1001001001; ll m = 1000000007; int main() { int n; cin >> n; vector<ll> a(n); rep(i, n) { cin >> a[i]; } ll temp =...
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25], ["+", 12, 16, 31, 23, 0, 16, 12, 16, 17, 109], ["+", 12, 16, 31, 23, 0, 16, 12, 16, 12, 22]]
1
158
mod = 1e9 + 7 n = gets.chomp.to_i arr = gets.chomp.split(' ').map(&:to_i) sum = arr.inject(:+) % mod res = 0 n.times do |i| sum -= arr[i] res += arr[i] * sum res %= mod end puts res.to_i
mod = (1e9 + 7).to_i n = gets.chomp.to_i arr = gets.chomp.split(' ').map(&:to_i) sum = arr.inject(:+) % mod res = 0 n.times do |i| sum -= arr[i] res += arr[i] * sum res %= mod end puts res.to_i
[["+", 0, 493, 0, 662, 12, 652, 486, 739, 0, 24], ["+", 0, 493, 0, 662, 12, 652, 486, 739, 0, 25], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 17, 131], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 735, 22]]
4
72
N = int(input()) A = list(map(lambda x: int(x), input().split(' '))) res = ((sum(A)**2 - sum(list(map(lambda x: x**2, A)))) / 2) % (10**9 + 7) print(int(res))
N = int(input()) A = list(map(lambda x: int(x), input().split(' '))) res = ((sum(A)**2 - sum(list(map(lambda x: x**2, A)))) // 2) % (10**9 + 7) print(int(res))
[["-", 0, 662, 12, 657, 31, 23, 0, 657, 17, 85], ["+", 0, 662, 12, 657, 31, 23, 0, 657, 17, 676]]
5
81
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int M = 1e9 + 7; int main() { int n; cin >> n; ll a[n]; ll s[n + 1]; s[0] = 0; ll ans = 0; for (int i = 0; i < n; i++) { cin >> a[i]; s[i + 1] = s[i] + a[i]; } for (int i = 0; i < n - 1; i++) { int j = i + 1; i...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int M = 1e9 + 7; int main() { int n; cin >> n; ll a[n]; ll s[n + 1]; s[0] = 0; ll ans = 0; for (int i = 0; i < n; i++) { cin >> a[i]; s[i + 1] = s[i] + a[i]; } for (int i = 0; i < n - 1; i++) { int j = i + 1; l...
[["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 39, 78], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
175
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int M = 1e9 + 7; int main() { int n; cin >> n; ll a[n]; ll s[n + 1]; s[0] = 0; ll ans = 0; for (int i = 0; i < n; i++) { cin >> a[i]; s[i + 1] = s[i] + a[i]; } for (int i = 0; i < n - 1; i++) { int j = i + 1; i...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int M = 1e9 + 7; int main() { int n; cin >> n; ll a[n]; ll s[n + 1]; s[0] = 0; ll ans = 0; for (int i = 0; i < n; i++) { cin >> a[i]; s[i + 1] = s[i] + a[i]; } for (int i = 0; i < n - 1; i++) { int j = i + 1; l...
[["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 39, 78], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 17, 109], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25]]
1
167
// This file is a "Hello, world!" in C++ language by GCC for wandbox. #include <algorithm> #include <bits/stdc++.h> #include <cstdlib> #include <iostream> using namespace std; int main() { int n, i, j, x; long long int ans = 0, a[200014], b[200014]; b[0] = 0; cin >> n; long long int MOD = 1000000007; for (...
// This file is a "Hello, world!" in C++ language by GCC for wandbox. #include <algorithm> #include <bits/stdc++.h> #include <cstdlib> #include <iostream> using namespace std; int main() { int n, i, j, x; long long int ans = 0, a[200014], b[200014]; b[0] = 0; cin >> n; long long int MOD = 1000000007; for (...
[["-", 31, 16, 31, 16, 31, 16, 31, 69, 28, 22], ["-", 31, 16, 31, 16, 31, 69, 341, 342, 0, 70], ["-", 31, 16, 31, 16, 31, 69, 341, 342, 0, 22], ["-", 31, 16, 31, 16, 31, 69, 341, 342, 0, 73], ["-", 12, 16, 31, 16, 31, 16, 31, 16, 17, 48]]
1
178
n = int(input()) a = list(map(int,input().split())) s = 0 for i in range(n): s += a[i] #sはaの和 t = 0 for i in range(n): t += a[i]**2 #tはaの2乗和 ans = int(((s**2 - t)/2) % (10**9 + 7)) print(ans)
n = int(input()) a = list(map(int,input().split())) s = 0 for i in range(n): s += a[i] #sはaの和 t = 0 for i in range(n): t += a[i]**2 #tはaの2乗和 ans = ((s**2 - t)//2) % (10**9 + 7) print(ans)
[["-", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["-", 3, 4, 0, 657, 31, 23, 0, 657, 17, 85], ["+", 0, 662, 12, 657, 31, 23, 0, 657, 17, 676], ["-", 12, 652, 3, 4, 0, 657, 12, 23, 0, 25]]
5
91
#include <iostream> using namespace std; int main() { int n; cin >> n; int a[200000]; for (int i = 0; i < n; i++) { cin >> a[i]; } long long ans = 0, s = 0; for (int i = 0; i < n; i++) { ans = ((s * a[i]) + ans) % 1000000000 + 7; s = (s + a[i]) % 1000000000 + 7; } cout << ans << endl; }
#include <iostream> using namespace std; int main() { int n; cin >> n; int a[200000]; for (int i = 0; i < n; i++) { cin >> a[i]; } long long ans = 0, s = 0; for (int i = 0; i < n; i++) { ans = ((s * a[i]) + ans) % (1000000000 + 7); s = (s + a[i]) % (1000000000 + 7); } cout << ans << endl...
[["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
1
114
#include <bits/stdc++.h> #include <math.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n - 1); i >= 0; i--) using namespace std; typedef long long ll; const int MOD = 1000000007; const ll INF = 1LL << 62; const int IINF = 1000000000; template <class T> inline bool chmax(T &a, T b) {...
#include <bits/stdc++.h> #include <math.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n - 1); i >= 0; i--) using namespace std; typedef long long ll; const int MOD = 1000000007; const ll INF = 1LL << 62; const int IINF = 1000000000; template <class T> inline bool chmax(T &a, T b) {...
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
850
#include <algorithm> #include <bits/stdc++.h> #include <iostream> #include <string> using namespace std; typedef long long ll; ll a[1000005], s[1000005]; int main() { ll b, c, ma = 1231231231, ans = 0, n; cin >> n; for (ll i = 1; i <= n; i++) { scanf("%lld", &a[i]); s[i] = s[i - 1] + a[i]; } for (ll i...
#include <algorithm> #include <bits/stdc++.h> #include <iostream> #include <string> using namespace std; typedef long long ll; ll a[1000005], s[1000005]; int main() { ll b, c, ma = 1231231231, ans = 0, n; cin >> n; for (ll i = 1; i <= n; i++) { scanf("%lld", &a[i]); s[i] = s[i - 1] + a[i]; } for (ll i...
[["+", 0, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 0, 11, 12, 23, 0, 16, 12, 23, 0, 25]]
1
152
n=int(input()) l=list(map(int,input().split())) s=sum(l) s=s**2 for i in range(n): s=s-l[i]**2 s=s/2 print(int(s%(7+10**9)))
n=int(input()) l=list(map(int,input().split())) s=sum(l) s=s**2 for i in range(n): s=s-l[i]**2 s=s//2 print(int(s%(7+10**9)))
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 85], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 676]]
5
74
N = int(input()) A = [int(i) for i in input().split()] mod = 10**9 + 7 sum_A = sum(A) ans = 0 for i in A: ans += i * (sum_A := sum_A - i) % mod print(ans)
N = int(input()) A = [int(i) for i in input().split()] mod = 10**9 + 7 sum_A = sum(A) ans = 0 for i in A: ans += i * (sum_A := sum_A - i) % mod print(ans % mod)
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 109], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]]
5
64
#include <algorithm> #include <iostream> #include <list> #include <queue> #include <string> #include <vector> #define rep(i, n) for (i = 0; i < (n); i++) #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) #define MOD 1000000007 #define PI 3.14159265358979323846 #define INF 1 << 30 using namespace std;...
#include <algorithm> #include <iostream> #include <list> #include <queue> #include <string> #include <vector> #define rep(i, n) for (i = 0; i < (n); i++) #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) #define MOD 1000000007 #define PI 3.14159265358979323846 #define INF 1 << 30 using namespace std;...
[["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["+", 0, 30, 0, 14, 8, 9, 0, 9, 0, 45], ["+", 0, 30, 0, 14, 8, 9, 0, 9, 0, 46], ["+", 31, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 31, 16, 12, 23, 0, 16, 31, 23, 0, 25], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 17, 109], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 12, 22]]
1
191
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O0") typedef long long int ll; typedef long double ld; #define rep(i, n) for (ll i = 0; i < (n); ++i) const ll mod = 1e9 + 7; const ll INF = 1e18; #define All(a) (a).begin(), (a).end() #define Pi acos(-1) class mint { public: long long x; constexp...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O0") typedef long long int ll; typedef long double ld; #define rep(i, n) for (ll i = 0; i < (n); ++i) const ll mod = 1e9 + 7; const ll INF = 1e18; #define All(a) (a).begin(), (a).end() #define Pi acos(-1) class mint { public: long long x; constexp...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78]]
1
617
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long lo...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long lo...
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
245
#include <iostream> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> A(N); vector<long long> B(N, 0); int mod = 1000000007; for (int i = 0; i < N; ++i) { cin >> A[i]; B[i + 1] = B[i] + A[i]; } long long ans = 0; for (int i = 0; i < N; i++) { long long sum =...
#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 long ans = 0; for (int i = 0; i < N; i++) { long long s...
[["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]]
1
153
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<int> A(n); rep(i, n) cin >> A[i]; const int m = 1000000007; ll ans = 0; ll x = 0; rep(i, n) { ans = (ans + A[i] * x % m)...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<int> A(n); rep(i, n) cin >> A[i]; const int m = 1000000007; ll ans = 0; ll x = 0; rep(i, n) { ans = (ans + A[i] * x % m)...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
127
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a.at(i); long long sum = 0; long long u = 0; for (int i = n - 1; i > 0; i--) { u += a.at(i); sum += u * a.at(i - 1); sum = sum %...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a.at(i); long long sum = 0; long long u = 0; for (int i = n - 1; i > 0; i--) { u += a.at(i); u = u % 1000000007; sum += u * a.at...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
119
#include <bits/stdc++.h> using namespace std; template <typename T, typename V> void __print(const pair<T, V> &x) { cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}'; } template <typename T> void __print(const T &x) { int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? ...
#include <bits/stdc++.h> using namespace std; template <typename T, typename V> void __print(const pair<T, V> &x) { cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}'; } template <typename T> void __print(const T &x) { int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? ...
[["+", 12, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["-", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["-", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
1
410
import numpy as np n = int(input()) a = np.array(list(map(int, input().split()))) s=[0]*(n-1) tmp=0 for i in range(n-1): tmp=(tmp+a[(i+1)*-1])%(10**9+7) s[(i+1)*-1]=tmp print((s*(a[:-1]%(10**9+7))).sum()%(10**9+7))
import numpy as np n = int(input()) a = np.array(list(map(int, input().split()))) s=[0]*(n-1) tmp=0 for i in range(n-1): tmp=(tmp+a[(i+1)*-1])%(10**9+7) s[(i+1)*-1]=tmp print(int((s*a[:-1]%(10**9+7)).sum()%(10**9+7)))
[["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["-", 63, 319, 500, 23, 0, 657, 12, 23, 0, 24], ["-", 0, 657, 31, 652, 63, 319, 500, 23, 0, 25], ["+", 0, 652, 3, 4, 0, 657, 12, 23, 0, 25]]
5
131
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.read...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.read...
[["+", 0, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25]]
3
259
#include <bits/stdc++.h> using namespace std; int main() { const long long MOD = 1000000007; long long N; cin >> N; long long A; long long ans = 0; long long souwa = 0; for (int i = 0; i < N; i++) { cin >> A; ans += souwa * A % MOD; souwa += A % MOD; if (souwa > MOD) { souwa = sou...
#include <bits/stdc++.h> using namespace std; int main() { const long long MOD = 1000000007; long long N; cin >> N; long long A; long long ans = 0; long long souwa = 0; for (int i = 0; i < N; i++) { cin >> A; ans += souwa * A % MOD; souwa += A % MOD; if (souwa > MOD) { souwa = sou...
[["-", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95]]
1
112
N = int(input()) A= list(map(int,input().split())) mod_num = 1.0e+9 + 7 rest = 0 temp = 0 for i in range(N-1): temp+=A[i] rest += temp*A[i+1] rest = rest%mod_num print(int(rest%mod_num))
N = int(input()) A= list(map(int,input().split())) mod_num = int(1.0e+9 + 7) rest = 0 temp = 0 for i in range(N-1): temp+=A[i] rest += temp*A[i+1] rest = rest%mod_num print(int(rest%mod_num))
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
76
#include <iostream> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; vector<uint64_t> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } uint64_t div = 1000000000 + 7; uint64_t sig = 0; for (int i = 0; i < n; i++) { sig += a[i]; } vector<uint64_t> si...
#include <iostream> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; vector<uint64_t> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } uint64_t div = 1000000000 + 7; uint64_t sig = 0; for (int i = 0; i < n; i++) { sig += a[i]; } vector<uint64_t> si...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
189
n = int(input()) a = list(map(int, input().split())) A = sum(a) print(A) s = 0 for i in range(n-1): A = A - a[i] b = (a[i]*A)%(10**9+7) s = s + b print(s%(10**9+7))
n = int(input()) a = list(map(int, input().split())) A = sum(a) s = 0 for i in range(n-1): A = A - a[i] b = (a[i]*A)%(10**9+7) s = s + b print(s%(10**9+7))
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
91
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 int main() { int n; cin >> n; long long ans = 0, tmp; vector<long long> a(n), b(n + 1, 0); for (int i = 0; i < n; i++) { cin >> a[i]; b[i + 1] = b[i] + a[i]; } for (int i = 1; i < n + 1; i++) { tmp = (b[n] - b[i]) * a[i - 1...
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 int main() { int n; cin >> n; long long ans = 0, tmp = 0; vector<long long> a(n), b(n + 1, 0); for (int i = 0; i < n; i++) { cin >> a[i]; b[i + 1] = b[i] + a[i]; } for (int i = 1; i < n + 1; i++) { tmp = (b[n] - b[i]) % MOD...
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 17, 109], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 12, 22]]
1
146
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; signed long long A[200000] = {}; signed long long Ans = 0; signed long long kakekioku = 0; signed long long Anstmp = 0; for (int i = 1; i <= N; i++) { cin >> A[i]; } for (int i = N - 1; i >= 1; i--) { kakekioku +...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; signed long long A[200000] = {}; signed long long Ans = 0; signed long long kakekioku = 0; signed long long Anstmp = 0; for (int i = 1; i <= N; i++) { cin >> A[i]; } for (int i = N - 1; i >= 1; i--) { kakekioku +...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
128
#include <bits/stdc++.h> using namespace std; long long a[200005]; long long cnt[200005]; long long ans = 0; const long long MOD = 1e9 + 7; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } cnt[1] = a[1]; for (int i = 2; i <= n; i++) { cnt[i] = (cnt[i - 1] + a[i]) % MOD; ...
#include <bits/stdc++.h> using namespace std; long long a[200005]; long long cnt[200005]; long long ans = 0; const long long MOD = 1e9 + 7; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } cnt[1] = a[1]; for (int i = 2; i <= n; i++) { cnt[i] = (cnt[i - 1] + a[i]) % MOD; ...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
170
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n, ans = 0; ll a[205000], s[205000]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; s[i] = a[i] + s[i - 1]; } for (int i = 0; i < n; i++) { ans += a[i] * (s[n - 1] - s[i]) % 1000000007; ans %= 1000000007;...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n, ans = 0; ll a[205000], s[205000]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; s[i] = a[i] + s[i - 1]; } for (int i = 0; i < n; i++) { ans += a[i] * ((s[n - 1] - s[i]) % 1000000007); ans %= 100000000...
[["+", 12, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
1
128
#include <bits/stdc++.h> using namespace std; #define ll long long #define MOD 1000000007 const int maxn = 200005; int N; ll A[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> N; ll total = 0; for (int i = 0; i < N; i++) { cin >> A[i]; total += A[i]; } ll sum = 0; for (in...
#include <bits/stdc++.h> using namespace std; #define ll long long #define MOD 1000000007 const int maxn = 200005; int N; ll A[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> N; ll total = 0; for (int i = 0; i < N; i++) { cin >> A[i]; total += A[i]; } ll sum = 0; for (in...
[["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 109], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
1
140
N = int(input()) A = list(map(int, input().split())) Asum = sum(A) % (10**9 + 7) ans = 0 for i in range(N): Asum = Asum - A[i] ans += A[i]*Asum if ans > (10**9 + 7): ans = ans % (10**9 + 7) print (ans)
N = int(input()) A = list(map(int, input().split())) Asum = sum(A) % (10**9 + 7) ans = 0 for i in range(N): Asum = Asum - A[i] ans += A[i]*Asum % (10**9 + 7) ans = ans % (10**9 + 7) print (ans)
[["-", 0, 656, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["+", 8, 196, 0, 1, 0, 677, 12, 657, 17, 109], ["-", 0, 656, 0, 7, 8, 196, 0, 57, 0, 102]]
5
92
n = int(input()) M = 1000000007 a = input().split() sum = 0 sq_sum = 0 for x in a: y = int(x) sum += y sq_sum += (y*y) sum = sum * sum ans = abs(sum - sq_sum)/2 ans = (ans + M) % M ans = int(ans) print(ans)
n = int(input()) M = 1000000007 a = input().split() sum = 0 sq_sum = 0 for x in a: y = int(x) sum += y sq_sum += (y*y) sum = sum * sum ans = abs(sum - sq_sum)//2 ans = (ans + M) % M ans = int(ans) print(ans)
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 85], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 676]]
5
81
#include <bits/stdc++.h> using namespace std; #define pb push_back #define endl '\n' #define mod 1000000007 #define forn(i, n) for (int i = 0; i < (int)(n); i++) #define REPa(i, b) for (int i = 1; i <= b; i++) #define REP(i, n) for (int i = 0; i < n; i++) #define init(arr, value) memset(arr, value, sizeof(arr)) #define...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define endl '\n' #define mod 1000000007 #define forn(i, n) for (int i = 0; i < (int)(n); i++) #define REPa(i, b) for (int i = 1; i <= b; i++) #define REP(i, n) for (int i = 0; i < n; i++) #define init(arr, value) memset(arr, value, sizeof(arr)) #define...
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
450
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; const long double PI = (acos(-1)); const long long MOD = 1000000007; struct Edge { long long to; long long cost; }; using Graph = vector<vector<Edge>>; using P = pair<ll, ll>; const long long INF = 1LL << 60; #defin...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; const long double PI = (acos(-1)); const long long MOD = 1000000007; struct Edge { long long to; long long cost; }; using Graph = vector<vector<Edge>>; using P = pair<ll, ll>; const long long INF = 1LL << 60; #defin...
[["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 17, 109], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 12, 22], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25]]
1
1,702
n = int(input()) a = list(map(int, input().split())) c = 10 ** 9 + 7 ans = 0 tmp_val = 0 for i in range(n): tmp_val = (tmp_val + a[i]) % c for i in range(n-1): tmp_val = (tmp_val - a[i]) % c ans += (tmp_val * a[i]) % c print(ans)
n = int(input()) a = list(map(int, input().split())) c = 10 ** 9 + 7 ans = 0 tmp_val = 0 for i in range(n): tmp_val = (tmp_val + a[i]) % c for i in range(n-1): tmp_val = (tmp_val - a[i]) % c ans += (tmp_val * a[i]) % c print(ans % c)
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 109], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]]
5
96
#include <bits/stdc++.h> using namespace std; #define froop1(a, n) for (int i = a; i < n; i++) #define froop2(a, n) for (int i = a; i > n; i--) #define ll long long #define pq(name, type) priority_queue<type> name #define vec(name, type, length, value) vector<type> name(length, value) #define vec2(name, type, length...
#include <bits/stdc++.h> using namespace std; #define froop1(a, n) for (int i = a; i < n; i++) #define froop2(a, n) for (int i = a; i > n; i--) #define ll long long #define pq(name, type) priority_queue<type> name #define vec(name, type, length, value) vector<type> name(length, value) #define vec2(name, type, length...
[["+", 12, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 31, 23, 0, 25], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 109], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 13], ["-", 8, 9, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 12, 13]]
1
159
def fastSumPair(A): L = len(A) M = 1000000007 # (a + b + c)**2 = a**2 + b**2 + c**2 + 2*(a*b + b*c + c*a) # derive from this equation # first array A_1_sum = 0 for i in range(0, L): A_1_sum = (A_1_sum + A[i]) A_1_sum = (A_1_sum ** 2) # second array ...
def fastSumPair(A): L = len(A) M = 1000000007 # (a + b + c)**2 = a**2 + b**2 + c**2 + 2*(a*b + b*c + c*a) # derive from this equation # first array A_1_sum = 0 for i in range(0, L): A_1_sum = (A_1_sum + A[i]) A_1_sum = (A_1_sum ** 2) # second array ...
[["-", 0, 657, 31, 652, 3, 4, 0, 657, 17, 85], ["+", 0, 657, 31, 652, 3, 4, 0, 657, 17, 676]]
5
123
#include <bits/stdc++.h> using namespace std; #define ll long long ll mod = 1e9 + 7; int main() { ll a, b, c; ll l; ll n; ll i, j, k; ll mn = 0; cin >> n; vector<ll> v; ll cnt = 0; ll cum[n + 10] = {0}; for (j = 0; j < n; j++) { cin >> a; v.push_back(a); if (!j) cum[j] = a; e...
#include <bits/stdc++.h> using namespace std; #define ll long long ll mod = 1e9 + 7; int main() { ll a, b, c; ll l; ll n; ll i, j, k; ll mn = 0; cin >> n; vector<ll> v; ll cnt = 0; ll cum[n + 10] = {0}; for (j = 0; j < n; j++) { cin >> a; v.push_back(a); if (!j) cum[j] = a; e...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
181
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N, 0); int64_t tmp = 0; int64_t sum = 0; int64_t MOD = 1000000007; for (int i = 0; i < N; i++) { cin >> A.at(i); } for (int i = N - 1; i >= 1; i--) { tmp += A.at(i); sum += A.at(i - 1) * tmp; ...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N, 0); int64_t tmp = 0; int64_t sum = 0; int64_t MOD = 1000000007; for (int i = 0; i < N; i++) { cin >> A.at(i); } for (int i = N - 1; i >= 1; i--) { tmp += A.at(i); sum += A.at(i - 1) * tmp; ...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
123
n=int(input()) a=list(map(int,input().split())) x=sum(a) y=0 for i in range(n): y+=a[i]**2 ans = (x**2 - y)/2 ans = ans % (10**9+7) print(int(ans))
n=int(input()) a=list(map(int,input().split())) x=sum(a) y=0 for i in range(n): y+=a[i]**2 ans = (x**2 - y)//2 ans = ans % (10**9+7) print(int(ans))
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 85], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 676]]
5
79
#include <cmath> #include <ctype.h> #include <iostream> #include <limits.h> #include <regex> #include <sstream> #include <stdio.h> #include <string.h> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long int ll; typedef vector<int> vi; //最大公約数 int g...
#include <cmath> #include <ctype.h> #include <iostream> #include <limits.h> #include <regex> #include <sstream> #include <stdio.h> #include <string.h> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long int ll; typedef vector<int> vi; //最大公約数 int g...
[["+", 12, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 12, 16, 12, 23, 0, 16, 31, 23, 0, 25], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 109], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 13]]
1
496
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> #define REP(i, n) for (int(i) = 0; (i) < (int)(n); (i)++) #define foreach(c, itr) \ for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); itr++) using namespace std; const int...
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> #define REP(i, n) for (int(i) = 0; (i) < (int)(n); (i)++) #define foreach(c, itr) \ for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); itr++) using namespace std; const int...
[["+", 8, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 8, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 0, 7, 8, 1, 0, 11, 12, 16, 17, 109], ["+", 0, 7, 8, 1, 0, 11, 12, 16, 12, 22]]
1
164
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; queue<int> que; int tsum = 0; int con; int64_t s = 0; int64_t mod = 1000000007; for (int i = 0; i < n; i++) { cin >> con; que.push(con); tsum += con % mod; } for (int i = 0; i < n - 1; i++) { tsum -= que.fro...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; queue<int> que; int64_t tsum = 0; int con; int64_t s = 0; int64_t mod = 1000000007; for (int i = 0; i < n; i++) { cin >> con; que.push(con); tsum += con; } for (int i = 0; i < n - 1; i++) { tsum -= que.front...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
138
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define FOR(i, a, b) for (int i = (a); i < (b); i++) using Graph = vector<vector<int>>; int main() { int N; cin >> N; long long sum = 0; long long sum2 = 0; FOR(i, 0, N) { long long x; cin >> x; sum += x; sum %= 1000000007; ...
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define FOR(i, a, b) for (int i = (a); i < (b); i++) using Graph = vector<vector<int>>; int main() { int N; cin >> N; long long sum = 0; long long sum2 = 0; FOR(i, 0, N) { long long x; cin >> x; sum += x; sum %= 1000000007; ...
[["+", 0, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["-", 31, 16, 12, 16, 31, 23, 0, 16, 17, 85], ["-", 31, 16, 12, 16, 31, 23, 0, 16, 12, 13], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 17, 109], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 12, 13], ["+", 12, 16, 31, 23, 0, 16, 31, 23, 0, 25], ["+", 31, 16, 12, 16, 31, 23, 0, 16, 17, 48], [...
1
138
#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…「sからnまで」の降順の繰り返...
#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…「sからnまで」の降順の繰り返...
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
196
n = int(input()) a = list(map(int, input().split())) m = 1000000007 s = sum(a) ans = 0 for i in range(n): aa = a[i] ans += aa * (s - aa) ans = int(ans/2) ans = ans % m print(ans)
n = int(input()) a = list(map(int, input().split())) m = 1000000007 s = sum(a) ans = 0 for i in range(n): aa = a[i] ans += aa * (s - aa) ans = ans//2 ans = ans % m print(ans)
[["-", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["-", 0, 662, 12, 652, 3, 4, 0, 657, 17, 85], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 676], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
77
#include <bits/stdc++.h> using namespace std; int main() { // main_program int N; int64_t sum = 0; int64_t kei = 0; cin >> N; vector<int> A(N); vector<int64_t> B(N); for (int i = 0; i < N; i++) { cin >> A.at(i); B.at(i) = A.at(i) % 1000000007; } for (int i = N - 1; i > 0; i--) { kei += ...
#include <bits/stdc++.h> using namespace std; int main() { // main_program int N; int64_t sum = 0; int64_t kei = 0; cin >> N; vector<int> A(N); vector<int64_t> B(N); for (int i = 0; i < N; i++) { cin >> A.at(i); B.at(i) = A.at(i) % 1000000007; } for (int i = N - 1; i > 0; i--) { kei += ...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
142
n,*l=map(int,open(0).read().split()) print((sum(l)**2-sum(i**2 for i in l)//2)%(10**9+7))
n,*l=map(int,open(0).read().split()) print((sum(l)**2-sum(i**2 for i in l))//2%(10**9+7))
[["+", 3, 4, 0, 657, 31, 657, 31, 23, 0, 25], ["-", 0, 652, 3, 4, 0, 657, 31, 23, 0, 25]]
5
54
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<long long> V(N); for (int i = 0; i < N; i++) { cin >> V.at(i); } long long C = 1000000007; long long Sum = 0; vector<long long> W(N - 1); W.at(0) = V.at(0); for (int i = 1; i < N - 1; i++) { W.at(i) = W.at(i ...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<long long> V(N); for (int i = 0; i < N; i++) { cin >> V.at(i); } long long C = 1000000007; long long Sum = 0; vector<long long> W(N - 1); W.at(0) = V.at(0); for (int i = 1; i < N - 1; i++) { W.at(i) = W.at(i ...
[["+", 12, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["+", 31, 23, 0, 16, 31, 2, 3, 4, 0, 25], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 17, 109], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 12, 22]]
1
181
#include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; long long mod = 1000000007; long long modpow(long long m, long long n) { long long res = 1; if...
#include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; long long mod = 1000000007; long long modpow(long long m, long long n) { long long res = 1; if...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
240
N = int(input()) A = list(map(int, input().split())) A_sum = 0 for i in range(0, N, 1): A_sum = A_sum + A[i] A_sum_sq = A_sum * A_sum idv_sq_sum = 0 for i in range(0, N, 1): idv_sq_sum += A[i] * A[i] Answer = (A_sum_sq - idv_sq_sum) / 2 print(int(Answer%(10**9 + 7)))
N = int(input()) A = list(map(int, input().split())) A_sum = 0 for i in range(0, N, 1): A_sum = A_sum + A[i] A_sum_sq = A_sum * A_sum idv_sq_sum = 0 for i in range(0, N, 1): idv_sq_sum += A[i] * A[i] Answer = (A_sum_sq - idv_sq_sum) // 2 print(Answer%(10**9 + 7))
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 85], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 676], ["-", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["-", 0, 652, 3, 4, 0, 657, 12, 23, 0, 25]]
5
103
#include <bits/stdc++.h> #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); typedef long long int ll; using names...
#include <bits/stdc++.h> #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); typedef long long int ll; using names...
[["+", 12, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["-", 12, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["-", 12, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
1
195
#include <bits/stdc++.h> using namespace std; int main() { int N; long long sum = 0, ans = 0; cin >> N; vector<long long> A(N); for (int i = 0; i < N; i++) { cin >> A.at(i); sum += A.at(i); } for (int i = 0; i < N; i++) { sum -= A.at(i); ans += A.at(i) * (sum); ans = ans % (1000000000...
#include <bits/stdc++.h> using namespace std; int main() { int N; long long sum = 0, ans = 0; cin >> N; vector<long long> A(N); for (int i = 0; i < N; i++) { cin >> A.at(i); sum += A.at(i); } for (int i = 0; i < N; i++) { sum -= A.at(i); ans += A.at(i) * (sum % (1000000000 + 7)); ans ...
[["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 109], ["+", 12, 16, 12, 23, 0, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 16, 12, 23, 0, 16, 31, 13], ["+", 12, 23, 0, 16, 12, 23, 0, 16, 17, 72], ["+", 12, 23, 0, 16, 12, 23, 0, 16, 12, 13], ["+", 12, 16, 12, 23, 0, 16, 12, 23, 0, 25]]
1
130
#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() { unsigned long long int n; cin >> n; unsigned long long int a[n]; unsigned long long int mod = pow(10, 9) + 7; rep(i, n) { cin >> a[i]; if (a[i] >= mod) { a[i] %=...
#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() { unsigned long long int n; cin >> n; unsigned long long int a[n]; unsigned long long int mod = pow(10, 9) + 7; rep(i, n) { cin >> a[i]; if (a[i] >= mod) { a[i] %=...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
161
#include <iostream> #include <vector> int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); int N; std::cin >> N; long long sumA = 0, ans = 0; std::vector<long long> A(N, 0); for (int i = 0; i < N; ++i) { std::cin >> A[i]; sumA += A[i]; } long long modN = 1000000007; for (int i =...
#include <iostream> #include <vector> int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); int N; std::cin >> N; long long sumA = 0, ans = 0; std::vector<long long> A(N, 0); for (int i = 0; i < N; ++i) { std::cin >> A[i]; sumA += A[i]; } long long modN = 1000000007; for (int i =...
[["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
1
150
#include <bits/stdc++.h> using namespace std; int main(void) { long n; cin >> n; long total = 0; long ans = 0; vector<long> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; total += v[i]; total %= 1000000007; } for (int i = 0; i < n - 1; i++) { total -= v[i]; ans += total * v[i]; ...
#include <bits/stdc++.h> using namespace std; int main(void) { long n; cin >> n; long total = 0; long ans = 0; vector<long> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; total += v[i]; total %= 1000000007; } for (int i = 0; i < n - 1; i++) { total -= v[i]; total %= 1000000007; ...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
129
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ppb pop_back #define pf push_front #define ppf pop_front #define all(x) (x).begin(), (x).end() #define ll long long #define mod 1000000007 #define fr first #define sc second #define vl vector<ll> #define pll pair<ll, ll> #define u_map unordered...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ppb pop_back #define pf push_front #define ppf pop_front #define all(x) (x).begin(), (x).end() #define ll long long #define mod 1000000007 #define fr first #define sc second #define vl vector<ll> #define pll pair<ll, ll> #define u_map unordered...
[["+", 31, 23, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 31, 23, 0, 16, 31, 16, 31, 23, 0, 25], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 17, 109], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 12, 22]]
1
247
#include <bits/stdc++.h> using namespace std; #define int long long const int mod = 1e9 + 7; int32_t main() { int n; cin >> n; int a[n + 1]; for (int i = 1; i <= n; i++) { cin >> a[i]; } int suffixSum[n + 1]; for (int i = n; i >= 1; i--) { if (i == n) { suffixSum[i] = a[i]; } else { ...
#include <bits/stdc++.h> using namespace std; #define int long long const int mod = 1e9 + 7; int32_t main() { int n; cin >> n; int a[n + 1]; for (int i = 1; i <= n; i++) { cin >> a[i]; } int suffixSum[n + 1]; for (int i = n; i >= 1; i--) { if (i == n) { suffixSum[i] = a[i]; } else { ...
[["+", 8, 9, 0, 1, 0, 16, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 12, 22]]
1
173
def multmod(a,b,m): ans = 0 a = a % m while b: if (b & 1): # odd ans = (ans + a) % m a = (2 * a) % m b >>= 1 # b = b / 2 return ans n = int(input()) S = [int(a) for a in input().split()] divisor = 10**9 + 7 tot = 0 a,b = 0,0 arr_sum = sum(S) #% divisor arr_ssq = arr_sum*arr_sum %...
def multmod(a,b,m): ans = 0 a = a % m while b: if (b & 1): # odd ans = (ans + a) % m a = (2 * a) % m b >>= 1 # b = b / 2 return ans n = int(input()) S = [int(a) for a in input().split()] divisor = 10**9 + 7 tot = 0 a,b = 0,0 arr_sum = sum(S) #% divisor arr_ssq = arr_sum*arr_sum #...
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 109], ["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 22]]
5
149
# Efficient python 3 program to find sum # pair products in an array. mod=1000000007 # required function def findProductSum(A, n): # calculating array sum (a1 + a2 ... + an) array_sum = 0 for i in range(0, n, 1): array_sum = array_sum + A[i] # calcualting square of array sum # (a1 + a2 + ... + an)^2 ...
# Efficient python 3 program to find sum # pair products in an array. mod=1000000007 # required function def findProductSum(A, n): # calculating array sum (a1 + a2 ... + an) array_sum = 0 for i in range(0, n, 1): array_sum = array_sum + A[i] # calcualting square of array sum # (a1 + a2 + ... + an)^2 ...
[["-", 0, 14, 8, 196, 0, 37, 0, 657, 17, 85], ["+", 0, 14, 8, 196, 0, 37, 0, 657, 17, 676]]
5
145
import java.util.Scanner; public class Main { public static final long MOD = 1000000007; public static void main(String[] args) { try (Scanner sc = new Scanner(System.in);) { int n = sc.nextInt(); long[] a = new long[n]; long[] sum = new long[n]; a[0] = sc.nextLong(); sum[0] = ...
import java.util.Scanner; public class Main { public static final long MOD = 1000000007; public static void main(String[] args) { try (Scanner sc = new Scanner(System.in);) { int n = sc.nextInt(); long[] a = new long[n]; long[] sum = new long[n]; a[0] = sc.nextLong(); sum[0] = ...
[["+", 8, 196, 0, 503, 49, 200, 51, 16, 17, 109], ["+", 8, 196, 0, 503, 49, 200, 51, 16, 12, 22]]
3
227
#include <algorithm> //sort(a.begin(), a.end());reverse(a.begin(), a.end()); #include <bits/stdc++.h> #include <iostream> #include <math.h> //pow(x,y)=x^y 99999とかの場合+1するif文 #define rep(init, i, n) for (int i = init; i < (n); i++) #define ll long long #define rev(s) reverse(s.begin(), s.end()) #define sor(v) sort(v.begi...
#include <algorithm> //sort(a.begin(), a.end());reverse(a.begin(), a.end()); #include <bits/stdc++.h> #include <iostream> #include <math.h> //pow(x,y)=x^y 99999とかの場合+1するif文 #define rep(init, i, n) for (int i = init; i < (n); i++) #define ll long long #define rev(s) reverse(s.begin(), s.end()) #define sor(v) sort(v.begi...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 20], ["-", 0, 14, 8, 9, 0, 7, 26, 27, 28, 22], ["+", 0, 14, 8, 9, 0, 7, 26, 27, 28, 22]]
1
221
#include <cmath> #include <iostream> using namespace std; const int sz = 1000000007; int main() { int n; cin >> n; long long arr[n]; int pref[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } pref[0] = arr[0]; for (int i = 1; i < n; i++) { pref[i] = pref[i - 1] + arr[i]; } long long s...
#include <cmath> #include <iostream> using namespace std; const int sz = 1000000007; int main() { int n; cin >> n; long long arr[n]; long long pref[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } pref[0] = arr[0]; for (int i = 1; i < n; i++) { pref[i] = pref[i - 1] + arr[i]; } long ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
167
N = int(input()) A = list(map(int, input().split())) ans = sum(A) ** 2 for a in A: ans = ans - a ** 2 ans = ans // 2 print(int(ans%(10^9+7)))
N = int(input()) A = list(map(int, input().split())) ans = sum(A) ** 2 for a in A: ans = ans - a ** 2 ans = ans // 2 print(int(ans%(10**9+7)))
[["-", 3, 4, 0, 657, 12, 23, 0, 657, 17, 140], ["+", 0, 657, 12, 23, 0, 657, 31, 657, 17, 578]]
5
65
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; // find_by_order(k) returns iterator to kth element starting from 0; // order_of_key(k) returns count of elements strictly smaller than k; #define ll long long int #define M 1000000007 #define ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; // find_by_order(k) returns iterator to kth element starting from 0; // order_of_key(k) returns count of elements strictly smaller than k; #define ll long long int #define M 1000000007 #define ...
[["+", 31, 23, 0, 16, 31, 16, 31, 16, 17, 109], ["+", 31, 23, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 109], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22]]
1
185
#include <bits/stdc++.h> #define int long long #define pb push_back #define pf emplace_front #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define pii pair<int, int> #define psi pair<string, int> #define vi vector<int> #define vpii vector<pii> #define vvi vector<vi> #define sz(x) (int)...
#include <bits/stdc++.h> #define int long long #define pb push_back #define pf emplace_front #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define pii pair<int, int> #define psi pair<string, int> #define vi vector<int> #define vpii vector<pii> #define vvi vector<vi> #define sz(x) (int)...
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
352
#include <bits/stdc++.h> using namespace std; using ll = long long; #define BIG_PRIME 1000000007 #define rep(i, n) for (int i = 0; i < (n); ++i) int main() { int n; cin >> n; vector<ll> a(n); rep(i, n) cin >> a[i]; ll horizontal_sum = a[n - 1]; ll ans = 0; for (int i = n - 2; i >= 0; --i) { ans += ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define BIG_PRIME 1000000007 #define rep(i, n) for (int i = 0; i < (n); ++i) int main() { int n; cin >> n; vector<ll> a(n); rep(i, n) cin >> a[i]; ll horizontal_sum = a[n - 1]; ll ans = 0; for (int i = n - 2; i >= 0; --i) { ans += ...
[["-", 0, 7, 8, 9, 0, 1, 0, 16, 17, 109], ["-", 8, 9, 0, 1, 0, 16, 12, 91, 17, 92], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 132]]
1
126
#include <stdio.h> #include <stdlib.h> unsigned long long mod(unsigned long long n) { return n % (1000000000 + 7); } int main() { int N; unsigned long long ans; scanf("%d", &N); unsigned long long A[N + 1]; unsigned long long sum; ans = 0; sum = 0; for (int i = 1; i <= N; i++) { scanf("%llu", &A[...
#include <stdio.h> #include <stdlib.h> unsigned long long mod(unsigned long long n) { return n % (1000000000 + 7); } int main() { int N; unsigned long long ans; scanf("%d", &N); unsigned long long A[N + 1]; unsigned long long sum; ans = 0; sum = 0; for (int i = 1; i <= N; i++) { scanf("%llu", &A[...
[["+", 3, 4, 0, 16, 12, 16, 12, 2, 63, 22], ["+", 0, 16, 12, 16, 12, 2, 3, 4, 0, 24], ["+", 0, 16, 12, 16, 12, 2, 3, 4, 0, 25]]
0
175
#include <bits/stdc++.h> #include <math.h> using namespace std; const long long mod = 1e9 + 7; int main() { unsigned long long int a[200001]; unsigned long long int res = 0; long n; cin >> n; unsigned long long int all = 0; for (int i = 0; i < n; i++) { cin >> a[i]; all = (all + a[i]) % mod; } ...
#include <bits/stdc++.h> #include <math.h> using namespace std; const long long mod = 1e9 + 7; int main() { long long int a[200001]; long long int res = 0; long n; cin >> n; long long int all = 0; for (int i = 0; i < n; i++) { cin >> a[i]; all = (all + a[i]) % mod; } long long int current_sum ...
[["-", 0, 14, 8, 9, 0, 43, 39, 86, 0, 87], ["-", 0, 7, 8, 9, 0, 43, 39, 86, 0, 87]]
1
188
n=int(input()) list=input().split() sum=0 for i in range(n): sum+=int(list[i]) sum=sum*sum sum2=0 for i in range(n): sum2+=int(list[i])*int(list[i]) sum-=sum2 sum/=2 sum%=1000000007 print(int(sum))
n=int(input()) list=input().split() sum=0 for i in range(n): sum+=int(list[i]) sum=sum*sum sum2=0 for i in range(n): sum2+=int(list[i])*int(list[i]) sum-=sum2 sum//=2 sum%=1000000007 print(int(sum))
[["-", 36, 36, 0, 656, 0, 1, 0, 677, 17, 90], ["+", 36, 36, 0, 656, 0, 1, 0, 677, 17, 691]]
5
86
#include <iostream> #define MOD 1000000007 using namespace std; typedef long long int ll; int main() { ll n; cin >> n; ll a[n]; for (ll i = 0; i < n; i++) { cin >> a[i]; } ll p[n] = {0}; p[n - 1] = a[n - 1]; for (ll i = n - 2; i > 0; i--) { p[i] = p[i + 1] + a[i]; } ll sum = 0; for (ll i ...
#include <iostream> #define MOD 1000000007 using namespace std; typedef long long int ll; int main() { ll n; cin >> n; ll a[n]; for (ll i = 0; i < n; i++) { cin >> a[i]; } ll p[n] = {0}; p[n - 1] = a[n - 1]; for (ll i = n - 2; i > 0; i--) { p[i] = p[i + 1] + a[i]; } ll sum = 0; for (ll i ...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 109], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
173
/* Author: DreamCat4er Created: 29.08.2020 15:57:29 */ #include <bits/stdc++.h> using namespace std; const long long base = (long long)(1e9 + 7); long long a[(int)(2e5 + 500)]; long long sf[(int)(2e5 + 500)]; long long mul(long long x, long long y) { return (x * y) % base; } void add_self(long long &x,...
/* Author: DreamCat4er Created: 29.08.2020 15:57:29 */ #include <bits/stdc++.h> using namespace std; const long long base = (long long)(1e9 + 7); long long a[(int)(2e5 + 500)]; long long sf[(int)(2e5 + 500)]; long long mul(long long x, long long y) { return (x * y) % base; } void add_self(long long &x,...
[["+", 8, 9, 0, 7, 8, 1, 0, 2, 63, 22], ["+", 0, 7, 8, 1, 0, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 7, 8, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 1, 0, 2, 3, 4, 0, 21], ["+", 0, 7, 8, 1, 0, 2, 3, 4, 0, 25]]
1
307
N = int(input()) A_ls=list(map(int, input().split())) a=(sum(A_ls))**2 b=0 for i in A_ls: b+=(i**2) c=int((a-b+0.5)/2) print(c%(10**9+7)) #print(b) # 2darray [[0] * 4 for i in range(3)] # import itertools
N = int(input()) A_ls=list(map(int, input().split())) a=(sum(A_ls))**2 b=0 for i in A_ls: b+=(i**2) c=int((a-b)//2) print(c%(10**9+7)) #print(b) # 2darray [[0] * 4 for i in range(3)] # import itertools
[["-", 3, 4, 0, 657, 31, 23, 0, 657, 17, 72], ["-", 3, 4, 0, 657, 31, 23, 0, 657, 12, 531], ["-", 0, 662, 12, 652, 3, 4, 0, 657, 17, 85], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 17, 676]]
5
79
#include <bits/stdc++.h> using namespace std; #define ll long long int int main() { ll n, i, j, sum = 0, ans = 0; j = (1e9) + 7; vector<ll> a; cin >> n; a.resize(n); for (i = 0; i < n; i++) { cin >> a[i]; sum = (sum + a[i]) % j; } for (i = 0; i < n; i++) { sum = (sum - a[i] + j) % j; an...
#include <bits/stdc++.h> using namespace std; #define ll long long int int main() { ll n, i, j, sum = 0, ans = 0; j = (1e9) + 7; vector<ll> a; cin >> n; a.resize(n); for (i = 0; i < n; i++) { cin >> a[i]; sum = (sum + a[i]) % j; } for (i = 0; i < n; i++) { sum = (sum - a[i] + j) % j; an...
[["-", 0, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25], ["-", 0, 11, 12, 23, 0, 16, 12, 23, 0, 25], ["-", 8, 9, 0, 1, 0, 11, 12, 23, 0, 25]]
1
145
#include <bits/stdc++.h> #define INF 2147483647 #define ll long long using namespace std; const int Max = 2e5 + 20; const int Maxn = 1e7 + 20; const int mod = 1e9 + 7; inline int read() { int f = 1, x = 0; char ch; do { ch = getchar(); if (ch == '-') f = -1; } while (ch < '0' || ch > '9'); do { ...
#include <bits/stdc++.h> #define INF 2147483647 #define ll long long using namespace std; const int Max = 2e5 + 20; const int Maxn = 1e7 + 20; const int mod = 1e9 + 7; inline int read() { int f = 1, x = 0; char ch; do { ch = getchar(); if (ch == '-') f = -1; } while (ch < '0' || ch > '9'); do { ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 23, 0, 16, 31, 23, 0, 25], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 17, 109], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 12, 22]]
1
253
#include <bits/stdc++.h> using namespace std; #define make_it_fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL) #define mp m...
#include <bits/stdc++.h> using namespace std; #define make_it_fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL) #define mp m...
[["+", 0, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["+", 49, 50, 51, 16, 31, 23, 0, 16, 17, 109], ["+", 49, 50, 51, 16, 31, 23, 0, 16, 12, 22]]
1
739
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef map<int, int> mii; typedef vector<int> vi; typedef vector<vector<int>> vii; typedef vector<long long> vl; typedef vector<vector<ll>> vll; typedef vector<bool> vb; typ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef map<int, int> mii; typedef vector<int> vi; typedef vector<vector<int>> vii; typedef vector<long long> vl; typedef vector<vector<ll>> vll; typedef vector<bool> vb; typ...
[["+", 31, 23, 0, 16, 12, 16, 12, 23, 0, 24], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 17, 109], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 12, 22], ["+", 31, 23, 0, 16, 12, 16, 12, 23, 0, 25]]
1
315
#include <bits/stdc++.h> #define int long long #define rep(i, m, n) for (int i = m; i < n; i++) #define repr(i, n, m) for (int i = n; i >= m; i--) #define mod 1000000007 #define float long double #define pb push_back #define mp make_pair #define print(v1) \ ...
#include <bits/stdc++.h> #define int long long int #define rep(i, m, n) for (int i = m; i < n; i++) #define repr(i, n, m) for (int i = n; i >= m; i--) #define mod 1000000007 #define float long double #define pb push_back #define mp make_pair #define print(v1) ...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 17, 109], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 12, 22]]
1
362
#include <algorithm> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; #define FOR(S, X) for (int i = S; i < X; i++) #define FOR2(S, X) for (int j = S; j < X; j++) const int MOD = 1000000007; int main() { unsigned long long int sum = 0, n, a; vector<unsigned long long in...
#include <algorithm> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; #define FOR(S, X) for (int i = S; i < X; i++) #define FOR2(S, X) for (int j = S; j < X; j++) const long long int MOD = 1000000007; int main() { unsigned long long int sum = 0, n, a; vector<unsigned lo...
[["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 109], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
161
package main import ( "bufio" "fmt" "math" "os" "strconv" "strings" ) var mod int64 func main() { scan_init() n := scanInt() mod = int64(math.Pow(10,9)+7) a := make([]int64, n) for i:= 0; i<n; i++ { a[i] = int64(scanInt()) } var sum int64 sum = 0 rusekiOne := make([]int64, n) for i:= 0; i<n-1; i++ { ...
package main import ( "bufio" "fmt" "math" "os" "strconv" "strings" ) var mod int64 func main() { scan_init() n := scanInt() mod = int64(math.Pow(10,9)+7) a := make([]int64, n) for i:= 0; i<n; i++ { a[i] = int64(scanInt()) } var sum int64 sum = 0 rusekiOne := make([]int64, n) for i:= 0; i<n-1; i++ { ...
[["+", 0, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 16, 31, 23, 0, 16, 31, 23, 0, 25]]
7
565
#include <iostream> using namespace std; const int maxn = 2e5 + 5; const int mod = 1e9 + 7; int N, a[maxn]; long long sum[maxn]; int main() { cin >> N; for (int i = 0; i < N; ++i) cin >> a[i], sum[i + 1] = sum[i] + a[i]; int ans = 0; for (int i = 0; i < N - 1; ++i) { ans = (ans + a[i] * (sum[N] - sum[i ...
#include <iostream> using namespace std; const int maxn = 2e5 + 5; const int mod = 1e9 + 7; int N, a[maxn]; long long sum[maxn]; int main() { cin >> N; for (int i = 0; i < N; ++i) cin >> a[i], sum[i + 1] = sum[i] + a[i]; int ans = 0; for (int i = 0; i < N - 1; ++i) { ans = (ans + a[i] * ((sum[N] - sum[i...
[["+", 12, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 12, 16, 12, 23, 0, 16, 31, 23, 0, 25], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 17, 109], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 12, 22]]
1
145
#include <iostream> #define MOD 1000000007 using namespace std; typedef long long int ll; int main() { ll n; cin >> n; ll a[n]; for (ll i = 0; i < n; i++) { cin >> a[i]; } ll p[n]; for (ll i = 0; i < n; i++) p[i] = 0; p[n - 1] = a[n - 1]; for (ll i = n - 2; i > 0; i--) { p[i] = p[i + 1] +...
#include <iostream> #define MOD 1000000007 using namespace std; typedef long long int ll; int main() { ll n; cin >> n; ll a[n]; for (ll i = 0; i < n; i++) { cin >> a[i]; } ll p[n]; for (ll i = 0; i < n; i++) p[i] = 0; p[n - 1] = a[n - 1]; for (ll i = n - 2; i > 0; i--) { p[i] = p[i + 1] +...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 109], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
190
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)
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 85], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 676]]
5
79
#pragma GCC optimize(3, "Ofast", "inline") #include <bits/stdc++.h> #define int long long #define pb push_back #define pf push_front #define st first #define nd second #define sz(x) ((int)x.size()) #define ins insert #define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define lowbit(x) ((x) & (-x)) #de...
#pragma GCC optimize(3, "Ofast", "inline") #include <bits/stdc++.h> #define int long long #define pb push_back #define pf push_front #define st first #define nd second #define sz(x) ((int)x.size()) #define ins insert #define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define lowbit(x) ((x) & (-x)) #de...
[["+", 8, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 8, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 0, 7, 8, 1, 0, 11, 12, 16, 17, 109], ["+", 0, 7, 8, 1, 0, 11, 12, 16, 12, 22]]
1
380
/*Hatsune Miku 4ever!*/ #include <bits/stdc++.h> using namespace std; typedef long long ll; #define _for(i, a, b) for (int i = (a); i < b; i++) #define _rep(i, a, b) for (int i = (a); i > b; i--) #define INF 0x3f3f3f3f #define mod 1000000007 #define lowbit(x) ((x) & (-x)) #define pb push_back #define MIKU 39 #define De...
/*Hatsune Miku 4ever!*/ #include <bits/stdc++.h> using namespace std; typedef long long ll; #define _for(i, a, b) for (int i = (a); i < b; i++) #define _rep(i, a, b) for (int i = (a); i > b; i--) #define INF 0x3f3f3f3f #define mod 1000000007 #define lowbit(x) ((x) & (-x)) #define pb push_back #define MIKU 39 #define De...
[["+", 8, 9, 0, 37, 0, 16, 31, 23, 0, 24], ["+", 0, 37, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 37, 0, 16, 31, 23, 0, 16, 12, 22], ["+", 8, 9, 0, 37, 0, 16, 31, 23, 0, 25], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 109], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 12, 22]]
1
267
#include <bits/stdc++.h> using namespace std; #define int long long int #define ld long double #define F first #define S second #define P pair<int, int> #define pb push_back #define MOD 1000000007 const int N = 100005; int32_t main() { int n; cin >> n; vector<int> a(n), suffix(n + 1); for (int i = 0; i < n; i...
#include <bits/stdc++.h> using namespace std; #define int long long int #define ld long double #define F first #define S second #define P pair<int, int> #define pb push_back #define MOD 1000000007 const int N = 100005; int32_t main() { int n; cin >> n; vector<int> a(n), suffix(n + 1); for (int i = 0; i < n; i...
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
178
#include <algorithm> #include <assert.h> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> ...
#include <algorithm> #include <assert.h> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> ...
[["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 109], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
1
757
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))
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))
[["-", 36, 36, 0, 656, 0, 1, 0, 677, 17, 90], ["+", 36, 36, 0, 656, 0, 1, 0, 677, 17, 691]]
5
82
/*The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep.*/ // PRABHJOT SINGH A.K.A. PRABHI //~~~~~conquizztador~~~~~ #include <bits/stdc++.h> using namespace std; using lli = long long int; #define pb push_back #define eb emplace_back #define ...
/*The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep.*/ // PRABHJOT SINGH A.K.A. PRABHI //~~~~~conquizztador~~~~~ #include <bits/stdc++.h> using namespace std; using lli = long long int; #define pb push_back #define eb emplace_back #define ...
[["+", 0, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 0, 16, 12, 23, 0, 16, 12, 23, 0, 25]]
1
242
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' #define sz(v) (int)v.size() #define all(v) v.begin(), v.end() void dbg_out() { cerr << "\b\b]\n"; } template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << H << ", "; dbg_out(T...); } #define watch(...)...
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' #define sz(v) (int)v.size() #define all(v) v.begin(), v.end() void dbg_out() { cerr << "\b\b]\n"; } template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << H << ", "; dbg_out(T...); } #define watch(...)...
[["-", 0, 7, 8, 9, 0, 1, 0, 16, 17, 109], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 132]]
1
244
#include <bits/stdc++.h> #define test \ int t; \ cin >> t; \ while (t--) #define fast ...
#include <bits/stdc++.h> #define test \ int t; \ cin >> t; \ while (t--) #define fast ...
[["+", 0, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 0, 16, 12, 23, 0, 16, 31, 23, 0, 25], ["-", 31, 23, 0, 16, 12, 23, 0, 16, 17, 109], ["-", 31, 23, 0, 16, 12, 23, 0, 16, 12, 22]]
1
185
mod = 1_000_000_007 gets a = gets.split.map &:to_i tmp0 = a.sum ** 2 tmp1 = a.sum { |e| e ** 2 } puts (tmp0 - tmp1) % mod
mod = 1_000_000_007 gets a = gets.split.map &:to_i tmp0 = a.sum ** 2 tmp1 = a.sum { |e| e ** 2 } puts (tmp0 - tmp1) / 2 % mod # tmp0 = a.sum # tmp0 = ((tmp0 % mod) ** 2) % mod # tmp1 = a.sum { |e| e ** 2 } # tmp1 %= mod # ans = tmp0 < tmp1 ? tmp0 - tmp1 + mod : tmp0 - tmp1 # if ans.odd? # puts (ans + mod) / 2 ...
[["+", 0, 652, 3, 4, 0, 738, 31, 738, 17, 85], ["+", 0, 652, 3, 4, 0, 738, 31, 738, 12, 612]]
4
41
#include <bits/stdc++.h> using namespace std; // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // #define ordered_set tree<int, null_type,less<int>, // rb_tree_tag,tree_order_statistics_node_update> #define ll long long #define fill fill_n #define pf ...
#include <bits/stdc++.h> using namespace std; // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // #define ordered_set tree<int, null_type,less<int>, // rb_tree_tag,tree_order_statistics_node_update> #define ll long long #define fill fill_n #define pf ...
[["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
329
#include <algorithm> #include <ctype.h> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> A(n); for (int i = 0; i < n; i++) { cin >> A[i]; } int mod = 1000000007; long long S = 0; for (int i = 0; i < n; i++) { S += A[i]; } ...
#include <algorithm> #include <ctype.h> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> A(n); for (int i = 0; i < n; i++) { cin >> A[i]; } int mod = 1000000007; long long S = 0; for (int i = 0; i < n; i++) { S += A[i]; } ...
[["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 132]]
1
157
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; vector<long long> v; int main() { cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false); long long n, q, sum = 0; cin >> n; for (long long i = 0; i < n; i++) { cin >> q; sum += q; v.push_back(q); } q = 0; ...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; vector<long long> v; int main() { cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false); long long n, q, sum = 0; cin >> n; for (long long i = 0; i < n; i++) { cin >> q; sum += q; v.push_back(q); } q = 0; ...
[["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 109], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
1
150
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long ans = 0; long sum = 0; long sqSum = 0; final long MOD = 1000000007; for (int i = 0; i < n; i++) { long a = sc.nextLong(); s...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long ans = 0; long sum = 0; long sqSum = 0; final long MOD = 1000000007; for (int i = 0; i < n; i++) { long a = sc.nextLong(); s...
[["-", 0, 1, 0, 492, 3, 4, 0, 16, 17, 85], ["-", 0, 1, 0, 492, 3, 4, 0, 16, 12, 499]]
3
181
#include <bits/stdc++.h> using namespace std; #define int long long int #define ff first #define ss second #define pb push_back int bexp(int a, int b, int mod) { int res = 1; if (mod <= 0) return 0; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return re...
#include <bits/stdc++.h> using namespace std; #define int long long int #define ff first #define ss second #define pb push_back int bexp(int a, int b, int mod) { int res = 1; if (mod <= 0) return 0; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return re...
[["+", 12, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 12, 22]]
1
338