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" #define MOD 1000000007 #define rep(i, n) for (ll i = 0; i < (n); i++) #define rrep(i, n) for (ll i = (n)-1; i >= 0; i--) #define ALL(v) v.begin(), v.end() #define rALL(v) v.rbegin(), v.rend() #define FOR(i, j, k) for (ll i = j; i < k; i++) #define debug_print(var) cerr << #var << "=" << var <<...
#include "bits/stdc++.h" #define MOD 1000000007 #define rep(i, n) for (ll i = 0; i < (n); i++) #define rrep(i, n) for (ll i = (n)-1; i >= 0; i--) #define ALL(v) v.begin(), v.end() #define rALL(v) v.rbegin(), v.rend() #define FOR(i, j, k) for (ll i = j; i < k; i++) #define debug_print(var) cerr << #var << "=" << var <<...
[["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25]]
1
1,025
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<P, ll> PLL; typedef pair<P, P> PP; typedef vector<ll> VECLL; typedef vector<P> VECP; typedef priority_queue<P, VECP, greater<P>> PQP; typedef priority_queue<ll, VECLL, greater<ll>> PQll; #define rep(i, a, n) for (...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<P, ll> PLL; typedef pair<P, P> PP; typedef vector<ll> VECLL; typedef vector<P> VECP; typedef priority_queue<P, VECP, greater<P>> PQP; typedef priority_queue<ll, VECLL, greater<ll>> PQll; #define rep(i, a, n) for (...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
856
#include <bits/stdc++.h> using namespace std; #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(NULL) typedef long long ll; typedef long double ld; #define rep(i, a) for (ll i = 0; i < a; i++) #defi...
#include <bits/stdc++.h> using namespace std; #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(NULL) typedef long long ll; typedef long double ld; #define rep(i, a) for (ll i = 0; i < a; i++) #defi...
[["+", 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], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22]]
1
490
// J'aime // Chemise Blanche #include <bits/stdc++.h> using namespace std; #define int long long #define ii pair<int, int> #define fi first #define sc second #define all(x) (x).begin(), (x).end() #define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl const int MOD = 1e9 + 7; void MAIN() { int n;...
// J'aime // Chemise Blanche #include <bits/stdc++.h> using namespace std; #define int long long #define ii pair<int, int> #define fi first #define sc second #define all(x) (x).begin(), (x).end() #define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl const int MOD = 1e9 + 7; void MAIN() { int n;...
[["+", 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
207
#include <bits/stdc++.h> using namespace std; int64_t Q = 1000000007; int64_t jyo(int64_t x, int64_t y) { int64_t H = y; //ここから int64_t a = 1, b = 0, c = 1; while (H > 0) { a *= 2; if (H % a != 0) { H -= a / 2; int64_t d = x; for (int j = 0; j < b; j++) { d = d * d; d =...
#include <bits/stdc++.h> using namespace std; int64_t Q = 1000000007; int64_t jyo(int64_t x, int64_t y) { int64_t H = y; //ここから int64_t a = 1, b = 0, c = 1; while (H > 0) { a *= 2; if (H % a != 0) { H -= a / 2; int64_t d = x; for (int j = 0; j < b; j++) { d = d * d; d =...
[["+", 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
223
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("Ofast") #pragma GCC optimization("unroll-loops, no-stack-protector") #pragma GCC target("avx") #pragma GCC target("avx2") #pragma GCC target("fma") #define fastio ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("Ofast") #pragma GCC optimization("unroll-loops, no-stack-protector") #pragma GCC target("avx") #pragma GCC target("avx2") #pragma GCC target("fma") #define fastio ...
[["+", 8, 9, 0, 1, 0, 11, 31, 23, 0, 24], ["+", 8, 9, 0, 1, 0, 11, 31, 23, 0, 25], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 22]]
1
260
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++) #define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) RFOR(i, 0, n) #define ALL(v) v.begin(), v.end() #define bra(first, second) '(' << fi...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++) #define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) RFOR(i, 0, n) #define ALL(v) v.begin(), v.end() #define bra(first, second) '(' << fi...
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22]]
1
318
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <queue> using namespace std; int main() { int N; cin >> N; long long int lis[200003]; long long int karizen = 0; /* for(int i=0;i<N;i++){ cin>>lis[i]; karizen+=lis[i]; karizen%=1000000007; } long long ...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <queue> using namespace std; int main() { int N; cin >> N; long long int lis[200003]; long long int karizen = 0; /* for(int i=0;i<N;i++){ cin>>lis[i]; karizen+=lis[i]; karizen%=1000000007; } long long ...
[["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
130
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #define mm(a, x) memset(a, x, sizeof(a)) #define sync \ std::ios::sync_with_stdio(false); \ std::cin.tie(0) #define ll long long u...
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #define mm(a, x) memset(a, x, sizeof(a)) #define sync \ std::ios::sync_with_stdio(false); \ std::cin.tie(0) #define ll long long u...
[["+", 12, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 12, 22]]
1
170
#include <algorithm> #include <iostream> #include <map> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; const int maxn = 5e5 + 10; const ll mod = 1e9 + 7; ll suf[maxn], a[maxn]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (in...
#include <algorithm> #include <iostream> #include <map> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; const int maxn = 5e5 + 10; const ll mod = 1e9 + 7; ll suf[maxn], a[maxn]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (in...
[["+", 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
163
#include <bits/stdc++.h> #define ll long long using namespace std; int n; const ll MOD = 1e9 + 7; ll a, sol = 0; ll arr[200005]; ll suf[200005]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; } for (int i = n - 1; i >= 0; i--) { suf[i] = suf[i + 1] + arr[i]; } for (int i = 0...
#include <bits/stdc++.h> #define ll long long using namespace std; int n; const ll MOD = 1e9 + 7; ll a, sol = 0; ll arr[200005]; ll suf[200005]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; } for (int i = n - 1; i >= 0; i--) { suf[i] = (suf[i + 1] + arr[i]) % MOD; } for (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
147
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = a; i < n; i++) using namespace std; using ll = long long; using P = pair<int, int>; const int mod = 1000000007; // const int mod = 998244353; struct mint { ll x; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } m...
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = a; i < n; i++) using namespace std; using ll = long long; using P = pair<int, int>; const int mod = 1000000007; // const int mod = 998244353; struct mint { ll x; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } m...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
468
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> P; int INF = 1e18; int mod = 1e9 + 7; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; signed main() { int N; cin >> N; vector<int> A(N); int res = 0; for (int i = 0; i < N; i++) { cin >> A[i]; A[i] %= mod;...
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> P; int INF = 1e18; int mod = 1e9 + 7; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; signed main() { int N; cin >> N; vector<int> A(N); int res = 0; for (int i = 0; i < N; i++) { cin >> A[i]; A[i] %= mod;...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
183
#include <bits/stdc++.h> using namespace std; const int maxn = 10009; const int P = 1000000007; int n; int a[maxn]; long long sum[maxn]; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); sum[i] = (sum[i - 1] + a[i]) % P; } long long ans = 0; for (int i = 2; i <= n; ++i...
#include <bits/stdc++.h> using namespace std; const int maxn = 200009; const int P = 1000000007; int n; int a[maxn]; long long sum[maxn]; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); sum[i] = (sum[i - 1] + a[i]) % P; } long long ans = 0; for (int i = 2; i <= n; ++...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
151
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define ll long long #define ld long double #define pb push_back #define FR first #define SC second #define MOD 1000000007 #define LLMN LONG_LONG_MIN #define LLMX LONG_LONG_MAX #define LDMX LDBL_MAX #define LDMN LDBL_MIN #define MAX 10...
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define ll long long #define ld long double #define pb push_back #define FR first #define SC second #define MOD 1000000007 #define LLMN LONG_LONG_MIN #define LLMX LONG_LONG_MAX #define LDMX LDBL_MAX #define LDMN LDBL_MIN #define MAX 10...
[["+", 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
238
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<ll> vi; typedef vector<bool> vb; #define mp make_pair #define pb push_back #define eb emplace_back #define sq(x) ((x) * (x)) #define fo(i, n) for (int ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<ll> vi; typedef vector<bool> vb; #define mp make_pair #define pb push_back #define eb emplace_back #define sq(x) ((x) * (x)) #define fo(i, n) for (int ...
[["+", 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
302
// Mayank Agarwal // IIIT Hyderabad #include <bits/stdc++.h> using namespace std; const long long int M = 1000000007; #define ll long long int #define ld double #define pb push_back #define mp make_pair ll power(ll x, ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p...
// Mayank Agarwal // IIIT Hyderabad #include <bits/stdc++.h> using namespace std; const long long int M = 1000000007; #define ll long long int #define ld double #define pb push_back #define mp make_pair ll power(ll x, ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p...
[["+", 31, 23, 0, 16, 12, 23, 0, 16, 17, 109], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 12, 22]]
1
354
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<ll> vll; template <typename T> inline void read(T &x) { T data = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<ll> vll; template <typename T> inline void read(T &x) { T data = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f...
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
301
#include <bits/stdc++.h> #include <unistd.h> #if __has_include(<local.h>) #include <local.h> #endif using namespace std; typedef long long int LL; typedef long long int LLint; // Faster Program #define endl "\n" // Faster Coding #define ED return #define GET(a) ...
#include <bits/stdc++.h> #include <unistd.h> #if __has_include(<local.h>) #include <local.h> #endif using namespace std; typedef long long int LL; typedef long long int LLint; // Faster Program #define endl "\n" // Faster Coding #define ED return #define GET(a) ...
[["+", 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
453
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "dump.hpp" #else #define dump(...) #define dumpv(...) #endif #define rep(i, n) for (int i = 0; i < (n); i++) #define mins(x, y) (x = min(x, y)) #define maxs(x, y) (x = max(x, y)) using ll = long long; using vi = vector<int>; using vl = vector<ll>; us...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "dump.hpp" #else #define dump(...) #define dumpv(...) #endif #define rep(i, n) for (int i = 0; i < (n); i++) #define mins(x, y) (x = min(x, y)) #define maxs(x, y) (x = max(x, y)) using ll = long long; using vi = vector<int>; using vl = vector<ll>; us...
[["+", 0, 11, 12, 23, 0, 16, 31, 74, 0, 24], ["+", 12, 23, 0, 16, 31, 74, 39, 77, 39, 78], ["+", 0, 11, 12, 23, 0, 16, 31, 74, 0, 25]]
1
641
#include <bits/stdc++.h> // Fast io #define io \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) // Class shorthands #define...
#include <bits/stdc++.h> // Fast io #define io \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) // Class shorthands #define...
[["+", 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
336
/* -------------- | / | | / | | / | * |/ | | ------ * | | | | / \ | | |\ | | | |\ | \ ...
/* -------------- | / | | / | | / | * |/ | | ------ * | | | | / \ | | |\ | | | |\ | \ ...
[["+", 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
169
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; int main() { int n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; vector<ll> sums(n + 1, 0); for (int i = 1; i <= n; ++i) sums[i] = sums[i - 1] + a[i - 1]; ll ans = 0; for (int i...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; int main() { int n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; vector<ll> sums(n + 1, 0); for (int i = 1; i <= n; ++i) sums[i] = sums[i - 1] + a[i - 1]; ll ans = 0; for (int i...
[["+", 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
174
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second #define quick \ ios::sync_with_stdio(false); \ cin.tie(0); #define time cerr << (0.1 * clock()) / CLO...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second #define quick \ ios::sync_with_stdio(false); \ cin.tie(0); #define time cerr << (0.1 * clock()) / CLO...
[["+", 0, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 12, 22], ["+", 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
182
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <list> #include <map> #include <q...
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <list> #include <map> #include <q...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 109], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
401
#define rep(i, n) for (int i = 0; i < n; i++) #include "bits/stdc++.h" using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; ll m = 1e9 + 7; cin >> n; vector<ll> a(n), sum_a(n); rep(i, n) cin >> a[i]; sum_a[0] = a[0]; rep(i, n - 1) { sum_a[i + 1] = sum_a[i] + a[i + ...
#define rep(i, n) for (int i = 0; i < n; i++) #include "bits/stdc++.h" using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; ll m = 1e9 + 7; cin >> n; vector<ll> a(n), sum_a(n); rep(i, n) cin >> a[i]; sum_a[0] = a[0]; rep(i, n - 1) { sum_a[i + 1] = sum_a[i] + a[i + ...
[["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 72], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 22]]
1
179
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int64_t> a(n); int64_t ans = 0, sum = 0; for (int i = 0; i < n; i++) { cin >> a.at(i); sum += a.at(i); } for (int i = 0; i < n - 1; i++) { sum -= a.at(i); ans = (ans + a.at(i) * sum) % 1000000007; } cou...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int64_t> a(n); int64_t ans = 0, sum = 0; for (int i = 0; i < n; i++) { cin >> a.at(i); sum += a.at(i); } for (int i = 0; i < n - 1; i++) { sum -= a.at(i); ans = (ans + sum % 1000000007 * a.at(i)) % 10000000...
[["+", 31, 23, 0, 16, 12, 16, 31, 16, 31, 22], ["+", 31, 23, 0, 16, 12, 16, 31, 16, 17, 109], ["+", 31, 23, 0, 16, 12, 16, 31, 16, 12, 13], ["+", 12, 16, 31, 23, 0, 16, 12, 16, 17, 48], ["-", 12, 16, 31, 23, 0, 16, 12, 16, 17, 48], ["-", 12, 16, 31, 23, 0, 16, 12, 16, 12, 22]]
1
124
#include <bits/stdc++.h> using namespace std; #define repd(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) #define all(x) (x).begin(), (x).end() template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chma...
#include <bits/stdc++.h> using namespace std; #define repd(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) #define all(x) (x).begin(), (x).end() template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chma...
[["+", 8, 9, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 17, 132], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 14, 8, 9, 0, 9, 0, 1, 0, 35]]
1
252
#include <bits/stdc++.h> #define ll long long int #define MOD 1000000007 #define INF 1000000000000000000 using namespace std; int main(void) { ll n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } /* ll sum = 0; ll ssum = 0; for (int i = 0; i < n; i++){ sum = (sum + ...
#include <bits/stdc++.h> #define ll long long int #define MOD 1000000007 #define INF 1000000000000000000 using namespace std; int main(void) { ll n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } /* ll sum = 0; ll ssum = 0; for (int i = 0; i < n; i++){ sum = (sum + ...
[["+", 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
166
#include <bits/stdc++.h> using namespace std; #define ll long long #define mod 1000000007 // int ans(){ // } int main() { ll n; cin >> n; ll a[n], sum = 0; for (int i = 0; i < n; i++) { cin >> a[i]; sum = sum % mod + a[i] % mod; } ll ans = 0; for (int i = 0; i < n; i++) { sum -= a[i]; ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define mod 1000000007 // int ans(){ // } int main() { ll n; cin >> n; ll a[n], sum = 0; for (int i = 0; i < n; i++) { cin >> a[i]; sum = sum + a[i]; } ll ans = 0; for (int i = 0; i < n; i++) { sum -= a[i]; ans = ans % ...
[["-", 0, 1, 0, 11, 12, 16, 31, 16, 17, 109], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 17, 109], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 12, 22]]
1
136
#pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #include <bits/stdc++.h> #define ll long long #define pb push_back #define pii pair<int, int> #define pll pair<ll, ll> #define st first #define sc second #define arr array #define yes ...
#pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #include <bits/stdc++.h> #define ll long long #define pb push_back #define pii pair<int, int> #define pll pair<ll, ll> #define st first #define sc second #define arr array #define yes ...
[["+", 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
182
#include <bits/stdc++.h> using namespace std; #define stop exit(0) #define pb push_back #define skip continue #define ll long long long long a, b, c, d = 0, e = 0, i, f = 0, g = 0, j, k = 0, l = 0, r, m, h[200001], p[200001], df[51]; string t, x, q, s; double w; vector<ll> dv[101], v, z; vector<strin...
#include <bits/stdc++.h> using namespace std; #define stop exit(0) #define pb push_back #define skip continue #define ll long long long long a, b, c, d = 0, e = 0, i, f = 0, g = 0, j, k = 0, l = 0, r, m, h[200001], p[200001], df[51]; string t, x, q, s; double w; vector<ll> dv[101], v, z; vector<strin...
[["+", 0, 11, 12, 23, 0, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 16, 12, 23, 0, 16, 17, 109], ["+", 12, 23, 0, 16, 12, 23, 0, 16, 12, 13], ["+", 0, 11, 12, 23, 0, 16, 12, 23, 0, 25]]
1
297
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef complex<ld> cd; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef pair<ld, ld> pd; typedef vector<int> vi; typedef vector<ld> vd; typedef vector<ll> vl...
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef complex<ld> cd; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef pair<ld, ld> pd; typedef vector<int> vi; typedef vector<ld> vd; typedef vector<ll> vl...
[["+", 31, 23, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 23, 0, 16, 12, 16, 12, 22], ["+", 31, 16, 12, 23, 0, 16, 31, 23, 0, 25], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 17, 72]]
1
435
#include <bits/stdc++.h> #define DEBUG if (0) #define lli long long int #define ldouble long double using namespace std; const int maxN = 2e5; int n; const lli mod = 1e9 + 7; lli a[maxN]; lli acc[maxN + 1]; int main() { while (scanf("%d", &n) != EOF) { for (int i = 0; i < n; i++) scanf("%lld", &a[i]); ...
#include <bits/stdc++.h> #define DEBUG if (0) #define lli long long int #define ldouble long double using namespace std; const int maxN = 2e5; int n; const lli mod = 1e9 + 7; lli a[maxN], acc[maxN + 1]; int main() { while (scanf("%d", &n) != EOF) { for (int i = 0; i < n; i++) scanf("%lld", &a[i]); fo...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 0, 35], ["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 78], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 0, 21], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 12, 22]]
1
191
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n, MOD = (ll)1e9 + 7; cin >> n; vector<ll> v(n); for (ll i = 0; i < n; i++) cin >> v[i]; vector<ll> suff(n); suff[n - 1] = v[n - 1]; for (ll i = n - 2; i >= 0; i--...
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n, MOD = (ll)1e9 + 7; cin >> n; vector<ll> v(n); for (ll i = 0; i < n; i++) cin >> v[i]; vector<ll> suff(n); suff[n - 1] = v[n - 1]; for (ll i = n - 2; i >= 0; i--...
[["+", 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
195
#include <bits/stdc++.h> using namespace std; using ll = long long; template <typename T> using v2 = vector<vector<T>>; template <typename T> inline v2<T> fill(int r, int c, const T &t) { return v2<T>(r, vector<T>(c, t)); } #define F first #define S second const int MOD = 1e9 + 7; // 998244353; inline int add(int a,...
#include <bits/stdc++.h> using namespace std; using ll = long long; template <typename T> using v2 = vector<vector<T>>; template <typename T> inline v2<T> fill(int r, int c, const T &t) { return v2<T>(r, vector<T>(c, t)); } #define F first #define S second const int MOD = 1e9 + 7; // 998244353; inline int add(int a,...
[["-", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 21], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
409
#include <bits/stdc++.h> #include <unordered_map> const double PI = acos(-1); using namespace std; typedef long long ll; typedef unsigned long long ull; using P = pair<ll, ll>; using V = vector<ll>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++) #define rep2(i...
#include <bits/stdc++.h> #include <unordered_map> const double PI = acos(-1); using namespace std; typedef long long ll; typedef unsigned long long ull; using P = pair<ll, ll>; using V = vector<ll>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++) #define rep2(i...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 14, 8, 9, 0, 43, 39, 344, 141, 78], ["+", 8, 9, 0, 43, 39, 344, 3, 347, 0, 18], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["+", 8, 9, 0, 43, 39, 344, 3, 347, 0, 47], ["+", 8, 9, 0, 1, 0, 16, 12, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 16, 12, 118, 119, 120]]
1
610
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define pii pair<int, int> #define F first #define S second #define ll long long #define io \ ios_base::sync_with_stdio(0); \ cin.tie(0);...
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define pii pair<int, int> #define F first #define S second #define ll long long #define io \ ios_base::sync_with_stdio(0); \ cin.tie(0);...
[["+", 0, 11, 12, 16, 31, 16, 31, 16, 17, 109], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 12, 22]]
1
169
#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; ll A[N]; rep(i, N) cin >> A[i]; ll s = 0; for (int i = 0; i < N; i++) { s += A[i]; } ll sum = 0; for (int i = 0; i < N - 1;...
#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; ll A[N]; rep(i, N) cin >> A[i]; ll s = 0; for (int i = 0; i < N; i++) { s += A[i]; } ll sum = 0; for (int i = 0; i < N - 1;...
[["+", 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, 13], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25]]
1
151
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #define inf 0x3f3f3f3f using namespace std; typedef unsigned long long ull; typedef long...
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #define inf 0x3f3f3f3f using namespace std; typedef unsigned long long ull; typedef long...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 12, 22]]
1
217
n = int(input()) a = list(map(int, input().split())) mod = 10 ** 9 + 7 res = sum([a[i] ** 2 for i in range(n)]) s = sum(a) ans = ((s ** 2 % mod) - res) // 2 ans %= mod print(ans)
n = int(input()) a = list(map(int, input().split())) mod = 10 ** 9 + 7 res = sum([a[i] ** 2 for i in range(n)]) s = sum(a) ans = (s ** 2 - res) // 2 ans %= mod print(ans)
[["-", 12, 657, 31, 23, 0, 657, 31, 23, 0, 24], ["-", 31, 23, 0, 657, 31, 23, 0, 657, 17, 109], ["-", 31, 23, 0, 657, 31, 23, 0, 657, 12, 22], ["-", 12, 657, 31, 23, 0, 657, 31, 23, 0, 25]]
5
80
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define For(i, n, k) for (int i = (n); i < (k); i++) #define ALL(a) (a).begin(), (a).end() ll ans = 0; const ll MOD = 1000000007; void Main() { int n; cin >> n; vector<ll> a(n); For(i, 0, n) cin >> a[i]; ll sm = accumulate(ALL(a), 0); sm %=...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define For(i, n, k) for (int i = (n); i < (k); i++) #define ALL(a) (a).begin(), (a).end() ll ans = 0; const ll MOD = 1000000007; void Main() { int n; cin >> n; vector<ll> a(n); For(i, 0, n) cin >> a[i]; ll sm = accumulate(ALL(a), 0LL); sm ...
[["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13]]
1
162
def findProductSum(A, n): # calculating array sum (a1 + a2 ... + an) array_sum = 0 for i in range(0, n, 1): array_sum += A[i] %MOD # calcualting square of array sum # (a1 + a2 + ... + an)^2 array_sum_square = (array_sum * array_sum )%MOD # calcualting a1^2 + a2^2 + ...
def findProductSum(A, n): # calculating array sum (a1 + a2 ... + an) array_sum = 0 for i in range(0, n, 1): array_sum += A[i] # calcualting square of array sum # (a1 + a2 + ... + an)^2 array_sum_square = (array_sum * array_sum ) # calcualting a1^2 + a2^2 + ... + an^...
[["-", 8, 196, 0, 1, 0, 677, 12, 657, 17, 109], ["-", 8, 196, 0, 1, 0, 677, 12, 657, 12, 22], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 109], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22]]
5
130
// AUTHOR - NIMISH UPADHYAY // FROM IIIT ALLAHABAD #include <bits/stdc++.h> using namespace std; #define ll long long int #define UPADHYAY \ int t; \ cin >> t; ...
// AUTHOR - NIMISH UPADHYAY // FROM IIIT ALLAHABAD #include <bits/stdc++.h> using namespace std; #define ll long long int #define UPADHYAY \ int t; \ cin >> t; ...
[["+", 12, 23, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 12, 22]]
1
161
#include <bits/stdc++.h> using namespace std; #define ll long long #define fastio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie...
#include <bits/stdc++.h> using namespace std; #define ll long long #define fastio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie...
[["+", 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
166
#include <algorithm> #include <chrono> #include <cmath> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <tuple> #include <vector> using namespace std; typedef long long ll; typedef long double ld; #define fastInp ...
#include <algorithm> #include <chrono> #include <cmath> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <tuple> #include <vector> using namespace std; typedef long long ll; typedef long double ld; #define fastInp ...
[["+", 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
257
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define int long long #define vi vector<int> #define pii pair<int, int> #define F first #define S second #define pb push_back #define rep(i, a, b) for (int i = a; i < b; i++) #define repr(i, a, b) for (int i = a - 1; i >= b; i--) #defin...
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define int long long #define vi vector<int> #define pii pair<int, int> #define F first #define S second #define pb push_back #define rep(i, a, b) for (int i = a; i < b; i++) #define repr(i, a, b) for (int i = a - 1; i >= b; i--) #defin...
[["+", 0, 16, 31, 23, 0, 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
183
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; vector<long long> A(N), B(N); for (long long i = 0; i < N; i++) { cin >> A.at(i); } B.at(0) = A.at(0); for (long long i = 1; i < N; i++) { B.at(i) = B.at(i - 1) + A.at(i); } long long ans = 0; for (long long i...
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; vector<long long> A(N), B(N); for (long long i = 0; i < N; i++) { cin >> A.at(i); } B.at(0) = A.at(0); for (long long i = 1; i < N; i++) { B.at(i) = B.at(i - 1) + A.at(i); } long long ans = 0; for (long long i...
[["+", 12, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 31, 23, 0, 16, 12, 2, 3, 4, 0, 25], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 109], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 13]]
1
177
#include <bits/stdc++.h> using namespace std; using lint = long long int; using P = pair<int, int>; using PL = pair<lint, lint>; #define FOR(i, begin, end) \ for (int i = (begin), i##_end_ = (end); i < i##_end_; i++) #define IFOR(i, begin, end) ...
#include <bits/stdc++.h> using namespace std; using lint = long long int; using P = pair<int, int>; using PL = pair<lint, lint>; #define FOR(i, begin, end) \ for (int i = (begin), i##_end_ = (end); i < i##_end_; i++) #define IFOR(i, begin, end) ...
[["+", 12, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 12, 22]]
1
290
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <vector> using namespace std; #define ll long long #define il inline const int maxn = 200010; const ll mod = 1e9 + 7; ll a[maxn], s[maxn]; int n; ll ans = 0; int main() { scanf("%d", &n); for (in...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <vector> using namespace std; #define ll long long #define il inline const int maxn = 200010; const ll mod = 1e9 + 7; ll a[maxn], s[maxn]; int n; ll ans = 0; int main() { scanf("%d", &n); for (in...
[["+", 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
168
#include <bits/stdc++.h> #define int long long #define double long double #define ff first #define ss second #define endl '\n' #define ii pair<int, int> #define mp make_pair #define mt make_tuple #define DESYNC \ ios_base::sync_with_stdio(false); ...
#include <bits/stdc++.h> #define int long long #define double long double #define ff first #define ss second #define endl '\n' #define ii pair<int, int> #define mp make_pair #define mt make_tuple #define DESYNC \ ios_base::sync_with_stdio(false); ...
[["-", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25]]
1
338
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ll long long const long long MOD = 1000000007; int main() { ll n; cin >> n; vector<ll> a(n); ll ans = 0, t = 0, M = 7 + 1e9; rep(i, n) { cin >> a.at(i); t += a.at(i); t %= M; } rep(i, ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ll long long const long long MOD = 1000000007; int main() { ll n; cin >> n; vector<ll> a(n); ll ans = 0, t = 0, M = 7 + 1e9; rep(i, n) { cin >> a.at(i); t += a.at(i); t %= M; } rep(i, ...
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22]]
1
133
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author houghstc */ #include <fstream> #include <iostream> #include <algorithm> #include <climits> #include <cstring> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #inclu...
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author houghstc */ #include <fstream> #include <iostream> #include <algorithm> #include <climits> #include <cstring> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #inclu...
[["+", 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
214
#ifdef LOCAL //#define _GLIBCXX_DEBUG #endif //#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<int, int> Pi; typedef vector<ll> Vec...
#ifdef LOCAL //#define _GLIBCXX_DEBUG #endif //#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<int, int> Pi; typedef vector<ll> Vec...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
1,300
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; typedef long long ll; const int mod = 1e9 + 7; int a[200005]; ll suf[200005]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; suf[n - 1] = a[n - 1]; for (int i = n - ...
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; typedef long long ll; const int mod = 1e9 + 7; int a[200005]; ll suf[200005]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; suf[n - 1] = a[n - 1]; for (int i = n - ...
[["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46], ["+", 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
170
#include <iostream> using namespace std; const int N = 2e5 + 10; int p[N], s[N]; int find(int x) { return x == p[x] ? x : p[x] = find(p[x]); } int main() { int n, m; scanf("%d%d", &n, &m); int u, v; for (int i = 1; i <= n; i++) { p[i] = i; s[i] = 1; } int res = 0; for (int i = 0; i < m; i++) { ...
#include <iostream> using namespace std; const int N = 2e5 + 10; int p[N], s[N]; int find(int x) { return x == p[x] ? x : p[x] = find(p[x]); } int main() { int n, m; scanf("%d%d", &n, &m); int u, v; for (int i = 1; i <= n; i++) { p[i] = i; s[i] = 1; } int res = 0; for (int i = 0; i < m; i++) { ...
[["+", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 21], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 25]]
1
208
#include <bits/stdc++.h> using namespace std; #define debug(x) cout << (#x) << " is " << x << endl; #define Q \ int t; \ scanf("%d", &t); ...
#include <bits/stdc++.h> using namespace std; #define debug(x) cout << (#x) << " is " << x << endl; #define Q \ int t; \ scanf("%d", &t); ...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 109], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
159
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace std; using namespace __gnu_pbds; template <class T> ostream &operator<<(ostream &os, vector<T> V) { os << "[ "; for (auto v : V) o...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace std; using namespace __gnu_pbds; template <class T> ostream &operator<<(ostream &os, vector<T> V) { os << "[ "; for (auto v : V) o...
[["+", 3, 4, 0, 2, 3, 4, 0, 16, 17, 109], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 12, 22]]
1
945
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; using ll = long long; #define rep(i, n) for (ll i = 0; i < ll(n); i++) #define YESNO(T) \ if (T) { \ cout << "YES"...
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; using ll = long long; #define rep(i, n) for (ll i = 0; i < ll(n); i++) #define YESNO(T) \ if (T) { \ cout << "YES"...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]]
1
357
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define mii make_pair<int, int> #define mll make_pair<ll, ll> #define pii pair<int, int> #define pll pair<ll, ll> #define vi vector<int> #define vvi vector<vector<int>> #define vl vector<ll> #define vvl vector<vector<ll>>...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define mii make_pair<int, int> #define mll make_pair<ll, ll> #define pii pair<int, int> #define pll pair<ll, ll> #define vi vector<int> #define vvi vector<vector<int>> #define vl vector<ll> #define vvl vector<vector<ll>>...
[["+", 0, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 12, 22]]
1
244
#include <bits/stdc++.h> using namespace std; typedef long long ll; template <class T> ll size(const T &x) { return x.size(); } #define rep(i, a, b) for (ll i = (a); i < (b); ++i) #define iter(it, c) for (auto it = (c).begin(); it != (c).end(); ++it) #define pb push_back #define fs first #define sc second #define MOD 1...
#include <bits/stdc++.h> using namespace std; typedef long long ll; template <class T> ll size(const T &x) { return x.size(); } #define rep(i, a, b) for (ll i = (a); i < (b); ++i) #define iter(it, c) for (auto it = (c).begin(); it != (c).end(); ++it) #define pb push_back #define fs first #define sc second #define MOD 1...
[["+", 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
294
#include <bits/stdc++.h> using namespace std; struct UnionFindTree { vector<int> size, parents; UnionFindTree() {} UnionFindTree(int n) { size.resize(n, 0); parents.resize(n, 0); for (int i = 0; i < n; i++) { makeTree(i); } } void makeTree(int x) { parents[x] = x; size[x] = 1;...
#include <bits/stdc++.h> using namespace std; struct UnionFindTree { vector<int> size, parents; UnionFindTree() {} UnionFindTree(int n) { size.resize(n, 0); parents.resize(n, 0); for (int i = 0; i < n; i++) { makeTree(i); } } void makeTree(int x) { parents[x] = x; size[x] = 1;...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
421
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <vector> using namespace std; typedef long long ll; const ll modint = 1000000007; int main() { int n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } ll sum = 0; for (int i = 0...
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <vector> using namespace std; typedef long long ll; const ll modint = 1000000007; int main() { int n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } ll sum = 0; for (int i = 0...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 132], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
158
#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>; vector<int> par; vector<int> siz; int maxi = 0; int root(int x) { if (par.at(x) == -1) return x; return par.at(x) = root(par.at(x)); } int size(int x) { return siz.at(...
#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>; vector<int> par; vector<int> siz; int maxi = 1; int root(int x) { if (par.at(x) == -1) return x; return par.at(x) = root(par.at(x)); } int size(int x) { return siz.at(...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
264
#include <bits/stdc++.h> using namespace std; int64_t MOD = 1000000007; double PI = 3.141592653589793; int main() { int64_t N, sum = 0; cin >> N; vector<int64_t> list(N); for (int i = 0; i < N; i++) { cin >> list[i]; sum = (sum + list[i]) % MOD; } int ans = (sum * sum) % MOD; for (int i = 0; i ...
#include <bits/stdc++.h> using namespace std; int64_t MOD = 1000000007; double PI = 3.141592653589793; int main() { int64_t N, sum = 0; cin >> N; vector<int64_t> list(N); for (int i = 0; i < N; i++) { cin >> list[i]; sum = (sum + list[i]) % MOD; } int ans = (sum * sum) % MOD; for (int i = 0; i ...
[["-", 75, 76, 0, 1, 0, 16, 12, 16, 17, 109], ["+", 75, 76, 0, 1, 0, 16, 12, 16, 17, 85]]
1
157
n = int(input()) a = [int(i) for i in input().split()] sum1 = 0 sum2 = 0 for _ in a: sum1 += _ sum2 += (_*_) sum1 = (sum1 * sum1) print((sum1 - sum2)//2)
n = int(input()) a = [int(i) for i in input().split()] sum1 = 0 sum2 = 0 for _ in a: sum1 += _ sum2 += (_*_) sum1 = (sum1 * sum1) print(((sum1 - sum2)//2)%1000000007)
[["+", 0, 657, 31, 23, 0, 657, 31, 23, 0, 24], ["+", 0, 652, 3, 4, 0, 657, 31, 23, 0, 25], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 109], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
64
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; using ll = long long; using vec = vector<ll>; using vect = vector<double>; using Graph = vector<vector<ll>>; #define loop(i, n) for (ll i = 0; i < n; i++) #define Loop(i, m, n) for (ll i = m; i < n; i++) #define pool(i, n) for (ll i = n; i >= 0; i--) ...
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; using ll = long long; using vec = vector<ll>; using vect = vector<double>; using Graph = vector<vector<ll>>; #define loop(i, n) for (ll i = 0; i < n; i++) #define Loop(i, m, n) for (ll i = m; i < n; i++) #define pool(i, n) for (ll i = n; i >= 0; i--) ...
[["+", 51, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["+", 51, 16, 31, 23, 0, 16, 12, 23, 0, 25]]
1
1,034
N = int(input()) Alist = list(map(int, input().split())) MOD = 1000000007 Alist = Alist[::-1] mod = 0 ans = 0 for n in range(N-1): mod += (Alist[n]%MOD) mod = mod % MOD ans += (Alist[n+1] * mod)%MOD print(ans)
N = int(input()) Alist = list(map(int, input().split())) MOD = 1000000007 Alist = Alist[::-1] mod = 0 ans = 0 for n in range(N-1): mod += (Alist[n]%MOD) mod = mod % MOD ans += (Alist[n+1] * mod)%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
86
#include <bits/stdc++.h> using namespace std; constexpr int mod = 1e9 + 7; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<long long> pref(n); for (int i = 0; i < n; i++) { if (i == 0) pref[i] = a[i]; else pref[i] = pref[i - 1] + a[i]; ...
#include <bits/stdc++.h> using namespace std; constexpr int mod = 1e9 + 7; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<long long> pref(n); for (int i = 0; i < n; i++) { if (i == 0) pref[i] = a[i]; else pref[i] = pref[i - 1] + a[i]; ...
[["+", 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
174
#include <bits/stdc++.h> using namespace std; #define set_precision(ans, l) cout << fixed << setprecision(l) << ans; #define rep(i, a, b) for (int i = a; i < b; i++) #define repb(i, a, b) for (int i = a; i >= b; i--) #define vi vector<int> #define vl vector<long long int> #define Vi vector<vector<int>> #define vpi vec...
#include <bits/stdc++.h> using namespace std; #define set_precision(ans, l) cout << fixed << setprecision(l) << ans; #define rep(i, a, b) for (int i = a; i < b; i++) #define repb(i, a, b) for (int i = a; i >= b; i--) #define vi vector<int> #define vl vector<long long int> #define Vi vector<vector<int>> #define vpi vec...
[["+", 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
433
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> P; typedef pair<int, int> Pi; #define rep(i, n) for (ll i = 0; i < n; i++) #define FOR(i, a, b) for (ll i = a; i < b; i++) #define fi first #define se second #define endl "\n" template <typename T> inline b...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> P; typedef pair<int, int> Pi; #define rep(i, n) for (ll i = 0; i < n; i++) #define FOR(i, a, b) for (ll i = a; i < b; i++) #define fi first #define se second #define endl "\n" template <typename T> inline b...
[["+", 0, 1, 0, 11, 12, 16, 31, 2, 63, 22], ["+", 0, 11, 12, 16, 31, 2, 3, 4, 0, 24], ["+", 0, 11, 12, 16, 31, 2, 3, 4, 0, 25], ["+", 0, 1, 0, 11, 12, 16, 12, 2, 63, 22], ["+", 0, 11, 12, 16, 12, 2, 3, 4, 0, 24], ["+", 12, 16, 12, 2, 3, 4, 0, 23, 0, 25]]
1
1,270
#pragma GCC target("avx2") #pragma GCC optimize("03") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; typedef unsigned long long ull; #define endl "\n" #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define rep(i, n) for (int i = 0;...
#pragma GCC target("avx2") #pragma GCC optimize("03") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; typedef unsigned long long ull; #define endl "\n" #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define rep(i, n) for (int i = 0;...
[["+", 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
962
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline n = int(input()) a = list( map(int, input().split())) p = 10**9+7 ans = 0 suma = sum(a)%p sumaa1 = (suma**2//2)%p sumaa2 = 0 for i in range(n): sumaa2 += (a[i]**2) sumaa2 = sumaa2//2 ans = (sumaa1-sumaa2)%p print(ans)
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline n = int(input()) a = list( map(int, input().split())) p = 10**9+7 ans = 0 suma = sum(a) sumaa1 = (suma**2//2)%p sumaa2 = 0 for i in range(n): sumaa2 += (a[i]**2) sumaa2 = sumaa2//2 ans = (sumaa1-sumaa2)%p print(ans)
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 109], ["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 22]]
5
110
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> ...
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> ...
[["+", 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
392
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #define _USE_MATH_DEFINES #include <cassert> #include <complex> #include <functional> #include <math.h> using namespace std; #define rep(i, x) for (ll i = 0; i ...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #define _USE_MATH_DEFINES #include <cassert> #include <complex> #include <functional> #include <math.h> using namespace std; #define rep(i, x) for (ll i = 0; i ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
766
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); int n = in.nextInt(); int m = in.nextInt(); if (m == 0) { ...
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); int n = in.nextInt(); int m = in.nextInt(); if (m == 0) { ...
[["-", 64, 196, 0, 1, 0, 492, 3, 4, 0, 499], ["+", 64, 196, 0, 1, 0, 492, 3, 4, 0, 499]]
3
460
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef vector<pll> vpll; typedef vector<vll> vvll; #define all(x) (x).begin(), (x).end() #define fi first #define se second int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef vector<pll> vpll; typedef vector<vll> vvll; #define all(x) (x).begin(), (x).end() #define fi first #define se second int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int ...
[["+", 0, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 109], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22]]
1
237
from __future__ import print_function from functools import reduce from operator import mul from collections import Counter from collections import deque from itertools import accumulate from queue import Queue from queue import PriorityQueue as pq from heapq import heapreplace from heapq import heapify from heapq imp...
from __future__ import print_function from functools import reduce from operator import mul from collections import Counter from collections import deque from itertools import accumulate from queue import Queue from queue import PriorityQueue as pq from heapq import heapreplace from heapq import heapify from heapq imp...
[["-", 0, 14, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 12, 612]]
5
744
import queue N, M = map(int, input().split()) l = [[] for i in range(N)] for i in range(M): a, b = map(int, input().split()) l[a - 1].append(b - 1) l[b - 1].append(a - 1) c = [0] * N ans = 0 q = queue.Queue() for j in range(N): q.put(l[j]) u = 0 while not q.empty(): ...
import queue N, M = map(int, input().split()) l = [[] for i in range(N)] for i in range(M): a, b = map(int, input().split()) l[a - 1].append(b - 1) l[b - 1].append(a - 1) c = [0] * N ans = 1 q = queue.Queue() for j in range(N): q.put(l[j]) u = 0 while not q.empty(): ...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]]
5
175
#include <bits/stdc++.h> //#include <atcoder/all> using ll = long long; using namespace std; // using namespace atcoder; int par[200000], siz[200000]; int find(int a) { if (par[a] == a) return a; return par[a] = find(par[a]); } void unite(int a, int b) { a = find(a); b = find(b); if (a == b) return...
#include <bits/stdc++.h> //#include <atcoder/all> using ll = long long; using namespace std; // using namespace atcoder; int par[200000], siz[200000]; int find(int a) { if (par[a] == a) return a; return par[a] = find(par[a]); } void unite(int a, int b) { a = find(a); b = find(b); if (a == b) return...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 3, 4, 0, 69, 341, 342, 0, 69, 28, 22], ["+", 0, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 0, 69, 341, 342, 0, 69, 341, 342, 0, 73]]
1
222
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; ...
[["+", 0, 235, 8, 498, 0, 124, 49, 200, 0, 32], ["+", 0, 235, 8, 498, 0, 124, 49, 200, 51, 499]]
3
921
import sys sys.setrecursionlimit(10 ** 9) N, M = map(int, input().split()) tree = [-1] * N def root(x): if tree[x] < 0: return x else: tree[x] = root(tree[x]) return tree[x] def unite(x, y): rx, ry = root(x), root(y) if rx == ry: return tree[rx] += tree[ry] tree[y] = rx def size(x): retur...
import sys sys.setrecursionlimit(10 ** 9) N, M = map(int, input().split()) tree = [-1] * N def root(x): if tree[x] < 0: return x else: tree[x] = root(tree[x]) return tree[x] def unite(x, y): rx, ry = root(x), root(y) if rx == ry: return tree[rx] += tree[ry] tree[ry] = rx def size(x): retu...
[["-", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22]]
5
177
#include <bits/stdc++.h> using namespace std; int find_par(vector<int> &par, int ver) { if (par[ver] == ver) return ver; return par[ver] = find_par(par, par[ver]); } void make(vector<int> &par, int x, int y) { int px = find_par(par, x); int py = find_par(par, y); par[x] = py; } int main() { int n, m; ...
#include <bits/stdc++.h> using namespace std; int find_par(vector<int> &par, int ver) { if (par[ver] == ver) return ver; return par[ver] = find_par(par, par[ver]); } void make(vector<int> &par, int x, int y) { int px = find_par(par, x); int py = find_par(par, y); par[px] = py; } int main() { int n, m;...
[["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]]
1
236
from copy import deepcopy N, M = map(int, input().split()) pairs = [0] * M for i in range(M): pairs[i] = list(map(int, input().split())) # N = 5 # pairs = [[1,2], [3,4], [5,1]] print(pairs) class UnionFind: def __init__(self, N): self.r = [-1] * N def root(self, x): if self.r[x] < 0: ...
from copy import deepcopy N, M = map(int, input().split()) pairs = [0] * M for i in range(M): pairs[i] = list(map(int, input().split())) # N = 5 # pairs = [[1,2], [3,4], [5,1]] class UnionFind: def __init__(self, N): self.r = [-1] * N def root(self, x): if self.r[x] < 0: r...
[["-", 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
289
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[] rank = new int[n]; int[] parent = new int[n]; for (int i = 0; i < n; i++) { rank[i] = 1; parent[i] = i; } ...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[] rank = new int[n + 1]; int[] parent = new int[n + 1]; for (int i = 0; i <= n; i++) { rank[i] = 1; parent[i] = i;...
[["+", 49, 200, 51, 227, 497, 505, 0, 16, 17, 72], ["+", 49, 200, 51, 227, 497, 505, 0, 16, 12, 499], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
3
332
#include <stdbool.h> #include <stdio.h> #define MAX_N 200200 int par[MAX_N], rank[MAX_N]; void init(int n) { for (int i = 0; i < n; i++) { par[i] = i; rank[i] = 0; } } int root(int x) { return par[x] == x ? x : (par[x] = root(par[x])); } bool same(int x, int y) { return root(x) == root(y); } void unite(int ...
#include <stdbool.h> #include <stdio.h> #define MAX_N 200200 int par[MAX_N], rank[MAX_N]; void init(int n) { for (int i = 0; i < n; i++) { par[i] = i; rank[i] = 0; } } int root(int x) { return par[x] == x ? x : (par[x] = root(par[x])); } bool same(int x, int y) { return root(x) == root(y); } void unite(int ...
[["-", 0, 1, 0, 27, 28, 69, 71, 69, 28, 22], ["-", 0, 1, 0, 27, 28, 69, 71, 69, 0, 70], ["+", 0, 1, 0, 27, 28, 69, 71, 2, 63, 22], ["+", 0, 27, 28, 69, 71, 2, 3, 4, 0, 24], ["-", 0, 1, 0, 27, 28, 69, 71, 69, 0, 73], ["+", 0, 27, 28, 69, 71, 2, 3, 4, 0, 25]]
0
332
#include <algorithm> #include <iostream> #include <vector> using namespace std; int getParent(vector<int> &parent, int x) { if (parent[x] < 0) return x; return parent[x] = getParent(parent, parent[x]); } void uniteParent(vector<int> &parent, int a, int b) { a = getParent(parent, a); b = getParent(parent,...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int getParent(vector<int> &parent, int x) { if (parent[x] < 0) return x; return parent[x] = getParent(parent, parent[x]); } void uniteParent(vector<int> &parent, int a, int b) { a = getParent(parent, a); b = getParent(parent,...
[["-", 0, 91, 28, 69, 341, 342, 0, 69, 28, 22], ["-", 28, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["-", 28, 69, 341, 342, 0, 69, 341, 342, 0, 73]]
1
240
#include <bits/stdc++.h> using namespace std; #define ll long long int #define mod 1000000007 vector<ll> v[200005]; bool visited[200005] = {false}; ll dfs(ll p) { queue<ll> q; q.push(p); visited[p] = true; ll count = 0; while (!q.empty()) { ll i; ll p1 = q.front(); q.pop(); for (i = 0; i < v[...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define mod 1000000007 vector<ll> v[200005]; bool visited[200005] = {false}; ll dfs(ll p) { queue<ll> q; q.push(p); visited[p] = true; ll count = 0; while (!q.empty()) { ll i; ll p1 = q.front(); q.pop(); for (i = 0; i < v[...
[["-", 12, 2, 63, 118, 28, 69, 341, 342, 0, 22], ["+", 12, 2, 63, 118, 28, 69, 341, 342, 0, 22], ["-", 341, 342, 0, 69, 28, 69, 341, 342, 0, 22], ["+", 341, 342, 0, 69, 28, 69, 341, 342, 0, 22], ["-", 3, 4, 0, 69, 28, 69, 341, 342, 0, 22], ["+", 3, 4, 0, 69, 28, 69, 341, 342, 0, 22]]
1
313
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> using namespace std; class UnionFind { private: unsigned int n_node; std::vector<uint32_t> parent, rank; public: UnionFind(unsigned ...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> using namespace std; class UnionFind { private: unsigned int n_node; std::vector<uint32_t> parent, rank; public: UnionFind(unsigned ...
[["-", 0, 14, 8, 9, 0, 37, 0, 69, 28, 22], ["-", 8, 9, 0, 37, 0, 69, 341, 342, 0, 70], ["+", 0, 14, 8, 9, 0, 37, 0, 2, 63, 22], ["+", 8, 9, 0, 37, 0, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 37, 0, 69, 341, 342, 0, 73], ["+", 8, 9, 0, 37, 0, 2, 3, 4, 0, 25]]
1
402
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef complex<double> cp; #define debug(a) cout << #a << ":" << a << endl; #define fr freopen("in.txt", "r", stdin); #define Fill(x, a) memset(x, a, sizeof(x)) #define cpy(a, b) memcpy(a, b, sizeof(a)) const double PI = aco...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef complex<double> cp; #define debug(a) cout << #a << ":" << a << endl; #define fr freopen("in.txt", "r", stdin); #define Fill(x, a) memset(x, a, sizeof(x)) #define cpy(a, b) memcpy(a, b, sizeof(a)) const double PI = aco...
[["-", 0, 27, 28, 69, 341, 342, 0, 69, 28, 22], ["-", 28, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 0, 27, 28, 69, 341, 342, 0, 2, 63, 22], ["+", 28, 69, 341, 342, 0, 2, 3, 4, 0, 24], ["-", 28, 69, 341, 342, 0, 69, 341, 342, 0, 73], ["+", 28, 69, 341, 342, 0, 2, 3, 4, 0, 25]]
1
329
import typing class DSU: ''' Implement (union by size) + (path compression) Reference: Zvi Galil and Giuseppe F. Italiano, Data structures and algorithms for disjoint set union problems ''' def __init__(self, n: int = 0): self._n = n self.parent_or_size = [-1] * n def...
import typing class DSU: ''' Implement (union by size) + (path compression) Reference: Zvi Galil and Giuseppe F. Italiano, Data structures and algorithms for disjoint set union problems ''' def __init__(self, n: int = 0): self._n = n self.parent_or_size = [-1] * n def...
[["-", 8, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 8, 196, 0, 1, 0, 652, 63, 319, 319, 22]]
5
446
#pragma GCC optimize("O2") #pragma GCC target("avx2") //#include<bits/stdc++.h> #include <algorithm> #include <cstdio> #include <cstring> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #defin...
#pragma GCC optimize("O2") #pragma GCC target("avx2") //#include<bits/stdc++.h> #include <algorithm> #include <cstdio> #include <cstring> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #defin...
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 123, 0, 14, 8, 9, 0, 1, 0, 35]]
1
522
from collections import deque N, M = map(int, input().split()) friends = [[] for _ in range(N+1)] for __ in range(M): a, b = map(int, input().split()) friends[a].append(b) friends[b].append(a) checked = [0 for ___ in range(N+1)] answer = 0 for i in range(1, N+1): friend = deque(friends[i]) cnt = 0 while(le...
from collections import deque N, M = map(int, input().split()) friends = [[] for _ in range(N+1)] for __ in range(M): a, b = map(int, input().split()) friends[a].append(b) friends[b].append(a) checked = [0 for ___ in range(N+1)] answer = 1 for i in range(1, N+1): friend = deque(friends[i]) cnt = 0 while(le...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]]
5
181
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<vector<int>> V(N + 1, vector<int>(0)); for (int i = 0; i < M; i++) { int A, B; cin >> A >> B; V[A].push_back(B); V[B].push_back(A); } // BFSの準備 vector<bool> visited(N, false); queue<int> que; ...
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<vector<int>> V(N + 1, vector<int>(0)); for (int i = 0; i < M; i++) { int A, B; cin >> A >> B; V[A].push_back(B); V[B].push_back(A); } // BFSの準備 vector<bool> visited(N + 1, false); queue<int> que...
[["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
241
#include <algorithm> #include <cstring> #include <iostream> #include <queue> #include <vector> #define el '\n' #define FAIO ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr) using namespace std; int N, M; vector<int> v[200001]; queue<int> q; bool visited[200001]; int main() { FAIO; cin >> N >> M...
#include <algorithm> #include <cstring> #include <iostream> #include <queue> #include <vector> #define el '\n' #define FAIO ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr) using namespace std; int N, M; vector<int> v[200001]; queue<int> q; bool visited[200001]; int main() { FAIO; cin >> N >> M...
[["-", 8, 9, 0, 338, 12, 69, 341, 342, 0, 22], ["+", 8, 9, 0, 338, 12, 69, 341, 342, 0, 22]]
1
230
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; using P = pair<int, int>; struct UnionFind { vector<int> uni; UnionFind(int n) : uni(n, -1) {} int root(int a) { if (uni[a] < 0) return a; return uni[a] = root(uni[a]); } bool c...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; using P = pair<int, int>; struct UnionFind { vector<int> uni; UnionFind(int n) : uni(n, -1) {} int root(int a) { if (uni[a] < 0) return a; return uni[a] = root(uni[a]); } bool c...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]]
1
320
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <new> #include <queue> #include <random> #include <se...
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <new> #include <queue> #include <random> #include <se...
[["-", 8, 9, 0, 338, 12, 69, 341, 342, 0, 22], ["+", 8, 9, 0, 338, 12, 69, 341, 342, 0, 22]]
1
328
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<vector<int>> number(N, vector<int>(0)); vector<bool> seen(N, false); vector<int> A(M); vector<int> B(M); for (int i = 0; i < M; i++) { cin >> A[i] >> B[i]; } for (int i = 0; i < M; i++) { number[A[i] ...
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<vector<int>> number(N, vector<int>(0)); vector<bool> seen(N, false); vector<int> A(M); vector<int> B(M); for (int i = 0; i < M; i++) { cin >> A[i] >> B[i]; } for (int i = 0; i < M; i++) { number[A[i] ...
[["-", 8, 9, 0, 338, 12, 69, 341, 342, 0, 22], ["+", 8, 9, 0, 338, 12, 69, 341, 342, 0, 22]]
1
291
#include <bits/stdc++.h> //--------------------------------------------------------------- #define ll long long #define mod 1000000007 #define MAX 100005 #define PI 3.141592653589793238 // shortcut keys #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define fr(i, a, b) for (int i = a; i <...
#include <bits/stdc++.h> //--------------------------------------------------------------- #define ll long long #define mod 1000000007 #define MAX 100005 #define PI 3.141592653589793238 // shortcut keys #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define fr(i, a, b) for (int i = a; i <...
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
229
n, m = map(int, input().split()) root = list(range(n + 1)) # from collections import defaultdict # d = defaultdict(set) cnt = [1] * (n + 1) def find(i): if i == root[i]: return i root[i] = find(root[i]) return root[i] def union(u, v): fu, fv = find(u), find(v) if fu == fv: ret...
n, m = map(int, input().split()) root = list(range(n + 1)) # from collections import defaultdict # d = defaultdict(set) cnt = [1] * (n + 1) def find(i): if i == root[i]: return i root[i] = find(root[i]) return root[i] def union(u, v): fu, fv = find(u), find(v) if fu == fv: ret...
[["-", 0, 662, 31, 206, 206, 652, 3, 4, 0, 22], ["+", 0, 662, 31, 206, 206, 652, 3, 4, 0, 22], ["-", 0, 677, 12, 206, 206, 652, 3, 4, 0, 22], ["+", 0, 677, 12, 206, 206, 652, 3, 4, 0, 22]]
5
173