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; int main() { int l; cin >> l; long double x = l / 3; long double vol = (x * x * x); cout << fixed << setprecision(12) << vol; }
#include <bits/stdc++.h> using namespace std; int main() { int l; cin >> l; long double x = (double)l / 3; long double vol = (x * x * x); cout << fixed << setprecision(12) << vol; }
[["+", 0, 43, 49, 50, 51, 16, 31, 74, 0, 24], ["+", 49, 50, 51, 16, 31, 74, 39, 77, 39, 40], ["+", 0, 43, 49, 50, 51, 16, 31, 74, 0, 25]]
1
50
#include "algorithm" #include "cmath" #include "cstdio" #include "cstring" #include "iostream" #include "map" #include "queue" #include "set" #include "vector" using namespace std; #define MAXN 200016 //#define int long long #define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i) #define per(i, a, b) for...
#include "algorithm" #include "cmath" #include "cstdio" #include "cstring" #include "iostream" #include "map" #include "queue" #include "set" #include "vector" using namespace std; #define MAXN 200016 //#define int long long #define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i) #define per(i, a, b) for...
[["+", 0, 43, 49, 50, 51, 16, 31, 16, 31, 13], ["+", 0, 43, 49, 50, 51, 16, 31, 16, 17, 48]]
1
191
#include <bits/stdc++.h> using namespace std; int main() { int L; cin >> L; cout << fixed << setprecision(12); cout << pow(L / 3, 3) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int L; cin >> L; cout << fixed << setprecision(12); cout << pow((double)L / 3, 3) << endl; }
[["+", 12, 2, 3, 4, 0, 16, 31, 74, 0, 24], ["+", 3, 4, 0, 16, 31, 74, 39, 77, 39, 40], ["+", 12, 2, 3, 4, 0, 16, 31, 74, 0, 25]]
1
41
#include <bits/stdc++.h> #define CYES \ cout << "Yes" \ << "\n"; #define CNO \ cout << "No" ...
#include <bits/stdc++.h> #define CYES \ cout << "Yes" \ << "\n"; #define CNO \ cout << "No" ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
1
154
import java.math.BigDecimal; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int L = sc.nextInt(); double tmp = L / 3; System.out.println(BigDecimal.valueOf(Math.pow(tmp, 3)).toPlainString()); } }
import java.math.BigDecimal; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int L = sc.nextInt(); double tmp = (double)L / 3; System.out.println(BigDecimal.valueOf(Math.pow(tmp, 3)).toPlainString()); } }
[["+", 0, 503, 49, 200, 51, 16, 31, 74, 0, 24], ["+", 49, 200, 51, 16, 31, 74, 39, 511, 0, 512], ["+", 0, 503, 49, 200, 51, 16, 31, 74, 0, 25]]
3
83
#include <bits/stdc++.h> using namespace std; int main() { int L; cin >> L; double x = double(L) / 3; cout << x * x * x << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int L; cin >> L; double x = double(L) / 3; cout << setprecision(15) << x * x * x << endl; return 0; }
[["+", 0, 16, 31, 16, 31, 16, 12, 2, 63, 22], ["+", 31, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 31, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 31, 16, 31, 16, 12, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
42
#include <bits/stdc++.h> using namespace std; int main() { int l; scanf("%d", &l); double ans = l / 3; printf("%lf\n", ans * ans * ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int l; scanf("%d", &l); double ans = l / 3.0; printf("%lf\n", ans * ans * ans); return 0; }
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
1
49
//#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/...
//#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/...
[["+", 0, 16, 31, 16, 31, 16, 12, 2, 63, 22], ["+", 31, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 31, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 31, 16, 31, 16, 12, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
1,510
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; scanf("%d", &n); double t = n / 3; printf("%.6lf\n", t * t * t); return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { double n; scanf("%lf", &n); double t = n / 3.0; printf("%.6lf\n", t * t * t); return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
1
54
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define rep(i, n, m) for (int i = (n); i < (m); i++) #define rep_d(i, n, m) for (int i = (n)-1; i >= (m); i--) #define sort_asc(X) sort((X).begin(), (X).end()) #define sort_desc(X) sort((X).begin(), (X).end(), greater<>()) #define endl "\n" templ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define rep(i, n, m) for (int i = (n); i < (m); i++) #define rep_d(i, n, m) for (int i = (n)-1; i >= (m); i--) #define sort_asc(X) sort((X).begin(), (X).end()) #define sort_desc(X) sort((X).begin(), (X).end(), greater<>()) #define endl "\n" templ...
[["+", 0, 43, 49, 50, 51, 16, 31, 74, 0, 24], ["+", 49, 50, 51, 16, 31, 74, 39, 77, 39, 40], ["+", 0, 43, 49, 50, 51, 16, 31, 74, 0, 25]]
1
440
#include <bits/stdc++.h> using namespace std; #define pi acos(-1) #define N 1000000007 #define ll long long #define ull unsigned long long #define mem(a) memset(a, 0, sizeof(a)) int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int l; cin >> l; double a = l / 3; double b = a; double c = l -...
#include <bits/stdc++.h> using namespace std; #define pi acos(-1) #define N 1000000007 #define ll long long #define ull unsigned long long #define mem(a) memset(a, 0, sizeof(a)) int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int l; cin >> l; double a = l / 3.0; double b = a; double c = l...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
1
97
#include <bits/stdc++.h> using namespace std; // ----------------------R00TDADA------------------------------ #define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++) #define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--) #define all(a) (a).begin(), (a).end() #define ff first #define ss second #define pp...
#include <bits/stdc++.h> using namespace std; // ----------------------R00TDADA------------------------------ #define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++) #define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--) #define all(a) (a).begin(), (a).end() #define ff first #define ss second #define pp...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
1
174
#include <bits/stdc++.h> #define M_PI 3.14159265358979323846 // pi using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<ll> VI; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> t3; typedef tuple<ll, ll, ll, ll> t4; #define rep(a, n) for (ll a = 0; a < n; a++) #define repi(a, b, ...
#include <bits/stdc++.h> #define M_PI 3.14159265358979323846 // pi using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<ll> VI; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> t3; typedef tuple<ll, ll, ll, ll> t4; #define rep(a, n) for (ll a = 0; a < n; a++) #define repi(a, b, ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
1
194
#include <bits/stdc++.h> using namespace std; // macros #define int long long #define TIME clock() * 1.0 / CLOCKS_PER_SEC #define all(c) c.begin(), c.end() #define PB push_back #define MP make_pair #define bitcount __builtin_popcount #define watch(x) cerr << (#x) << " is " << (x) << "\n"; #define sz(x) ((int)((x).size...
#include <bits/stdc++.h> using namespace std; // macros #define int long long #define TIME clock() * 1.0 / CLOCKS_PER_SEC #define all(c) c.begin(), c.end() #define PB push_back #define MP make_pair #define bitcount __builtin_popcount #define watch(x) cerr << (#x) << " is " << (x) << "\n"; #define sz(x) ((int)((x).size...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
633
// Bismillahirrahmanirrahim //█▀█─█──█──█▀█─█─█ //█▄█─█──█──█▄█─█▄█ //█─█─█▄─█▄─█─█─█─█ #pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; typedef long long lo; typedef pair<lo, lo> PII; #define fi first #define se second #define mp make_pair #define pb push_back #d...
// Bismillahirrahmanirrahim //█▀█─█──█──█▀█─█─█ //█▄█─█──█──█▄█─█▄█ //█─█─█▄─█▄─█─█─█─█ #pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; typedef long long lo; typedef pair<lo, lo> PII; #define fi first #define se second #define mp make_pair #define pb push_back #d...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
1
171
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <deque> #include <iostream> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #inclu...
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <deque> #include <iostream> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #inclu...
[["+", 0, 43, 49, 50, 51, 16, 31, 74, 0, 24], ["+", 49, 50, 51, 16, 31, 74, 39, 77, 39, 40], ["+", 0, 43, 49, 50, 51, 16, 31, 74, 0, 25]]
1
230
#include <bits/stdc++.h> using namespace std; #define SELECTER(_1, _2, _3, SELECT, ...) SELECT #define REP1(i, n) for (int(i) = 0; (i) < (n); (i)++) #define REP2(i, a, b) for (int(i) = (a); (i) < (b); (i)++) #define REP(...) SELECTER(__VA_ARGS__, REP2, REP1, )(__VA_ARGS__) #define MOD 1'000'000'007 template <class T> ...
#include <bits/stdc++.h> using namespace std; #define SELECTER(_1, _2, _3, SELECT, ...) SELECT #define REP1(i, n) for (int(i) = 0; (i) < (n); (i)++) #define REP2(i, a, b) for (int(i) = (a); (i) < (b); (i)++) #define REP(...) SELECTER(__VA_ARGS__, REP2, REP1, )(__VA_ARGS__) #define MOD 1'000'000'007 template <class T> ...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
1
227
// Patwari26 #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define endl '\n' #define mii map<ll, ll> #define pii pair<ll, ll> #define vi vector<ll> #define all(a) (a).begin(), (a).end() #define F first #define S second #define sz(x) (ll) x.size() #define hell 1000000007 #defin...
// Patwari26 #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define endl '\n' #define mii map<ll, ll> #define pii pair<ll, ll> #define vi vector<ll> #define all(a) (a).begin(), (a).end() #define F first #define S second #define sz(x) (ll) x.size() #define hell 1000000007 #defin...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
1
200
#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; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int getRand(int l, int r) { uniform_int_distribution<int> uid(l, r); return uid(rng); } #de...
#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; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int getRand(int l, int r) { uniform_int_distribution<int> uid(l, r); return uid(rng); } #de...
[["+", 49, 50, 51, 23, 0, 16, 12, 74, 0, 24], ["+", 51, 23, 0, 16, 12, 74, 39, 77, 39, 40], ["+", 49, 50, 51, 23, 0, 16, 12, 74, 0, 25]]
1
235
/* -------------- | / | | / | | / | * |/ | | ------ * | | | | / \ | | |\ | | | |\ | \ ...
/* -------------- | / | | / | | / | * |/ | | ------ * | | | | / \ | | |\ | | | |\ | \ ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 16, 12, 16, 31, 16, 31, 74, 0, 24], ["-", 12, 16, 31, 16, 31, 74, 39, 77, 39, 40], ["-", 0, 16, 12, 16, 31, 16, 31, 74, 0, 25]]
1
157
#include <algorithm> #include <chrono> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { int L; cin >> L; double s = L / 3; printf("%.1...
#include <algorithm> #include <chrono> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int main() { int L; cin >> L; double s = 1.0 * L / 3; print...
[["+", 0, 43, 49, 50, 51, 16, 31, 16, 31, 13], ["+", 0, 43, 49, 50, 51, 16, 31, 16, 17, 48]]
1
67
#include <bits/stdc++.h> using namespace std; #define FOR(i, n) for (int i = 0; i < int(n); i++) #define RNG(i, f, t) for (int i = int(f); i <= int(t); i++) bool RELAXED = false; template <int, typename T> struct MINMAX { T val; MINMAX(T val) : val(val) {} }; template <typename T> MINMAX<1, T> MAX(T val) { return M...
#include <bits/stdc++.h> using namespace std; #define FOR(i, n) for (int i = 0; i < int(n); i++) #define RNG(i, f, t) for (int i = int(f); i <= int(t); i++) bool RELAXED = false; template <int, typename T> struct MINMAX { T val; MINMAX(T val) : val(val) {} }; template <typename T> MINMAX<1, T> MAX(T val) { return M...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
1
389
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespa...
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespa...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
1
590
#include <bits/stdc++.h> using namespace std; /* data type, special numbers, defines */ //#define int ll //use if ded #define ll long long #define ld long double const ll inf = LLONG_MAX; // const ll mod=1e9+7; const ll mod = 998244353; const ld pi = acos(-1.0); #define all(v) v.begin(), v.end() /* end data type and s...
#include <bits/stdc++.h> using namespace std; /* data type, special numbers, defines */ //#define int ll //use if ded #define ll long long #define ld long double const ll inf = LLONG_MAX; // const ll mod=1e9+7; const ll mod = 998244353; const ld pi = acos(-1.0); #define all(v) v.begin(), v.end() /* end data type and s...
[["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67]]
1
829
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <...
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <...
[["+", 0, 16, 31, 16, 31, 16, 12, 2, 63, 22], ["+", 31, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 31, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 31, 16, 31, 16, 12, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
157
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) using ll = long long; const ll MOD = 1000000007, MOD2 = 998244353; int main() { int L; cin >> L; double ans = L * L * L / 27; cout << fixed << setprecision(10); cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) using ll = long long; const ll MOD = 1000000007, MOD2 = 998244353; int main() { double L; cin >> L; double ans = L * L * L / 27; cout << fixed << setprecision(10); cout << ans << endl; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
1
69
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; struct fast_io { fast_io() { std:...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; struct fast_io { fast_io() { std:...
[["+", 12, 2, 3, 4, 0, 16, 31, 74, 0, 24], ["+", 0, 16, 31, 74, 39, 77, 39, 86, 0, 96], ["+", 0, 16, 31, 74, 39, 77, 39, 86, 39, 40], ["+", 12, 2, 3, 4, 0, 16, 31, 74, 0, 25]]
1
118
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 100; int n; double s; int main() { scanf("%d", &n); s = n / 3; printf("%.10lf\n", s * s * s); }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 100; int n; double s; int main() { scanf("%d", &n); s = n / 3.0; printf("%.10lf\n", s * s * s); }
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
61
import collections N = int(input()) A = list(map(int, input().split())) c = collections.Counter(A) ans = 0 for i in range(N): ans+=c[i]*(c[i]-1)//2 for i in range(N): print(ans-(c[A[i]]-1))
import collections N = int(input()) A = list(map(int, input().split())) c = collections.Counter(A) ans = 0 for i in c: ans+=c[i]*(c[i]-1)//2 for i in range(N): print(ans-(c[A[i]]-1))
[["-", 36, 36, 0, 656, 0, 7, 12, 652, 63, 22], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 25], ["+", 36, 36, 36, 36, 0, 656, 0, 7, 12, 22]]
5
87
def resolve(): n = int(input()) a = tuple(map(int,input().split())) A = collections.Counter(a) cnt_0 = 0 for i in A.values(): cnt_0 += int(i*(i-1)/2) for i in a: cnt_1 = A[i]-1 print(cnt_0-cnt_1) resolve()
import collections def resolve(): n = int(input()) a = tuple(map(int,input().split())) A = collections.Counter(a) cnt_0 = 0 for i in A.values(): cnt_0 += int(i*(i-1)/2) for i in a: cnt_1 = A[i]-1 print(cnt_0-cnt_1) resolve()
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]]
5
86
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) using ll = long long; ll f(int n) { if (n < 2) return 0; return n * (n - 1) / 2; } int main() { ll n; cin >> n; vector<int> a(n); vector<ll> c(n + 1); rep(i, n) { cin >> a[i]; c[a[i]]++; } ll sum ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) using ll = long long; ll f(int n) { if (n < 2) return 0; return (ll)n * (n - 1) / 2; } int main() { int n; cin >> n; vector<int> a(n); vector<int> c(n + 1); rep(i, n) { cin >> a[i]; c[a[i]]++; } l...
[["+", 0, 37, 0, 16, 31, 16, 31, 74, 0, 24], ["+", 0, 16, 31, 16, 31, 74, 39, 77, 39, 78], ["+", 0, 37, 0, 16, 31, 16, 31, 74, 0, 25], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40]]
1
162
n=(int)(nput()) a=input().split() for i in range(n): a[i]=(int)(a[i]) dic={} sum=0 for i in range(n): if not a[i] in dic: dic[a[i]]=1 else: dic[a[i]]+=1 sum+=dic[a[i]]-1 for i in a: print(sum-dic[i]+1)
n=(int)(input()) a=input().split() for i in range(n): a[i]=(int)(a[i]) dic={} sum=0 for i in range(n): if not a[i] in dic: dic[a[i]]=1 else: dic[a[i]]+=1 sum+=dic[a[i]]-1 for i in a: print(sum-dic[i]+1)
[["-", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22]]
5
112
""" スニペット """ def get_int(): return int(input()) def get_ints(): return list(map(int, input().split())) """ スニペット """ import math # 2つ選ぶ通り数を算出 nC2 def choose2(n): return n*(n-1)//2 # インプット N = get_int() An = get_ints() """ 全ての要素から2つのボールを選ぶ通り数を求める """ uni = [0] * (N+1) # ユニーク数の配列を求める for i in range(N): uni[An...
""" スニペット """ def get_int(): return int(input()) def get_ints(): return list(map(int, input().split())) """ スニペット """ import math # 2つ選ぶ通り数を算出 nC2 def choose2(n): return n*(n-1)//2 # インプット N = get_int() An = get_ints() """ 全ての要素から2つのボールを選ぶ通り数を求める """ uni = [0] * (N+1) # ユニーク数の配列を求める for i in range(N): uni[An...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
163
#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>; const int INF = 1e9; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1}; #define PI 3.14159265358979323846264338327950L #define MOD 1000000007 // setprecision(15) in...
#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>; const int INF = 1e9; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1}; #define PI 3.14159265358979323846264338327950L #define MOD 1000000007 // setprecision(15) ll...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 78], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
293
n = int(input()) a =list(map(int,input().split())) d = [0]*(n+1) answer = 0 for i in range(n): d[a[i]]+=1 for j in range(n): answer+= (d[j]*(d[j]-1))//2 for k in range(n): print(answer+1-(d[a[k]]))
n = int(input()) a =list(map(int,input().split())) d = [0]*(n+1) answer = 0 for i in range(n): d[a[i]]+=1 for j in range(n+1): answer+= (d[j]*(d[j]-1))//2 for k in range(n): print(answer+1-(d[a[k]]))
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
107
N=int(input()) s=0 A=list(map(int,input().split())) li=[0]*(2*(10**5)+1) for i in range(N): li[A[i]]+=1 for j in range(N): s+=li[j]*(li[j]-1)//2 for k in range(N): print(s-li[A[k]]+1)
N=int(input()) s=0 A=list(map(int,input().split())) li=[0]*(2*(10**5)+1) for i in range(N): li[A[i]]+=1 for j in range(N+1): s+=li[j]*(li[j]-1)//2 for k in range(N): print(s-li[A[k]]+1)
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
109
#include <bits/stdc++.h> using namespace std; #define int long long #define ALL(x) (x).begin(), (x).end() #define MAX(x) *max_element(ALL(x)) #define MIN(x) *min_element(ALL(x)) typedef pair<int, int> PI; typedef pair<int, pair<int, int>> PII; static const int INF = 1010000000000000017LL; static const double eps = 1...
#include <bits/stdc++.h> using namespace std; #define int long long #define ALL(x) (x).begin(), (x).end() #define MAX(x) *max_element(ALL(x)) #define MIN(x) *min_element(ALL(x)) typedef pair<int, int> PI; typedef pair<int, pair<int, int>> PII; static const int INF = 1010000000000000017LL; static const double eps = 1...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
412
n=int(input()) arr=list(map(int,input().split())) tt=[0]*(n+7) total=0 for a in range(n): tt[a]+=1 for t in tt: total += (t*(t-1)//2) for i in range(n): n = tt[arr[0]] d = (n*(n-1)//2) - ((n-1)*(n-2)//2) print(total-d) # x * x-1 // 2
n=int(input()) arr=list(map(int,input().split())) tt=[0]*(n+7) total=0 for a in arr: tt[a]+=1 for t in tt: total += (t*(t-1)//2) for i in range(n): n = tt[arr[i]] d = (n*(n-1)//2) - ((n-1)*(n-2)//2) print(total-d) # x * x-1 // 2
[["-", 36, 36, 0, 656, 0, 7, 12, 652, 63, 22], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 25], ["+", 36, 36, 36, 36, 0, 656, 0, 7, 12, 22], ["-", 0, 1, 0, 662, 12, 206, 206, 206, 206, 612], ["+", 0, 1, 0, 662, 12, 206, 206, 206, 206, 22]]
5
124
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #define rep(i, n) for (int i = 0; i < (n); i++) #define init(a, i) \ for (int k = 0; k < (i); k++) \ (a)[k] = 0 #...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #define rep(i, n) for (int i = 0; i < (n); i++) #define init(a, i) \ for (int k = 0; k < (i); k++) \ (a)[k] = 0 #...
[["-", 3, 4, 0, 16, 12, 105, 39, 77, 39, 40], ["+", 3, 4, 0, 16, 12, 105, 51, 23, 0, 22]]
1
242
n = int(input()) *li,=map(int, input().split()) from collections import Counter c = Counter() for i in li: c[i] += 1 ans=0 from math import comb for i in c.values(): ans += comb(i, 2) for i in li: print(ans - comb(c[i], 2) + comb(c[i-1], 2))
n = int(input()) *li,=map(int, input().split()) from collections import Counter c = Counter() for i in li: c[i] += 1 ans=0 from math import comb for i in c.values(): ans += comb(i, 2) for i in li: print(ans - comb(c[i], 2) + comb(c[i]-1, 2))
[["+", 12, 652, 3, 4, 0, 657, 31, 206, 0, 73], ["-", 0, 657, 12, 652, 3, 4, 0, 206, 0, 73]]
5
99
#!/usr/bin/env python3 import sys from functools import lru_cache from collections import deque sys.setrecursionlimit(10**8) INF = float("inf") MOD = 1000000007 # type: int class Graph(object): def __init__(self, N): self.N = N self.E = defaultdict(list) def add_edge(self, src, dest, w=1)...
#!/usr/bin/env python3 import sys from collections import defaultdict from functools import lru_cache from collections import deque sys.setrecursionlimit(10**8) INF = float("inf") MOD = 1000000007 # type: int class Graph(object): def __init__(self, N): self.N = N self.E = defaultdict(list) ...
[["+", 36, 36, 0, 656, 0, 686, 687, 673, 0, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 487], ["+", 36, 36, 0, 656, 0, 686, 141, 673, 0, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 314]]
5
887
#include <algorithm> #include <cassert> #include <cmath> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll mod = 1e9 + 7; vector<ll...
#include <algorithm> #include <cassert> #include <cmath> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll mod = 1e9 + 7; vector<ll...
[["+", 49, 50, 51, 16, 31, 16, 31, 16, 17, 109], ["+", 49, 50, 51, 16, 31, 16, 31, 16, 12, 22]]
1
956
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stdio.h> #include <string.h> #include <vector> #define REP(i, n) for (int i = 0; (i) < (n); ++(i)) #define FOR(i, n) for (int i = 1; (i) <= (n); ++(i)) #define dump(x) cout << #x << " =...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stdio.h> #include <string.h> #include <vector> #define REP(i, n) for (int i = 0; (i) < (n); ++(i)) #define FOR(i, n) for (int i = 1; (i) <= (n); ++(i)) #define dump(x) cout << #x << " =...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["-", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
936
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) # 全方位木DP、葉側と根側 N = ir() graph = [[] for _ in range(N+1)] # 1-indexed for _ in range(N-1): a, b = lr() graph[a].append(b) graph[b].append(a) MOD = 10 ** 9 + 7 fact = [1]...
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) # 全方位木DP、葉側と根側 N = ir() graph = [[] for _ in range(N+1)] # 1-indexed for _ in range(N-1): a, b = lr() graph[a].append(b) graph[b].append(a) MOD = 10 ** 9 + 7 fact = [1]...
[["-", 0, 656, 0, 7, 12, 206, 206, 663, 0, 612], ["+", 0, 656, 0, 7, 12, 206, 206, 663, 0, 612]]
5
556
import sys input = lambda: sys.stdin.readline().rstrip() #MOD P = 10**9 + 7 N = 200001 #使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心 inv = [0] + [1] # 1/x finv = [1] + [1] # 1/x! fac = [1] + [1] # x! for i in range(2, N): inv += [inv[P % i] * (P - int(P / i)) % P] fac += [(fac[i-1] * i) % P] finv += [(finv[i-1] * inv[i]) % ...
import sys input = lambda: sys.stdin.readline().rstrip() #MOD P = 10**9 + 7 N = 200001 #使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心 inv = [0] + [1] # 1/x finv = [1] + [1] # 1/x! fac = [1] + [1] # x! for i in range(2, N): inv += [inv[P % i] * (P - int(P / i)) % P] fac += [(fac[i-1] * i) % P] finv += [(finv[i-1] * inv[i]) % ...
[["-", 0, 1, 0, 662, 12, 634, 0, 657, 17, 48], ["+", 0, 1, 0, 662, 12, 658, 0, 659, 0, 88], ["+", 0, 1, 0, 662, 12, 658, 0, 659, 31, 22], ["+", 0, 1, 0, 662, 12, 658, 0, 659, 0, 267], ["+", 0, 662, 12, 658, 0, 659, 12, 652, 63, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 24], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, ...
5
880
def main(): from sys import stdin input=stdin.readline n = int(input()) ab = [list(map(int, input().split())) for _ in [0]*(n-1)] g = [set() for _ in [0]*n] for a, b in ab: g[a-1].add(b-1) g[b-1].add(a-1) mod = 10**9+7 fact = [1, 1] inv = [pow(i, mod-2, mod) for i i...
def main(): from sys import stdin input = stdin.readline n = int(input()) ab = [list(map(int, input().split())) for _ in [0]*(n-1)] g = [set() for _ in [0]*n] for a, b in ab: g[a-1].add(b-1) g[b-1].add(a-1) mod = 10**9+7 fact = [1, 1] inv = [pow(i, mod-2, mod) for i...
[["-", 0, 656, 0, 14, 8, 196, 0, 14, 0, 669], ["+", 0, 656, 0, 14, 8, 196, 0, 682, 0, 269], ["-", 0, 14, 8, 196, 0, 14, 54, 54, 0, 22], ["-", 0, 14, 8, 196, 0, 14, 54, 54, 0, 21]]
5
618
#include <algorithm> #include <array> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i...
#include <algorithm> #include <array> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i...
[["-", 0, 1, 0, 16, 31, 16, 0, 42, 0, 22], ["+", 0, 1, 0, 16, 31, 16, 0, 42, 0, 22]]
1
1,050
#include <bits/stdc++.h> #define ll long long #define ld long double #define F first #define S second //#define ONLINE_JUDGE 1 using namespace std; const int mod = 1e9 + 7; const int MAX = 200020; vector<ll> fact(MAX), ifac(MAX); vector<ll> invs(MAX); vector<vector<int>> g(MAX); vector<ll> dp(MAX); vector<ll> sz(M...
#include <bits/stdc++.h> #define ll long long #define ld long double #define F first #define S second #define ONLINE_JUDGE 1 using namespace std; const int mod = 1e9 + 7; const int MAX = 200020; vector<ll> fact(MAX), ifac(MAX); vector<ll> invs(MAX); vector<vector<int>> g(MAX); vector<ll> dp(MAX); vector<ll> sz(MAX...
[["+", 36, 36, 36, 36, 0, 30, 0, 58, 0, 148], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 141, 22], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
1
742
import sys sys.setrecursionlimit(10 ** 7) class Tree: C, RL = {}, {} R, N, D, S, P, T = None, None, None, None, None, None TL = None def __init__(s, num): s.N = num def set(s, a, b): if a in s.C: s.C[a].append(b) else: s.C[a] = [b] if b in s.C: s.C[b].append(a) else: s.C[b] = [a] def mak...
import sys sys.setrecursionlimit(10 ** 7) class Tree: C, RL = {}, {} R, N, D, S, P, T = None, None, None, None, None, None TL = None def __init__(s, num): s.N = num def set(s, a, b): if a in s.C: s.C[a].append(b) else: s.C[a] = [b] if b in s.C: s.C[b].append(a) else: s.C[b] = [a] def mak...
[["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 652, 3, 4, 0, 319, 500, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 319, 0, 131], ["-", 0, 1, 0, 652, 3, 4, 0, 319, 319, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
979
n = int(input()) mod = 10**9 + 7 ## nCkのmodを求める関数 # テーブルを作る(前処理) max = 2 * 10**5 + 10 fac, finv, inv = [0]*max, [0]*max, [0]*max def comInit(max): fac[0] = fac[1] = 1 finv[0] = finv[1] = 1 inv[1] = 1 for i in range(2,max): fac[i] = fac[i-1]* i% mod inv[i] = mod - inv[mod%i] * (mod // i) %...
n = int(input()) mod = 10**9 + 7 ## nCkのmodを求める関数 # テーブルを作る(前処理) max = 2 * 10**5 + 10 fac, finv, inv = [0]*max, [0]*max, [0]*max def comInit(max): fac[0] = fac[1] = 1 finv[0] = finv[1] = 1 inv[1] = 1 for i in range(2,max): fac[i] = fac[i-1]* i% mod inv[i] = mod - inv[mod%i] * (mod // i) %...
[["-", 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
778
def examA(): S = SI() if S[2]==S[3] and S[4]==S[5]: print("Yes") else: print("No") return def examB(): X = I() ans = 0 ans += (X//500) * 1000 X %= 500 ans += (X//5) * 5 print(ans) return def examC(): K, N = LI() A = LI() L = [0]*N L[0] = K-A[...
def examA(): S = SI() if S[2]==S[3] and S[4]==S[5]: print("Yes") else: print("No") return def examB(): X = I() ans = 0 ans += (X//500) * 1000 X %= 500 ans += (X//5) * 5 print(ans) return def examC(): K, N = LI() A = LI() L = [0]*N L[0] = K-A[...
[["-", 0, 656, 0, 14, 8, 196, 0, 37, 0, 38]]
5
1,658
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <ctime> #include <fstream> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <typeinfo> #include <un...
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <ctime> #include <fstream> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <typeinfo> #include <un...
[["+", 0, 11, 12, 16, 31, 16, 31, 16, 31, 13], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 17, 48]]
1
677
n = int(input()) mod = 10**9+7 #出力の制限 N = 10**6 g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル for i in range( 2, N + 1 ): g1.append( ( g1[-1] * i ) % mod ) inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod ) g2.append( (g2[-1] * inverse[-1]) % mod ) g = [[] for _ in range(n...
n = int(input()) mod = 10**9+7 #出力の制限 N = 10**6 g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル for i in range( 2, N + 1 ): g1.append( ( g1[-1] * i ) % mod ) inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod ) g2.append( (g2[-1] * inverse[-1]) % mod ) g = [[] for _ in range(n...
[["-", 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
541
#include <bits/stdc++.h> using namespace std; #define ran 202202 int n; vector<int> e[ran]; int sz[ran], inv[ran], cn[ran]; int f[ran], g[ran]; struct modular_arithmetic { int mod; modular_arithmetic() { mod = 1000000007; } // No specific settings. int add(int x, int y) { return (x += y) < mod ? x : x - mo...
#include <bits/stdc++.h> using namespace std; #define ran 202202 int n; vector<int> e[ran]; int sz[ran], inv[ran], cn[ran]; int f[ran], g[ran]; struct modular_arithmetic { int mod; modular_arithmetic() { mod = 1000000007; } // No specific settings. int add(int x, int y) { return (x += y) < mod ? x : x - mo...
[["+", 3, 4, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 12, 22]]
1
935
import sys def solve(): input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(10 ** 7) mod = 10 ** 9 + 7 def comb(n, r): if r > n: return 0 return fac[n] * inv[r] * inv[n - r] % mod def dfs(v, Pa=-1): for u in to[v]: if u == Pa: continue ...
import sys def solve(): input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(10 ** 7) mod = 10 ** 9 + 7 def comb(n, r): if r > n: return 0 return fac[n] * inv[r] * inv[n - r] % mod def dfs(v, Pa=-1): for u in to[v]: if u == Pa: continue ...
[["-", 0, 1, 0, 677, 12, 657, 31, 206, 51, 22], ["+", 0, 1, 0, 677, 12, 657, 31, 206, 51, 22]]
5
487
import java.io.*; import java.util.*; class Solver { final int n; final int[][] abs; List<List<Integer>> graph; ModCalculator mc; int[] subTreeSizes; long[] subTreePatterns; long[] answers; Solver(int n, int[][] abs) { this.n = n; this.abs = abs; } private void dfs1(int index, int parent...
import java.io.*; import java.util.*; class Solver { final int n; final int[][] abs; List<List<Integer>> graph; ModCalculator mc; int[] subTreeSizes; long[] subTreePatterns; long[] answers; Solver(int n, int[][] abs) { this.n = n; this.abs = abs; } private void dfs1(int index, int parent...
[["-", 8, 196, 0, 1, 0, 11, 12, 492, 141, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 492, 141, 22]]
3
2,966
#include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <numeric> #include <queue> #include <regex> #include <set> #include <stack> #include <string> #include <tuple> #include <type_traits> #include <un...
#include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <numeric> #include <queue> #include <regex> #include <set> #include <stack> #include <string> #include <tuple> #include <type_traits> #include <un...
[["-", 0, 122, 8, 123, 0, 14, 0, 153, 0, 154], ["-", 0, 122, 8, 123, 0, 14, 49, 352, 0, 67]]
1
4,111
#include <bits/stdc++.h> #define M 300005 #define LL long long using namespace std; int A[M], B[M], C[M], sz[M], fa[M]; int P = 1e9 + 7, n; vector<int> edge[M]; LL F[M], dp[M], pre, Ft[M], T[M]; int fast(int x, int n) { LL res = 1, a = x; while (n) { if (n & 1) res = res * a % P; a = a * a % P; n ...
#include <bits/stdc++.h> #define M 300005 #define LL long long using namespace std; int A[M], B[M], C[M], sz[M], fa[M]; int P = 1e9 + 7, n; vector<int> edge[M]; LL F[M], dp[M], pre, Ft[M], T[M]; int fast(int x, int n) { LL res = 1, a = x; while (n) { if (n & 1) res = res * a % P; a = a * a % P; n ...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
616
#pragma GCC optimize("O3") #pragma GCC target("avx") #include <bits/stdc++.h> 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" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\n...
#pragma GCC optimize("O3") #pragma GCC target("avx") #include <bits/stdc++.h> 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" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\n...
[["-", 0, 57, 75, 76, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 70], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 73]]
1
814
from functools import reduce p = 1000000007 #ここを変える ccache = [] inv_ccache = [] def powmod(a, n): global p res = 1 tmp=a while n>0: if n & 1 == 1: res = (res * tmp) % p n=n//2 tmp = tmp * tmp % p return res def invmod(n): return powmod(n, p - 2) def cmod(n, r...
from functools import reduce p = 1000000007 #ここを変える ccache = [] inv_ccache = [] N = 1000000 def powmod(a, n): global p res = 1 tmp=a while n>0: if n & 1 == 1: res = (res * tmp) % p n=n//2 tmp = tmp * tmp % p return res def invmod(n): return powmod(n, p - 2) d...
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]]
5
670
#include <bits/stdc++.h> #define forn(i, n) for (int i = 0; i < int(n); ++i) #define for1(i, n) for (int i = 1; i <= int(n); ++i) #define fore(i, l, r) for (int i = int(l); i <= int(r); ++i) #define ford(i, n) for (int i = int(n) - 1; i >= 0; --i) #define pb push_back #define eb emplace_back #define ms(a, x) memset(a,...
#include <bits/stdc++.h> #define forn(i, n) for (int i = 0; i < int(n); ++i) #define for1(i, n) for (int i = 1; i <= int(n); ++i) #define fore(i, l, r) for (int i = int(l); i <= int(r); ++i) #define ford(i, n) for (int i = int(n) - 1; i >= 0; --i) #define pb push_back #define eb emplace_back #define ms(a, x) memset(a,...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 78]]
1
587
N = int(input()) A = list(map(int,input().split())) from collections import Counter cnt = Counter(A) ans = 0 for v in cnt.values(): ans += v*(v-1)//2 for a in A: k = C[a] print(ans - (k*(k-1)//2) + (k-1)*(k-2)//2)
N = int(input()) A = list(map(int,input().split())) from collections import Counter cnt = Counter(A) ans = 0 for v in cnt.values(): ans += v*(v-1)//2 for a in A: k = cnt[a] print(ans - (k*(k-1)//2) + (k-1)*(k-2)//2)
[["-", 8, 196, 0, 1, 0, 662, 12, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 206, 51, 22]]
5
99
def nc2(n): if n==0: return 0 return n*(n-1)/2 n=int(input()) arr=[int(i) for i in input().strip().split(" ")] ans=0 dic={} for i in arr: dic[i]=dic.get(i,0)+1 for i in dic: if dic[i]==1 : continue ans+=nc2(dic[i]) print(dic) for i in range(n): curr_nc2=nc2(dic[arr[i]]) ...
def nc2(n): if n==0: return 0 return n*(n-1)/2 n=int(input()) arr=[int(i) for i in input().strip().split(" ")] ans=0 dic={} for i in arr: dic[i]=dic.get(i,0)+1 for i in dic: if dic[i]==1 : continue ans+=nc2(dic[i]) #print(dic) for i in range(n): curr_nc2=nc2(dic[arr[i]]) ...
[["-", 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
153
import collections n=int(input()) a=list(map(int,input().split())) c=collections.Counter(a) print(c) s=0 for i in c.values(): s+=i*(i-1)//2 #ボールを抜かない場合に2つのボールを選ぶ方法の数 for j in a: f=c[j] print(s-(f-1)) #下記メモ参照 ''' 複数個のボールから1個のボールが抜かれる場合、i*(i-1)//2が(i-1)*(i-2)//2となる。 i*(i-1)//2-(i-1)*(i-2)//2 =i-1 よって、2つのボールを...
import collections n=int(input()) a=list(map(int,input().split())) c=collections.Counter(a) s=0 for i in c.values(): s+=i*(i-1)//2 #ボールを抜かない場合に2つのボールを選ぶ方法の数 for j in a: f=c[j] print(s-(f-1)) #下記メモ参照 ''' 複数個のボールから1個のボールが抜かれる場合、i*(i-1)//2が(i-1)*(i-2)//2となる。 i*(i-1)//2-(i-1)*(i-2)//2 =i-1 よって、2つのボールを選ぶ方法が(i-1...
[["-", 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], ["-", 36, 36, 0, 656, 0, 1, 0, 557, 0, 6], ["+", 36, 36, 0, 656, 0, 1, 0, 557, 0, 6]]
5
88
if __name__ == '__main__': n = int(input()) A = list(map(int,input().split())) #全体の数 d = Counter(A) d2 = dict() #この時の組み合わせの合計 for k,v in d.items(): d2[k] = (v*(v-1)) // 2 ans_sum = sum(d2.values()) #結果表示 for i in A: ans = 0 if i in d2: ...
from collections import Counter if __name__ == '__main__': n = int(input()) A = list(map(int,input().split())) #全体の数 d = Counter(A) d2 = dict() #この時の組み合わせの合計 for k,v in d.items(): d2[k] = (v*(v-1)) // 2 ans_sum = sum(d2.values()) #結果表示 for i in A: ans = 0...
[["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 314], ["+", 36, 36, 0, 656, 0, 686, 687, 673, 0, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 487], ["+", 36, 36, 0, 656, 0, 686, 141, 673, 0, 22]]
5
144
n = int(input()) A = list(map(int,input().split())) S={} for i in range(n): a = A[i] if a in S : S[a]+=1 else: S[a]=1 V=list(S.values()) c = sum([v*(v-1)//2 for v in V]) cdiff=0 K=[] for i in range(n): a = A[i] s=S[a] if s>=2 : cdiff=(s*(s-1)-(s-1)*(s-2))//2 print(...
n = int(input()) A = list(map(int,input().split())) S={} for i in range(n): a = A[i] if a in S : S[a]+=1 else: S[a]=1 V=list(S.values()) c = sum([v*(v-1)//2 for v in V]) cdiff=0 K=[] for i in range(n): cdiff=0 a = A[i] s=S[a] if s>=2 : cdiff=(s*(s-1)-(s-1)*(s-2))//...
[["+", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612]]
5
155
n = gets.chomp.to_i a = gets.chomp.split(" ").map(&:to_i) hash = Hash.new(0) a.each do |i| hash[i] += 1 end hash_2 = Hash.new(0) arr = Array.new(n+1,0) count = 0 hash.each do |i| #p i ans = (i[1] * (i[1] - 1)) / 2 hash_2[i[0]] = ans #p ans count += ans end p hash_2 a.each do |j| point = has...
n = gets.chomp.to_i a = gets.chomp.split(" ").map(&:to_i) hash = Hash.new(0) a.each do |i| hash[i] += 1 end hash_2 = Hash.new(0) arr = Array.new(n+1,0) count = 0 hash.each do |i| #p i ans = (i[1] * (i[1] - 1)) / 2 hash_2[i[0]] = ans #p ans count += ans end #p hash_2 a.each do |j| point = ha...
[["-", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["-", 36, 36, 0, 493, 0, 652, 3, 4, 0, 22]]
4
200
import math N = int(input()) A = list(map(int, input().split())) dic = {} for a in A: if not a in dic: dic[a] = 1 else: dic[a] += 1 ans = 0 for a in dic: if dic[a] > 1: ans += dic[a] * (dic[a] - 1) // 2 ansdic = {} for a in dic: ansdic[a] = 0 if dic[a] > 1: ansd...
import math N = int(input()) A = list(map(int, input().split())) dic = {} for a in A: if not a in dic: dic[a] = 1 else: dic[a] += 1 ans = 0 for a in dic: if dic[a] > 1: ans += dic[a] * (dic[a] - 1) // 2 ansdic = {} for a in dic: ansdic[a] = ans if dic[a] > 1: an...
[["-", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 22]]
5
139
def combination(n,r): n_=1 r_=1 for i in range(n,n-r,-1): n_*=i for i in range(1,r+1): r_*=i return n_//(n_r*r_) def main(): N=int(input()) A=list(map(int,input().split())) ball_dic={} for a in A: if a in ball_dic.keys(): ball_dic[a]+=1 ...
def combination(n,r): n_=1 r_=1 for i in range(n,n-r,-1): n_*=i for i in range(1,r+1): r_*=i return n_//r_ def main(): N=int(input()) A=list(map(int,input().split())) ball_dic={} for a in A: if a in ball_dic.keys(): ball_dic[a]+=1 else:...
[["-", 8, 196, 0, 37, 0, 657, 12, 23, 0, 24], ["-", 0, 37, 0, 657, 12, 23, 0, 657, 31, 22], ["-", 0, 37, 0, 657, 12, 23, 0, 657, 17, 48], ["-", 8, 196, 0, 37, 0, 657, 12, 23, 0, 25]]
5
274
N=int(input()) A=list(map(int,input().split())) dic={} for a in A: if a in dic: dic[a]+=1 else: dic[a]=1 print(dic) c=0 for i in dic.values(): c+=i*(i-1)/2 for j in range(1,N+1): d=c-dic[A[j-1]]+1 print(int(d))
N=int(input()) A=list(map(int,input().split())) dic={} for a in A: if a in dic: dic[a]+=1 else: dic[a]=1 c=0 for i in dic.values(): c+=i*(i-1)/2 for j in range(1,N+1): d=c-dic[A[j-1]]+1 print(int(d))
[["-", 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
114
n=int(input()) a=list(map(int,input().split())) def choose2(n): if n <= 1: return 0 return n*(n-1)//2 inp = [0]*(n+1) for i in range(n): inp[a[i]] += 1 total = 0 for i in range(n): total += choose2(inp[i]) for i in range(n): count = total - choose2(inp[a[i]]) + choose2(inp[a[i]]-1) print(count)
n=int(input()) a=list(map(int,input().split())) def choose2(n): if n <= 1: return 0 return n*(n-1)//2 inp = [0]*(n+1) for i in range(n): inp[a[i]] += 1 total = 0 for i in range(n+1): total += choose2(inp[i]) for i in range(n): count = total - choose2(inp[a[i]]) + choose2(inp[a[i]]-1) print(count)
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
135
from collections import Counter n = int(input()) a_input = list(map(int,input().split())) a_count = Counter(a_input) score_dic={} exclude_dic={} for k,v in enumerate(a_count.items()): score_dic[k]=v*(v-1)//2 exclude_dic[k]=(v-1)*(v-2)//2 score_sum = sum(score_dic.values()) for i in range(n): print(scor...
from collections import Counter n = int(input()) a_input = list(map(int,input().split())) a_count = Counter(a_input) score_dic={} exclude_dic={} for k,v in a_count.items(): score_dic[k]=v*(v-1)//2 exclude_dic[k]=(v-1)*(v-2)//2 score_sum = sum(score_dic.values()) for i in range(n): print(score_sum-score...
[["-", 36, 36, 0, 656, 0, 7, 12, 652, 63, 22], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 24], ["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
127
import collections n = int(input()) arr = list(map(int,input().split())) cnt = collectioms.Counter(arr) total = 0 for key in cnt.keys(): total += cnt[key] * (cnt[key] - 1)//2 for i in range(n): tmp = total tmp -= cnt[arr[i]]*(cnt[arr[i]] - 1)//2 tmp += (cnt[arr[i]] - 1)*(cnt[arr[i]] - 2)//2 print(tmp)
import collections n = int(input()) arr = list(map(int,input().split())) cnt = collections.Counter(arr) total = 0 for key in cnt.keys(): total += cnt[key] * (cnt[key] - 1)//2 for i in range(n): tmp = total tmp -= cnt[arr[i]]*(cnt[arr[i]] - 1)//2 tmp += (cnt[arr[i]] - 1)*(cnt[arr[i]] - 2)//2 print(tmp)
[["-", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22]]
5
129
import collections n = int(input()) a = list(map(int, input().split())) c = collections.Counter(a) v = c.values() s = 0 for i in v: s += (i*(i-1))//2 for i in range(n): d = c[a[i]] x = (d*(d-1))//2 if d > 1 else 0 y = (d-1*(d-2))//2 if d > 2 else 0 print(s-x+y)
import collections n = int(input()) a = list(map(int, input().split())) c = collections.Counter(a) v = c.values() s = 0 for i in v: s += (i*(i-1))//2 for i in range(n): d = c[a[i]] x = (d*(d-1))//2 if d > 1 else 0 y = ((d-1)*(d-2))//2 if d > 2 else 0 print(s-x+y)
[["+", 0, 657, 31, 23, 0, 657, 31, 23, 0, 24], ["+", 0, 657, 31, 23, 0, 657, 31, 23, 0, 25]]
5
128
import math N = int(input()) K = list(map(int,input().split())) hashmap = {} for k in K: if k not in hashmap: hashmap[k] = 0 hashmap[k]+=1 total = 0 for v in hashmap.values(): total+=math.factorial(v) // (math.factorial(v - 2) * 2) for k in K: print(total-(hashmap[k]-1))
import math N = int(input()) K = list(map(int,input().split())) hashmap = {} for k in K: if k not in hashmap: hashmap[k] = 0 hashmap[k]+=1 total = 0 for v in hashmap.values(): if v>=2: total+=math.factorial(v) // (math.factorial(v - 2) * 2) for k in K: print(total-(hashmap[k]-1))
[["+", 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, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 656, 0, 7, 8, 196, 0, 57, 0, 102]]
5
105
def main(): N = int(input()) A = [int(i) for i in input().split()] from collections import Counter c = Counter(A) ans = 0 for v in c.values(): ans += v*(v-1)//2 for k in range(N): v = c[A[k]] diff = -v*(v-1)//2 + (v-1)*(v-2)//2 print(ans + diff if v != 1 else...
def main(): N = int(input()) A = [int(i) for i in input().split()] from collections import Counter c = Counter(A) ans = 0 for v in c.values(): ans += v*(v-1)//2 for k in range(N): v = c[A[k]] diff = -v*(v-1)//2 + (v-1)*(v-2)//2 print(ans + (diff if v != 1 els...
[["+", 0, 652, 3, 4, 0, 657, 12, 23, 0, 24], ["+", 0, 652, 3, 4, 0, 657, 12, 23, 0, 25]]
5
129
def main(): N = int(input()) A = [int(i) for i in input().split()] from collections import Counter c = Counter(A) ans = 0 for v in c.values(): ans += v*(v-1)//2 for k in range(N): if 2 <= c[A[k]]: print(ans - (c[A[k]] - 1)) else: print(0) if ...
def main(): N = int(input()) A = [int(i) for i in input().split()] from collections import Counter c = Counter(A) ans = 0 for v in c.values(): ans += v*(v-1)//2 for k in range(N): if 2 <= c[A[k]]: print(ans - (c[A[k]] - 1)) else: print(ans) i...
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22]]
5
115
from collections import Counter N = int(input()) A = list(map(int, input().split())) cA = Counter(A) allS = 0 for key in cA: allS += cA[key] * (cA[key] - 1) / 2 for i in range(N): if i in cA.keys(): print(int(allS - (cA[i] - 1))) else: print(int(allS))
from collections import Counter N = int(input()) A = list(map(int, input().split())) cA = Counter(A) allS = 0 for key in cA: allS += cA[key] * (cA[key] - 1) / 2 for i in range(N): if A[i] in cA.keys(): print(int(allS - (cA[A[i]] - 1))) else: print(int(allS))
[["+", 8, 196, 0, 57, 15, 666, 0, 206, 51, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 0, 70], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 0, 73], ["+", 0, 657, 12, 23, 0, 657, 31, 206, 0, 70], ["+", 12, 23, 0, 657, 31, 206, 206, 206, 51, 22], ["+", 12, 23, 0, 657, 31, 206, 206, 206, 0, 73]]
5
102
#include <bits/stdc++.h> typedef long long ll; using namespace std; ll p(ll a, ll b) { ll sum = 1, cnt = 0; for (ll i = a; cnt < b; i--) { sum *= i; cnt++; } return sum; } ll c(ll a, ll b) { ll r = 1; for (ll i = 1; i <= b; i++) { r *= i; } return a / r; } int main() { cin.tie(0); ios:...
#include <bits/stdc++.h> typedef long long ll; using namespace std; ll p(ll a, ll b) { ll sum = 1, cnt = 0; for (ll i = a; cnt < b; i--) { sum *= i; cnt++; } return sum; } ll c(ll a, ll b) { ll r = 1; for (ll i = 1; i <= b; i++) { r *= i; } return a / r; } int main() { cin.tie(0); ios:...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 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
356
/*------------------------------------ ........Bismillahir Rahmanir Rahim.... ..........created by Abdul Aziz....... ------------------------------------*/ #include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stdio.h> #include <unordered_m...
/*------------------------------------ ........Bismillahir Rahmanir Rahim.... ..........created by Abdul Aziz....... ------------------------------------*/ #include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stdio.h> #include <unordered_m...
[["-", 0, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 17, 72]]
1
227
from collections import Counter N=int(input()) A = list(map(int,input().split())) ans = [0] * N B = Counter(A) for i in range(N): ans[i] = B[A[i]]-1 total=sum(ans) C=[] for i in range(N): c = (total-ans[i])//2 C.append(c) for num in C: print(num)
from collections import Counter N=int(input()) A = list(map(int,input().split())) ans = [0] * N B = Counter(A) for i in range(N): ans[i] = B[A[i]]-1 total=sum(ans) C=[] for i in range(N): c = (total-2*ans[i])//2 C.append(c) for num in C: print(num)
[["+", 12, 657, 31, 23, 0, 657, 12, 657, 31, 612], ["+", 12, 657, 31, 23, 0, 657, 12, 657, 17, 48]]
5
109
from collections import defaultdict N = int(input()) A = list(map(int, input().split())) d = defaultdict(int) for key in A: d[key] += 1 #print(d) Sum = 0 for i in d: n = d[A[i]] Sum += (n * (n - 1)) // 2 #print((n * (n - 1)) // 2) #print(d[A[i]],i) #print(d) #print(Sum) for i in range(N...
from collections import defaultdict N = int(input()) A = list(map(int, input().split())) d = defaultdict(int) for key in A: d[key] += 1 #print(d) Sum = 0 for i in d: n = d[i] Sum += (n * (n - 1)) // 2 #print((n * (n - 1)) // 2) #print(d[A[i]],i) #print(d) #print(Sum) for i in range(N): ...
[["-", 0, 1, 0, 662, 12, 206, 206, 206, 51, 22], ["-", 0, 1, 0, 662, 12, 206, 206, 206, 0, 70], ["-", 0, 1, 0, 662, 12, 206, 206, 206, 0, 73]]
5
133
N=int(input()) A=list(map(int,input().strip().split())) l=[0 for n in range(N+1)] for e in A: l[e]+=1 count=0 for n in range(N): if l[n]>=2: count+=l[n]*(l[n]-1)//2 for n in range(N): print(count-l[A[n]]+1)
N=int(input()) A=list(map(int,input().strip().split())) l=[0 for n in range(N)] for e in A: l[e-1]+=1 count=0 for n in range(N): if l[n]>=2: count+=l[n]*(l[n]-1)//2 for n in range(N): print(count-l[A[n]-1]+1)
[["-", 0, 659, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 1, 0, 677, 31, 206, 206, 657, 17, 33], ["+", 0, 1, 0, 677, 31, 206, 206, 657, 12, 612], ["+", 0, 657, 31, 657, 12, 206, 206, 657, 17, 33], ["+", 0, 657, 31, 657, 12, 206, 206, 657, 12, 612]]
5
112
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <unordered_map> #include <utility> #include <vector> template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return fa...
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <unordered_map> #include <utility> #include <vector> template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return fa...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
329
from operator import mul from functools import reduce N = int(input()) A = list(map(int,input().split())) def cmb(n, r): if n < r: return 0 r = min(n - r, r) if r == 0: return 1 over = reduce(mul, range(n, n - r, -1)) under = reduce(mul, range(1, r + 1)) return over // under dic = {} for i i...
from operator import mul from functools import reduce N = int(input()) A = list(map(int,input().split())) def cmb(n, r): if n < r: return 0 r = min(n - r, r) if r == 0: return 1 over = reduce(mul, range(n, n - r, -1)) under = reduce(mul, range(1, r + 1)) return over // under dic = {} for i...
[["-", 0, 7, 8, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 31, 22]]
5
188
N=int(input()) A=list(map(int,input().split())) count=[0]*(N+1) for a in A: count[a]+=1 combination=0 for i in range(N): if count[i]!=0: combination+=count[i]*(count[i]-1)//2 for a in A: print(combination-(count[a]-1))
N=int(input()) A=list(map(int,input().split())) count=[0]*(N+1) for a in A: count[a]+=1 combination=0 for i in range(N+1): if count[i]!=0: combination+=count[i]*(count[i]-1)//2 for a in A: print(combination-(count[a]-1))
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
101
from collections import Counter n=int(input()) a=list(map(int,input().split())) C=Counter(a) #print(C) total=0 for k,v in C.items(): if v>=2: total+=v*(v-1)//2 print(total) for i in range(n): V=C[a[i]] ans=total-(V*(V-1))//2+((V-1)*(V-2))//2 print(ans)
from collections import Counter n=int(input()) a=list(map(int,input().split())) C=Counter(a) #print(C) total=0 for k,v in C.items(): if v>=2: total+=v*(v-1)//2 #print(total) for i in range(n): V=C[a[i]] ans=total-(V*(V-1))//2+((V-1)*(V-2))//2 print(ans)
[["-", 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
122
// -------------- // Tejas Pandey | // 12 - 06 - 20 | // Random Practice| // -------------- #include <bits/stdc++.h> using namespace std; #define vi vector<int> typedef long long int ll; int cnt[100007]; int main(void) { // freopen("in.txt","r",stdin); // freopen("out.txt","w",stdout); ios_base::sync_with_s...
// -------------- // Tejas Pandey | // 12 - 06 - 20 | // Random Practice| // -------------- #include <bits/stdc++.h> using namespace std; #define vi vector<int> typedef long long int ll; ll cnt[200007]; int main(void) { // freopen("in.txt","r",stdin); // freopen("out.txt","w",stdout); ios_base::sync_with_st...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 78], ["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
524
n = int(input()) a = list(map(int, input().split())) def factorial(n): v = 1 for i in range(1, n + 1): v *= i return v def comb(a, b): return factorial(a) // (factorial(b) * factorial(a - b)) from collections import Counter acnt = dict(Counter(a)) value = list(acnt.values()) sv = 0 for i in r...
n = int(input()) a = list(map(int, input().split())) def factorial(n): v = 1 for i in range(1, n + 1): v *= i return v def comb(a, b): return factorial(a) // (factorial(b) * factorial(a - b)) from collections import Counter acnt = dict(Counter(a)) value = list(acnt.values()) sv = 0 for i in r...
[["+", 12, 657, 31, 23, 0, 657, 12, 23, 0, 24], ["+", 0, 657, 12, 23, 0, 657, 31, 206, 0, 73], ["-", 12, 657, 31, 23, 0, 657, 12, 206, 0, 73], ["+", 12, 657, 31, 23, 0, 657, 12, 23, 0, 25]]
5
190
n = int(input()) a = list(map(int, input().split())) c = {} for i in a: c[i] = c.get(i, 0) + 1 ways = 0 for i in a: ways += c[i]*(c[i]-1)//2 for k in a: ans = ways-c[k]+1 print(ans)
n = int(input()) a = list(map(int, input().split())) c = {} for i in a: c[i] = c.get(i, 0) + 1 ways = 0 for i in c: ways += c[i]*(c[i]-1)//2 for k in a: ans = ways-c[k]+1 print(ans)
[["-", 36, 36, 36, 36, 0, 656, 0, 7, 12, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 7, 12, 22]]
5
93
n = int(input()) l = list(map(int, input().split())) import collections c = collections.Counter(l) ans = 0 for i in c.values(): ans += i * (i - 1) // 2 for i in l: print(ans - c[i] - 1)
n = int(input()) l = list(map(int, input().split())) import collections c = collections.Counter(l) ans = 0 for i in c.values(): ans += i * (i - 1) // 2 for i in l: print(ans - c[i] + 1)
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72]]
5
74
n = int(input()) number = list(map(int,input().split())) num = sorted(number) num.append(0) p = num[0] combi = dict() u = 0 for i in range (n+1) : q = num[i] if p != q : combi[p] = u u = 0 u += 1 p = q t = 0 for j in combi.values() : t += j*(j-1)//2 for k in range (n) : x = c...
n = int(input()) number = list(map(int,input().split())) num = sorted(number) num.append(0) p = num[0] combi = dict() u = 0 for i in range (n+1) : q = num[i] if p != q : combi[p] = u u = 0 u += 1 p = q t = 0 for j in combi.values() : t += j*(j-1)//2 for k in range (n) : x = n...
[["-", 8, 196, 0, 1, 0, 662, 12, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 206, 51, 22], ["-", 8, 196, 0, 1, 0, 662, 12, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 206, 206, 22]]
5
164
N = gets.to_i A = gets.split(" ").map(&:to_i) counts = Array.new(N,0) sum = 0 A.each do |a| counts[a - 1] += 1 end counts.each do |c| if c > 1 sum += c* (c - 1) / 2 end end A.each do |a| if counts[a - 1] > 1 puts sum - counts[a - 1] + 1 else puts 0 end end
N = gets.to_i A = gets.split(" ").map(&:to_i) counts = Array.new(N,0) sum = 0 A.each do |a| counts[a - 1] += 1 end counts.each do |c| if c > 1 sum += c* (c - 1) / 2 end end A.each do |a| if counts[a - 1] > 1 puts sum - counts[a - 1] + 1 else puts sum end end
[["-", 0, 121, 75, 95, 0, 652, 3, 4, 0, 612], ["+", 0, 121, 75, 95, 0, 652, 3, 4, 0, 22]]
4
106
#include <bits/stdc++.h> typedef long long lint; using namespace std; lint gcd(lint x, lint y) { if (x == 0) { return y; } else { return gcd(y % x, x); } } lint lcm(lint x, lint y) { return x / gcd(x, y) * y; } lint C(lint n, lint k) { if (n == k) { return 1; } else if (n < k) { return 0; ...
#include <bits/stdc++.h> typedef long long lint; using namespace std; lint gcd(lint x, lint y) { if (x == 0) { return y; } else { return gcd(y % x, x); } } lint lcm(lint x, lint y) { return x / gcd(x, y) * y; } lint C(lint n, lint k) { if (n == k) { return 1; } else if (n < k) { return 0; ...
[["-", 0, 1, 0, 11, 12, 16, 31, 16, 17, 85], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 85], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
316
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int N; cin >> N; vector<int> A(N); map<int, ll> mp; for (int i = 0; i < N; i++) { cin >> A[i]; if (mp.count(A[i])) mp[A[i]]++; else mp[A[i]] = 1; } ll total = 0; for (auto x : mp) { ll num = x.s...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int N; cin >> N; vector<int> A(N); map<int, ll> mp; for (int i = 0; i < N; i++) { cin >> A[i]; if (mp.count(A[i])) mp[A[i]]++; else mp[A[i]] = 1; } ll total = 0; for (auto x : mp) { ll num = x.s...
[["+", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 0, 57, 75, 76, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 75, 76, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 75, 76, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 57, 75, 76, 0, 1, 0, 35]]
1
207
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { int N; ll A[200010] = {0}; ll B[200010]; for (int i = 0; i < N; i++) { cin >> B[i]; A[B[i]]++; } ll sum = 0; // N個のときの総数 for (int i = 1; i < -N; i++) { sum += A[i] * (A[i] - 1) / 2; } // for文でそれぞれi個目のボール...
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { int N; cin >> N; ll A[200010] = {0}; ll B[200010]; for (int i = 0; i < N; i++) { cin >> B[i]; A[B[i]]++; } ll sum = 0; // N個のときの総数 for (int i = 1; i <= N; i++) { sum += A[i] * (A[i] - 1) / 2; } // for文...
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 8, 9, 0, 7, 15, 16, 12, 91, 17, 33], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
154
from collections import Counter n = int(input()) A = list(map(int, input().split())) counter = Counter(A) counter_comb = list(map(lambda y: int(y*(y-1)/2), counter.values())) sum_counter = sum(counter_comb) for i in range(n): z = counter[A[i]-1] if z>0: print(ssum_counter-(z-1)) else: print...
from collections import Counter n = int(input()) A = list(map(int, input().split())) counter = Counter(A) counter_comb = list(map(lambda y: int(y*(y-1)/2), counter.values())) sum_counter = sum(counter_comb) for i in range(n): z = counter[A[i]] if z>0: print(sum_counter-(z-1)) else: print(su...
[["-", 0, 1, 0, 662, 12, 206, 206, 657, 17, 33], ["-", 0, 1, 0, 662, 12, 206, 206, 657, 12, 612], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22]]
5
110
import collections n = int(input()) A = list(map(int,input().split())) B = collections.Counter(A) C = B.copy() total = 0 for i in B.values(): total += i*(i-1)//2 for i in A: print(total - i)
import collections n = int(input()) A = list(map(int,input().split())) B = collections.Counter(A) C = B.copy() total = 0 for i in B.values(): total += i*(i-1)//2 for i in A: print(total - B[i]+1)
[["+", 3, 4, 0, 657, 31, 657, 12, 206, 51, 22], ["+", 3, 4, 0, 657, 31, 657, 12, 206, 0, 70], ["+", 3, 4, 0, 657, 31, 657, 12, 206, 0, 73], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
76
//#include <bits/stdc++.h> #include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> using namespace std; typedef long long ll; typedef vector<int> vint; typedef vector<vector<int>> vvint; typedef vector<long long> vll, vLL; typed...
//#include <bits/stdc++.h> #include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> using namespace std; typedef long long ll; typedef vector<int> vint; typedef vector<vector<int>> vvint; typedef vector<long long> vll, vLL; typed...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
275
n=int(input()) al=list(map(int,input().split())) counter=[0]*(n+1) for a in al: nums[a]+=1 sum=0 for c in counter: sum+=c*(c-1)//2 for a in al: print(sum-(counter[a]-1))
n=int(input()) al=list(map(int,input().split())) counter=[0]*(n+1) for a in al: counter[a]+=1 sum=0 for c in counter: sum+=c*(c-1)//2 for a in al: print(sum-(counter[a]-1))
[["-", 8, 196, 0, 1, 0, 677, 31, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 677, 31, 206, 51, 22]]
5
84