text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; int putt[11][11]; long n, m, g[12], t, at; int main() { cin >> n >> m; for (int i = 0; i < n; i++) { cin >> t; g[t]++; } for (int i = 1; i <= m; i++) for (int j = 1; j <= m; j++) if (j != i && !putt[i][j]) { at += g[i] * g[j]; putt[i][j] = 1; putt[j][i] = 1; } cout << at; }
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 2e5 + 7; long long num[maxn]; int main() { int n, m; while (cin >> n >> m) { memset(num, 0, sizeof(num)); for (int i = 0; i < n; i++) { int x; cin >> x; num[x]++; } long long ans = 0; for (int i = 1; i <= 10; i++) { ans += (n - num[i]) * num[i]; } cout << ans / 2 << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, count[11] = {0}, i, j, inp; long long total = 0; cin >> n >> m; for (i = 0; i < n; i++) { cin >> inp; count[inp]++; } for (i = 1; i < m; i++) { for (j = i + 1; j <= m; j++) { total += count[i] * count[j]; } } cout << total << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n, m, i, a[11][200005], v[200005], s, j; int main() { cin >> n >> m; for (i = 1; i <= n; i++) { cin >> v[i]; } for (i = n; i >= 1; i--) { for (j = 1; j <= m; j++) a[j][i] = a[j][i + 1]; a[v[i]][i] = a[v[i]][i + 1] + 1; } for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) { if (j != v[i]) s = s + a[j][i]; } } cout << s; }
#include <bits/stdc++.h> using namespace std; int cnt[10000010]; int a[1000001]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { int a; cin >> a; cnt[a]++; } int ans = 0; for (int i = 1; i <= m; i++) { for (int j = i + 1; j <= m; j++) { ans += cnt[i] * cnt[j]; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; map<int, int> mp; map<int, int>::iterator it, i; int main() { int n, m, s = 0; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) { int x; scanf("%d", &x); mp[x]++; } for (it = mp.begin(); it != mp.end(); it++) { int sum = 0; it++; for (i = it; i != mp.end(); i++) { sum += i->second; } it--; s += (sum * it->second); } cout << s; return 0; }
#include <bits/stdc++.h> using namespace std; int a[15]; long long f(long long n, long long k) { if (k > n) return 0; if (k > n / 2) return f(n, n - k); long long res = 1; for (long long i = n - k + 1; i <= n; i++) res *= i; for (long long i = 1; i <= k; i++) res /= i; return res; } int main() { ios::sync_with_stdio(false); int n, m; cin >> n >> m; for (int i = 0; i < (n); i++) { int c; cin >> c; a[c - 1]++; } long long ans = f(n, 2); for (int i = 0; i < (m); i++) ans -= f(a[i], 2); cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int n, m; long long a[15]; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) { int x; scanf("%d", &x); a[x]++; } long long ans = 0; for (int i = 1; i <= m; i++) for (int j = i + 1; j <= m; j++) ans += a[i] * a[j]; cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; long long M = 1000000007; void fast() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } long long power(long long base, long long n) { if (n == 0) return 1; if (n == 1) return base; long long halfn = power(base, n / 2); if (n % 2 == 0) return (halfn * halfn) % M; else return (((halfn * halfn) % M) * base) % M; } void solve() { long long n, m; cin >> n >> m; vector<long long> a(n); for (auto& i : a) cin >> i; map<long long, long long> mp; for (auto i : a) mp[i]++; long long c = 0; for (long long i = 1; i <= m; i++) { for (long long j = i + 1; j <= m; j++) { c += mp[i] * mp[j]; } } cout << c; } int main() { fast(); solve(); return 0; }
#include <bits/stdc++.h> long long a[11]; using namespace std; int main() { long long n, m, i, s, x, j; scanf("%lld", &n); scanf("%lld", &m); for (i = 0; i < n; i++) { scanf("%lld", &x); a[x]++; } s = 0; for (i = 1; i <= m; i++) { for (j = i + 1; j <= m; j++) { s += a[i] * a[j]; } } printf("%lld\n", s); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; long long int ma, a; cin >> n >> ma; long long int b[n]; memset(b, 0, sizeof(b)); for (long long int i = 1; i < n; i++) { b[i] = b[i - 1] + i; } map<int, int> m; map<int, int>::iterator itr; for (long long int i = 0; i < n; i++) { cin >> a; m[a]++; } long long int x = b[n - 1]; for (itr = m.begin(); itr != m.end(); itr++) { x = x - b[(itr->second) - 1]; } cout << x; }
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 55; int a[2 * MAX]; int c[2 * MAX]; int main() { long long n, m; cin >> n >> m; long long ans = 0; for (long long i = 0; i < n; ++i) { cin >> a[i]; c[a[i]]++; } for (int i = 1; i < m; ++i) for (int j = i + 1; j <= m; ++j) ans += c[i] * c[j]; cout << ans; return 0; }
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:1677721600") using namespace std; template <class T> inline bool in(T &ret) { char c; int sgn; if (c = getchar(), c == EOF) return 0; while (c != '-' && (c < '0' || c > '9')) c = getchar(); sgn = (c == '-') ? -1 : 1; ret = (c == '-') ? 0 : (c - '0'); while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0'); ret *= sgn; return 1; } template <class T> inline void out(T x) { if (x < 0) { putchar('-'); x = -x; } if (x > 9) out(x / 10); putchar(x % 10 + '0'); } template <class T> T MAX(T a, T b) { return a > b ? a : b; } template <class T> T MIN(T a, T b) { return a < b ? a : b; } template <class T> T GCD(T a, T b) { return b ? GCD(b, a % b) : a; } template <class T> T LCM(T a, T b) { return a / GCD(a, b) * b; } const int MAXN = 50 + 10; const int MAXM = 50 + 10; const double eps = 1e-8; long long MOD = 1000000007; long long a[14]; long long ge(long long x) { return x * (x - 1) / 2; } int main() { long long n, m; cin >> n >> m; int t; for (int i = 1; i <= n; i++) { cin >> t; a[t]++; } long long ans = ge(n); for (int i = 1; i <= m; i++) { ans -= ge(a[i]); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> genres(m, 0); for (int i = 0; i < n; i++) { int j; cin >> j; genres[j - 1]++; } int ans = 0; for (int i = 0; i < m - 1; i++) { int temp = 0; for (int j = i + 1; j < m; j++) { temp += genres[i] * genres[j]; } ans += temp; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int num[20]; int main() { int n, m; cin >> n >> m; memset(num, 0, sizeof num); for (int i = 1; i <= n; i++) { int a; cin >> a; num[a]++; } int ans = 0; for (int i = 1; i < m; i++) { for (int j = i + 1; j <= m; j++) { ans += (num[i] * num[j]); } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; void read() {} int main() { read(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; while (t--) { int n, m, a, ans = 0, temp, count = 0; cin >> n >> m; map<long long int, long long int> mp; for (int i = 0; i < n; i++) { cin >> a; mp[a]++; for (auto pr : mp) { if (pr.first != a) { ans += pr.second; } } } cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; long long powmod(long long a, long long b) { long long res = 1; a %= 1000000007; for (; b; b >>= 1) { if (b & 1) res = res * a % 1000000007; a = a * a % 1000000007; } return res; } int a[300000]; long long num[11]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) num[a[i]]++; long long ans = 0; for (int i = 1; i <= m; i++) { ans += num[i] * (n - num[i]); } cout << ans / 2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef int64_t ll; int main(int argc, char **argv) { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0), cout.precision(15); int n, m; cin >> n >> m; vector<int> cnt(m, 0); for (int i = 0; i < n; i++) { int ai; cin >> ai; cnt[ai - 1]++; } ll ans = 0; for (int i = 0; i < m; i++) { ans += cnt[i] * (n - cnt[i]); } ans /= 2; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; template <class X> void print_vector(const std::vector<X> &t); template <class X> void unique_vector(std::vector<X> &t); int n, m; int main() { cin >> n >> m; vector<int> books(n); vector<int> qua(m); for (auto &i : books) cin >> i; sort(books.begin(), books.end()); for (int i = 0; i < m; i++) { qua[i] = count(books.begin(), books.end(), i + 1); } int ans = 0; for (int i = 0; i < m; i++) { for (int j = i; j < m; j++) { if (i == j) continue; ans += qua[i] * qua[j]; } } cout << ans << endl; } template <class X> void unique_vector(std::vector<X> &t) { std::sort(t.begin(), t.end()); t.erase(std::unique(t.begin(), t.end()), t.end()); } template <class X> void print_vector(const std::vector<X> &t) { for (auto itr = t.begin(); itr != t.end(); itr++) { std::cout << *itr; if (itr != t.end() - 1) std::cout << ' '; } std::cout << std::endl; }
#include <bits/stdc++.h> using namespace std; int main() { int m, n, gen, cant = 0; cin >> n >> m; int genre[10] = {}; for (int i = 0; i < n; i++) { cin >> gen; genre[gen - 1]++; } for (int i = 0; i < m; i++) { for (int j = i + 1; j < m; j++) { cant += genre[i] * genre[j]; } } cout << cant; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, same = 0, arr[15] = {0}, x, temp; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> x; arr[x]++; } x = 1; for (int i = n; i > n - 2; i--) x *= i; x /= 2; for (int i = 1; i <= 10; i++) { temp = 1; if (arr[i] < 2) continue; for (int j = arr[i]; j > arr[i] - 2; j--) temp *= j; temp /= 2; x -= temp; } cout << x << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long i, j, k, l, m, n, s, a[1111111], b[1111111], c, cc, d, e, f, t; string p, r, q, w; map<long long, long long> x[333333], y, z; vector<long long> u, uu; int main() { cin >> n >> m; t = 111111111111111; for (i = 0; i < n; i++) { cin >> d; s += a[d]; a[d]++; } cout << n * (n - 1) / 2 - s; }
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int maxx = 105; int A[maxx]; int main() { int n, m; while (~scanf("%d%d", &n, &m)) { int a; memset(A, 0, sizeof(A)); for (int i = 0; i < n; i++) { scanf("%d", &a); A[a]++; } int ans = 0; int sum = 0; for (int i = 1; i <= m; i++) { sum += A[i]; ans += (n - sum) * A[i]; } printf("%d\n", ans); } }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, a, ans, count = 0, i, m, h[30] = {0}; cin >> n >> m; for (i = 0; i < n; i++) { cin >> a; h[a]++; } for (i = 0; i <= m; i++) { count += h[i] * (h[i] - 1) / 2; } ans = n * (n - 1) / 2 - count; cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); for (; c < '0' || c > '9'; c = getchar()) if (c == '-') f = -1; for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0'; return x * f; } int n, m; int a[15]; int main() { n = read(), m = read(); for (int i = (1); i <= (n); i++) { int x = read(); a[x]++; } int ans = 0; for (int i = (1); i <= (m); i++) for (int j = (i + 1); j <= (m); j++) { ans += a[i] * a[j]; } printf("%d\n", ans); }
#include <bits/stdc++.h> using namespace std; const int MaxM = 11; int n, m, c[MaxM]; int main() { int i, j, s; scanf("%d%d", &n, &m); for (i = 1; i <= n; i++) scanf("%d", &j), c[j]++; s = 0; for (i = 1; i <= m; i++) for (j = i + 1; j <= m; j++) s += c[i] * c[j]; printf("%d\n", s); return 0; }
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1e1 + 9; int tab[MAX_N]; int n, m; int main() { scanf("%d%d", &n, &m); int a; for (int i = 0; i < n; ++i) { scanf("%d", &a); ++tab[a]; } int sol = 0; for (int i = 1; i <= m; ++i) { for (int j = i + 1; j <= m; ++j) { sol += tab[i] * tab[j]; } } printf("%d", sol); return 0; }
#include <bits/stdc++.h> using namespace std; long long int x[200000], A[11]; int main() { long long int y, m, n; cin >> n >> m; y = ((n)*1ll * (n - 1)) / 2; for (long long int i = 0; i < m + 1; i++) A[i] = 0; for (long long int i = 0; i < n; i++) { cin >> x[i]; A[(x[i])]++; } for (int i = 1; i < m + 1; i++) if (A[i] > 1) y -= ((A[i]) * 1ll * (A[i] - 1)) / 2; cout << y << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = 2147483647; const int MAX = 5005; bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); } long long pow2(long long n) { long long x = 1; for (long long i = 1; i <= n; i++) x *= 2; return x; } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, x, p = 0, ans = 0; cin >> n >> x; vector<long long> v(x); for (long long i = 0; i < n; i++) { long long t; cin >> t; v[t - 1]++; } for (long long i = 0; i < x; i++) p += v[i]; for (long long i = 0; i < x; i++) { p -= v[i]; ans += v[i] * p; } cout << ans; }
#include <bits/stdc++.h> using namespace std; void solve() {} int main() { long long s; long long n, k; cin >> n >> k; long long a[n]; for (int i = 0; i < n; i++) cin >> a[i]; long long cnt[11]{0}; for (int i = 0; i < n; i++) cnt[a[i]]++; s = (n * (n - 1)) / 2; for (int i = 1; i <= k; i++) s -= (cnt[i] * (cnt[i] - 1)) / 2; cout << s << endl; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ; int n, m; cin >> n >> m; int mm[11] = {}; int i; int total = 0; for (i = 1; i <= n; i++) { int a; cin >> a; mm[a]++; total++; } long long ans = 0; for (i = 1; i <= m; i++) { ans += mm[i] * (total - mm[i]); } cout << ans / 2 << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; long long nc2(long long n) { return n * (n - 1) / 2; } int main() { long long n, m; cin >> n >> m; long long mp[11] = {0}; long long q; for (int i = 0; i < n; i++) { cin >> q; mp[q]++; } long long sum = 0; for (int i = 1; i <= 10; i++) { if (mp[i] > 1) sum += nc2(mp[i]); } cout << nc2(n) - sum << endl; }
#include <bits/stdc++.h> using namespace std; int cnt[20]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < (n); i++) { int x; scanf("%d", &x); cnt[x]++; } long long ans = (long long)n * (n - 1) / 2; for (int i = 1; i <= (m); i++) ans -= (long long)cnt[i] * (cnt[i] - 1) / 2; cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; const int MAX = 20; int n, m; int a[MAX]; int main() { cin >> n >> m; int x; memset(a, 0, sizeof(a)); for (int i = 0; i < n; i++) { cin >> x; a[x]++; } int ans = 0; for (int i = 1; i <= 10; i++) { if (a[i] == 0) { break; } for (int j = i + 1; j <= 10; j++) { if (a[j] == 0) { break; } ans += a[i] * a[j]; } } cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; const string LN = "\n"; const double eps = 1e-7; const double pi = acos(-1.0); const int INF = (int)1e9 + 7; const long long LINF = (long long)9e18 + 7; bool insert(int k, int x1, int x2) { return (k >= x1 && k <= x2); } long long n, m; long long a[12]; int main() { cin >> n >> m; for (int i = 0; i < n; i++) { long long z; cin >> z; a[z]++; } long long ans = 0; for (int i = 1; i <= 10; i++) { ans += a[i] * (n - a[i]); } cout << ans / 2; }
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int main() { long long f[N], cnt[12]; int n, m; long long ans = 0; memset(cnt, 0, sizeof(cnt)); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> f[i], cnt[f[i]]++; for (int i = 1; i <= m; i++) ans += (n - cnt[i]) * cnt[i]; cout << ans / 2 << endl; return 0; }
#include <bits/stdc++.h> int a[200200]; int n, m; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; ++i) { int x; scanf("%d", &x); ++a[x]; } int s = 0; for (int i = 1; i <= m; ++i) for (int j = i + 1; j <= m; ++j) s += a[i] * a[j]; printf("%d\n", s); return 0; }
#include <bits/stdc++.h> const int INF = 1e9; using namespace std; inline string gtStr() { char st[200]; scanf("%s", st); return st; } long long sum[1001]; int cnt[11]; int main() { int n, m, f; cin >> n >> m; for (int i = 0; i < n; i++) { scanf("%d", &f); cnt[f]++; } long long ans = 0; for (int i = 1; i <= 9; i++) { for (int j = i + 1; j <= 10; j++) { ans += 1LL * cnt[i] * cnt[j]; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int a[200010], b[20]; int main() { int n, m, i, j, sum = 0; scanf("%d%d", &n, &m); for (i = 1; i <= n; i++) { scanf("%d", &a[i]); } for (i = 1; i <= n; i++) { b[a[i]]++; } for (i = 1; i <= m - 1; i++) { for (j = i + 1; j <= m; j++) { sum += b[i] * b[j]; } } printf("%d\n", sum); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, C = 0, x; map<int, int> M; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> x; M[x]++; } for (map<int, int>::iterator it = M.begin(); it != M.end(); it++) { C += it->second * (n - it->second); n -= it->second; } cout << C; return 0; }
#include <bits/stdc++.h> using namespace std; int n, m; int cnt[11]; int main() { scanf("%d %d", &n, &m); for (int i = 0; i < n; i++) { int x; scanf("%d", &x); cnt[x]++; } long long ans = 0; for (int i = 1; i <= m; i++) ans += 1LL * cnt[i] * (n - cnt[i]); cout << ans / 2 << endl; }
#include <bits/stdc++.h> template <typename A, typename B> inline void umin(A &x, B y) { if (x > y) x = y; } template <typename A, typename B> inline void umax(A &x, B y) { if (x < y) x = y; } const int MAXN = 200005; using namespace std; int cnt[15]; int n, m, a, ans; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) { scanf("%d", &a); cnt[a]++; } for (int i = 1; i <= m; i++) for (int h = i + 1; h <= m; h++) ans += cnt[i] * cnt[h]; printf("%d", ans); }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n, m, mp[15] = {0}; cin >> n >> m; for (long long i = (0); i < (long long)(n); ++i) { int t; cin >> t; mp[t]++; } int res = 0; for (int i = 1; i < 11; i++) { for (int j = i + 1; j < 11; j++) { res += (mp[i] * mp[j]); } } printf("%d", res); ; return 0; }
#include <bits/stdc++.h> using namespace std; class TheBestGift { int numBook; int numGenres; int numResult; map<int, int> miiGenresNum; public: void initial(int, int); void input(); void compute(); void output(); }; void TheBestGift::initial(int g, int b) { numGenres = g, numBook = b, numResult = 0; miiGenresNum.clear(); } void TheBestGift::input() { int t; for (int i = 0; i < numBook; i++) { cin >> t; miiGenresNum[t]++; } } void TheBestGift::compute() { for (int i = 1; i <= numGenres; i++) { for (int j = i + 1; j <= numGenres; j++) { numResult += miiGenresNum[i] * miiGenresNum[j]; } } } void TheBestGift::output() { cout << numResult << endl; } int main() { int n, m; TheBestGift tbg; while (cin >> n) { cin >> m; tbg.initial(m, n); tbg.input(); tbg.compute(); tbg.output(); } return 0; }
#include <bits/stdc++.h> using namespace std; long long n, m, a[200111], c[200111], i, res = 0; int main() { memset(c, 0, sizeof c); cin >> n >> m; for (i = 0; i < n; i++) { cin >> a[i]; c[a[i]]++; } for (i = 0; i < n - 1; i++) { res += n - i - c[a[i]]; c[a[i]]--; } cout << res; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> genre(m, 0); for (int i = 0; i < n; i++) { int temp; cin >> temp; genre[temp - 1]++; } long long ans = 0; for (int i = 0; i < m; i++) for (int j = i + 1; j < m; j++) ans += genre[i] * genre[j]; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i, c = 0, s = 0, m, a[200010], v[200010]; cin >> n; cin >> m; for (i = 0; i < n; i++) { cin >> a[i]; v[a[i]]++; } for (i = 0; i < n - 1; i++) { v[a[i]] = v[a[i]] - 1; c += n - (i + 1) - v[a[i]]; } cout << c; return 0; }
#include <bits/stdc++.h> int N, M; int A[200000 + 5]; int Sum[200000 + 5][10 + 5]; int main() { scanf("%d%d", &N, &M); for (int i = 1; i <= N; i++) { scanf("%d", &A[i]); for (int j = 1; j <= M; j++) Sum[i][j] += Sum[i - 1][j]; Sum[i][A[i]]++; } int Ans = 0; for (int i = 1; i <= N; i++) Ans += N - i - Sum[N][A[i]] + Sum[i][A[i]]; printf("%d", Ans); }
#include <bits/stdc++.h> using namespace std; int ans, cnt[11], n, a; int main() { int m; cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> a; cnt[a]++; } for (int i = 1; i <= m; i++) { for (int j = i + 1; j <= m; j++) { ans += cnt[i] * cnt[j]; } } cout << ans; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a[m]; for (int i = 0; i < m; i++) { a[i] = 0; } for (int i = 0; i < n; i++) { int c; cin >> c; a[c - 1]++; } int res = 0; for (int i = 0; i < m - 1; i++) { for (int j = i + 1; j < m; j++) { res += a[i] * a[j]; } } cout << res; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, c; cin >> n >> m; long long i, ara[m + 2], books = (n * (n - 1)) / 2; memset(ara, 0, sizeof(ara)); for (i = 1; i <= n; i++) { cin >> c; ara[c]++; } for (i = 1; i <= m; i++) { long long x = ara[i]; long long bi = (x * (x - 1)) / 2; books = books - bi; } cout << books << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int a[11]; int n, m; while (cin >> n >> m) { memset(a, 0, sizeof(a)); int x; for (int i = 0; i < n; i++) { scanf("%d", &x); a[x]++; } int ans = 0; for (int i = 1; i < m; i++) { for (int j = i + 1; j <= m; j++) { ans = ans + a[i] * a[j]; } } cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int zhanr[10]; void solve() { unsigned long long sum = 0; int n, m, k; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> k; zhanr[k - 1]++; } for (int i = 0; i < m; i++) { for (int j = i + 1; j < m; j++) { sum += zhanr[j] * zhanr[i]; } } cout << sum; } int main() { int n = 1; while (n--) { solve(); } }
#include <bits/stdc++.h> using namespace std; int main(void) { long long n, m; cin >> n >> m; vector<long long> list(m + 1, 0); while (n--) { long long x; cin >> x; list[x]++; } long long comb = 0; for (int i = 1; i <= m; i++) { for (int j = i + 1; j <= m; j++) { comb += list[i] * list[j]; } } cout << comb << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { map<int, int> M; int n, m; int sum(0); int i(0); cin >> n >> m; while (n--) { int a; cin >> a; sum = sum + i - M[a]; M[a]++; i++; } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m, aux; cin >> n >> m; vector<int> v(m + 1); for (int i = 0; i < int(n); i++) { cin >> aux; v[aux]++; } long long int res = 0; for (int i = 1; i < m + 1; i++) { for (int j = i + 1; j < m + 1; j++) res += v[i] * v[j]; } cout << res << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; long long a[2000666]; long long fr[2000666]; int main() { long long n, m, i, result = 0, sum = 0; cin >> n >> m; for (i = 1; i <= n; ++i) { cin >> a[i]; ++fr[a[i]]; sum++; } result = (sum * (sum - 1)) / (long long)2; for (i = 1; i <= 10; ++i) result -= (fr[i] * (fr[i] - 1)) / (long long)2; cout << result << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int i, j, n, m, a[11] = {0}, t, s = 0; cin >> n >> m; for (i = 0; i < n; i++) { scanf("%d", &t); a[t]++; } for (i = 2; i < 11; i++) { for (j = i; j < 11; j++) s += a[i - 1] * a[j]; } printf("%d\n", s); }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, ans = 0, k = 1; scanf("%d%d", &n, &m); vector<int> v(n); for (int i = 0; i < n; i++) scanf("%d", &v[i]); sort(v.begin(), v.end()); for (int i = 0; i < n - 1; i++) if (v[i] != v[i + 1]) { ans += (n - i - 1) * k; k = 1; } else k++; printf("%d", ans); return 0; }
#include <bits/stdc++.h> using namespace std; long long n, sum, ans; int m, a[20], x; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) { scanf("%d", &x); x--; a[x]++; } for (int i = 0; i < m; i++) { if (a[i] != 0) { for (int j = i + 1; j < m; j++) { sum += a[i] * a[j]; } } } printf("%ld\n", sum); return 0; }
#include <bits/stdc++.h> using namespace std; const long long inf = 1e18; const long long cs = 200005; const long long mod = 1000000007; const double PI = 2 * acos(0.0); void solve() { long long int t, n, m, a, b, c, d, e, i, j, k, x, y, z, cnt = 0, cnt1 = 0; bool flag = false; cin >> n >> m; vector<long long> v(n); for (auto &ss : v) cin >> ss; sort(v.begin(), v.end()); vector<long long>::iterator upp, low; low = lower_bound(v.begin(), v.end(), v[n - 1]); x = distance(v.begin(), low); for (i = 0; i < x; i++) { upp = upper_bound(v.begin(), v.end(), v[i]); cnt += (v.end() - upp); } cout << cnt << '\n'; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 110; int cnt[maxn]; int main() { int n, m, x; scanf("%d %d", &n, &m); for (int i = 1; i <= n; ++i) { scanf("%d", &x); cnt[x]++; } int ans = 0; for (int i = 1; i <= m; ++i) { for (int j = i + 1; j <= m; ++j) { ans += cnt[i] * cnt[j]; } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, m, i, j, k, q, s, w, v, ans; int a[11]; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) { int x; cin >> x; a[x]++; } for (i = 1; i <= 10; i++) for (j = i + 1; j <= 10; j++) ans += a[i] * a[j]; cout << ans << endl; return 0; }
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") constexpr long long INF = 1LL << 60; constexpr long double PI = 3.141592653589; using namespace std; template <typename T = long long> using vec = vector<T>; template <typename T = long long> using vec2 = vector<vector<T>>; template <typename T = long long> using vec3 = vector<vector<vector<T>>>; template <typename T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <typename T> inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } namespace snow { struct IoSetup { IoSetup() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(10); } } iosetup; } // namespace snow template <typename T1, typename T2> std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &p) { os << p.first << " " << p.second; return os; } template <typename T1, typename T2> std::istream &operator>>(std::istream &is, std::pair<T1, T2> &p) { is >> p.first >> p.second; return is; } template <typename T1, typename T2, typename T3> std::ostream &operator<<(std::ostream &os, const std::tuple<T1, T2, T3> &t) { auto &[a, b, c] = t; os << a << " " << b << " " << c; return os; } template <typename T1, typename T2, typename T3> std::istream &operator>>(std::istream &is, std::tuple<T1, T2, T3> &t) { auto &[a, b, c] = t; is >> a >> b >> c; return is; } template <typename T> std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) { for (int i = 0; i < (int)v.size(); ++i) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } template <typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &in : v) is >> in; return is; } template <typename T> std::ostream &operator<<(std::ostream &os, const std::set<T> &st) { int ct = 0; for (auto &s : st) os << s << (++ct != (int)st.size() ? " " : ""); return os; } template <class... T> void input(T &...a) { (std::cin >> ... >> a); } void print() { std::cout << '\n'; } template <class T, class... Ts> void print(const T &a, const Ts &...b) { std::cout << a; (std::cout << ... << (std::cout << ' ', b)); std::cout << '\n'; } int drop() { std::cout << '\n'; exit(0); } template <class T, class... Ts> int drop(const T &a, const Ts &...b) { std::cout << a; (std::cout << ... << (std::cout << ' ', b)); std::cout << '\n'; exit(0); } using namespace snow; int main() { long long N, M; cin >> N >> M; vec<> A(N); cin >> A; map<int, int> mp; for (auto a : A) mp[a]++; long long ans = 0; for (long long i = 1; i <= (M); ++i) for (long long j = 1; j <= (M); ++j) if (i < j) { ans += mp[i] * mp[j]; } print(ans); return 0; }
#include <bits/stdc++.h> using namespace std; template <class A, class B> ostream& operator<<(ostream& output, const pair<A, B>& p) { output << "(" << p.first << ", " << p.second << ")"; return output; } template <class A> ostream& operator<<(ostream& output, const vector<A>& a) { output << "["; for (auto it = a.begin(); it != a.end(); ++it) { if (it != a.begin()) { output << ", "; } output << *it; } output << "]"; return output; } using lld = long long; using pii = pair<int, int>; using pll = pair<lld, lld>; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; vector<int> genre(n); unordered_map<int, int> next, done; for (int i = 0; i < n; ++i) { cin >> genre[i]; next[genre[i]]++; } int ans = 0; for (int i = 0; i < n; ++i) { done[genre[i]]++; ans += n - (i + 1) - (next[genre[i]] - done[genre[i]]); } cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; long long int inline ipow(long long int a, long long int b, long long int m) { long long int val = 1; a %= m; while (b) { if (b & 01) val = (val * a) % m; b >>= 1; a = (a * a) % m; }; return val % m; } long long int inline ipow(long long int a, long long int b) { long long int val = 1; while (b) { if (b & 01) val = (val * a); b >>= 1; a = (a * a); }; return val; } int cnts[11]; int main() { std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); clock_t tStart = clock(); long long int i, x, n, m, ans = 0; cin >> n >> m; for (i = 1; i <= n; i++) { cin >> x; cnts[x]++; } for (i = 1; i <= m; i++) ans += (n - cnts[i]) * cnts[i]; cout << ans / 2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long n, s = 0, d1, d = 0; long long m, num; cin >> n >> m; long long a[m]; for (long long i = 0; i < m; i++) a[i] = 0; for (long long i = 0; i < n; i++) { cin >> num; a[num - 1]++; } for (long long i = 0; i < m; i++) { for (long long j = i + 1; j < m; j++) { s += a[i] * a[j]; } } cout << s << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int n, m, cnt[300000 + 10]; int main() { scanf("%d%d", &n, &m); memset(cnt, 0, sizeof cnt); for (int i = 1; i <= n; i++) { int x; scanf("%d", &x); cnt[x]++; } long long ret = 0; for (int i = 1; i <= m; i++) for (int j = i + 1; j <= m; j++) { ret += 1ll * cnt[i] * cnt[j]; } cout << ret << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long a[10005], n, m; int main() { long long ans = 0; cin >> n >> m; int q; for (int i = 1; i <= n; i++) { cin >> q; a[q]++; } for (int i = 1; i <= m; i++) { for (int j = i + 1; j <= m; j++) { ans = ans + a[i] * a[j]; } } cout << ans; }
#include <bits/stdc++.h> using namespace std; long long int n, m, ans, ind; long long int arr[1000006]; long long int sum[1000006]; int main() { ios_base::sync_with_stdio(false); cin >> n >> m; for (int i = 0; i < n; i++) { cin >> ind; arr[ind - 1]++; } sum[m - 1] = arr[m - 1]; for (int j = m - 2; j >= 0; j--) sum[j] = arr[j] + sum[j + 1]; for (int i = 0; i < m - 1; i++) ans += arr[i] * sum[i + 1]; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const unsigned long long BIGEST = 1000000000000000000 + 1000000000000000000; const long long BIGER = 1000000000000000000; const int BIG = 1000000000; const long long MOD = 19961993; const long long LMOD = 1000000007; long long a[200005]; int main() { long long n, m; scanf("%I64d%I64d", &n, &m); long long t = 0; long long s = n * (n - 1) / 2; for (long long i = 1; i <= n; i++) { scanf("%I64d", &t); a[t]++; } for (long long i = 1; i <= m; i++) { s -= a[i] * (a[i] - 1) / 2; } cout << s; return 0; }
#include <bits/stdc++.h> using namespace std; const long double E = 2.71828182845904523536; const long double pi = acos(-1); const double eps = 1e-9; const long long mod = 1e9 + 7; const long long inf = 1LL << 30; const int N = 100100; int frq[22]; int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) { int x; scanf("%d", &x); frq[x]++; } int ans = 0, sum = n; for (int i = 1; i <= m; i++) { sum -= frq[i]; ans += (frq[i] * sum); } printf("%d", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { cout << "25" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long a; cin >> a; cout << 25; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { cout << 25; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; cout << 25 << endl; return 0; }
#include <bits/stdc++.h> int main() { long long int n, p; scanf("%I64d", &n); printf("25\n"); }
#include <bits/stdc++.h> using namespace std; int main() { long n, s = 1; cin >> n; cout << 25; return 0; }
#include <bits/stdc++.h> using namespace std; int32_t main() { long long int n; cin >> n; cout << "25"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, p[10], i = 0; cin >> n; if (n == 2) { cout << 25; } else cout << 25; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << "25"; }
#include <bits/stdc++.h> using namespace std; int main() { int in, ans = 25; cin >> in; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { cout << "25"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; printf("25"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { cout << 25 << endl; return 0; }
#include <bits/stdc++.h> int main() { std::cout << "25\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, ans; cin >> n; cout << 25 << endl; }
#include <bits/stdc++.h> using namespace std; int k, asdasjkd, adsnamsd, a[210001], q, m, mna, mnb, b[101], us[101]; long long ans; long long n; vector<int> v; int main() { int t24 = 1; for (int qwe = 1; qwe <= t24; qwe++) { int n, k, m; cout << 25; } return 0; }
#include <bits/stdc++.h> void fast(); void file(); void error(); using namespace std; int main() { fast(); file(); long long int n; cin >> n; cout << 25 << endl; error(); return 0; } void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } void file() {} void error() { cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; }
#include <bits/stdc++.h> using namespace std; template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c* x) -> decltype(cerr << *x, 0); template <class c> char dud(...); struct debug { ~debug() { cerr << endl; } template <class c> typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) { cerr << boolalpha << i; return *this; } template <class c> typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) { return *this << range(begin(i), end(i)); } template <class c, class b> debug& operator<<(pair<b, c> d) { return *this << "(" << d.first << ", " << d.second << ")"; } template <class c> debug& operator<<(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; return *this << "]"; } }; template <typename... T> void read(T&... args) { ((cin >> args), ...); } template <typename... T> void write(T... args) { ((cout << args << " "), ...); } void testcase() { long long int n; read(n); cout << 25 << endl; } int main() { testcase(); return 0; }
#include <bits/stdc++.h> using namespace std; using d = int; using ll = long long; using ud = unsigned int; using ull = unsigned long long; using lf = double; using llf = long double; using ch = char; using st = string; using bl = bool; using vo = void; vo InputOutput() {} ll AscendingOfDigits(ll num) { d digit[10] = {}; while (num != 0) { digit[num % 10]++; num /= 10; } for (d i = 9; i >= 0; i--) { for (d j = 1; j <= digit[i]; j++) num = (num * 10) + i; } return num; } ll BigMod(ll B, ll P, ll M) { ll ans = 1; B %= M; while (P != 0) { if (P % 2) ans = (ans * B) % M; B = (B * B) % M; P /= 2; } return ans; } ll Combination(ll N, ll R) { ll ans; if (N == R) return 1; if (R > (N / 2)) R = N - R; ans = N--; for (ll i = 2; i <= R; i++, N--) { ans *= N; ans /= i; } return ans; } ll DescendingOfDigits(ll num) { d digit[10] = {}; while (num != 0) { digit[num % 10]++; num /= 10; } for (d i = 0; i <= 9; i++) { for (d j = 1; j <= digit[i]; j++) num = (num * 10) + i; } return num; } ll GCD(ll num1, ll num2) { ll temp; while (num2 != 0) { temp = num2; num2 = num1 % num2; num1 = temp; } return num1; } d IsPrime(d num) { if (num <= 2) return 0; if (num % 2 == 0) return 0; else { for (d i = 3; i * i <= num; i += 2) { if (num % i == 0) return 0; } return 1; } } ll LengthOfLCSubstring(st a, st b) { ll len1, len2, mx = 0; len1 = a.size(); len2 = b.size(); ll table[len1 + 1][len2 + 1]; memset(table, 0, sizeof table); for (ll i = 1; i <= len1; i++) { for (ll j = 1; j <= len2; j++) { if (a[i - 1] == b[j - 1]) table[i][j] = table[i - 1][j - 1] + 1; else table[i][j] = 0; if (table[i][j] > mx) mx = table[i][j]; } } return mx; } bl check[100000]; vector<d> prime; void Sieve(d number) { d i, j; check[0] = check[1] = 1; for (i = 2; i * i <= number; i++) { if (check[i] == 0) { for (j = i * i; j <= number; j += i) check[j] = 1; } } for (i = 2; i <= number; i++) { if (check[i] == 0) prime.push_back(i); } } bl SortBySecDes(const pair<ll, ll> &a, const pair<ll, ll> &b) { return (a.second > b.second); } bl SortBySecAsc(const pair<ll, ll> &a, const pair<ll, ll> &b) { return (a.second < b.second); } ll SumOfDigits(ll num) { ll sum = 0; while (num != 0) { sum += num % 10; num /= 10; } return sum; } void solve() { ll n, ans; cin >> n; ans = BigMod(5, n, 100); cout << ans << endl; } d main() { InputOutput(); d t = 1; while (t--) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 1) cout << 5; else cout << 25; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; cout << "25" << endl; return 0; }
#include <bits/stdc++.h> int main() { std::cout << "25\n"; return 0; }
#include <bits/stdc++.h> int main() { std::cout << "25\n"; return 0; }
#include <bits/stdc++.h> using namespace std; long long n, a = 1, t, b, m, ans, i, j; int main() { cin >> n; cout << 25 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << 25 << endl; return 0; }
#include <bits/stdc++.h> int main() { std::cout << "25" << std::endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long p; cin >> p; cout << "25\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n <= 1) cout << "your answer is terrible!"; else cout << 25; }