Datasets:

problem_id
stringlengths
6
6
buggy_code
stringlengths
8
526k
fixed_code
stringlengths
12
526k
labels
listlengths
0
15
buggy_submission_id
int64
1
1.54M
fixed_submission_id
int64
2
1.54M
user_id
stringlengths
10
10
language
stringclasses
9 values
p02947
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define MOD (1000000007); int main() { int n; cin >> n; unordered_map<string, int> m; for (int i = 0; i < n; i++) { string s; cin >> s; sort(s.begin(), s.end()); m[s]++; } ll ans = 0; for (auto x : m) { ll buf = (x.second * (x.second - 1)) / 2; ans += buf; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define MOD (1000000007); int main() { ll n; cin >> n; unordered_map<string, ll> m; for (ll i = 0; i < n; i++) { string s; cin >> s; sort(s.begin(), s.end()); m[s]++; } ll ans = 0; for (auto x : m) { ll buf = (x.second * (x.second - 1)) / 2; ans += buf; } cout << ans << endl; return 0; }
[ "variable_declaration.type.change", "control_flow.loop.for.initializer.change" ]
749,578
749,579
u493491082
cpp
p02947
#include <bits/stdc++.h> using namespace std; string s[100001]; int n, cnt = 1, ans; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; ++i) cin >> s[i], sort(s[i].begin(), s[i].end()); sort(s, s + n); // for (int i=0;i<n;++i) cout<<s[i]<<endl; for (int i = 1; i < n; ++i) { if (s[i] == s[i - 1]) { ++cnt; continue; } ans = ans + cnt * (cnt - 1) / 2; cnt = 1; } ans = ans + cnt * (cnt - 1) / 2; cout << ans; return 0; }
#include <bits/stdc++.h> #define ll long long using namespace std; string s[100001]; ll n, cnt = 1, ans; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; ++i) cin >> s[i], sort(s[i].begin(), s[i].end()); sort(s, s + n); // for (int i=0;i<n;++i) cout<<s[i]<<endl; for (int i = 1; i < n; ++i) { if (s[i] == s[i - 1]) { ++cnt; continue; } ans = ans + cnt * (cnt - 1) / 2; cnt = 1; } ans = ans + cnt * (cnt - 1) / 2; cout << ans; return 0; }
[ "variable_declaration.type.change" ]
749,580
749,581
u878056971
cpp
p02947
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k = 0, l, n, m; cin >> m; string s[m]; for (i = 0; i < m; i++) { cin >> s[i]; sort(s[i].begin(), s[i].end()); } map<string, int> mymap; for (i = 0; i < m; i++) { if (mymap.find(s[i]) == mymap.end()) { // initialize it explicitly mymap[s[i]] = 1; } else { // it has a value, now you can use it, increment it, whatever mymap[s[i]]++; } } map<string, int>::iterator itr; for (itr = mymap.begin(); itr != mymap.end(); itr++) { j = itr->second; k = k + ((j) * (j - 1)) / 2; } cout << k; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, k = 0, l, n, m; cin >> m; string s[m]; for (i = 0; i < m; i++) { cin >> s[i]; sort(s[i].begin(), s[i].end()); } map<string, long long> mymap; for (i = 0; i < m; i++) { if (mymap.find(s[i]) == mymap.end()) { // initialize it explicitly mymap[s[i]] = 1; } else { // it has a value, now you can use it, increment it, whatever mymap[s[i]]++; } } map<string, long long>::iterator itr; for (itr = mymap.begin(); itr != mymap.end(); itr++) { j = itr->second; k = k + ((j) * (j - 1)) / 2; } cout << k; return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
749,582
749,583
u390437117
cpp
p02947
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<string> s(N); for (int i = 0; i < N; i++) { cin >> s[i]; sort(s[i].begin(), s[i].end()); } sort(s.begin(), s.end()); int num = 1; long ans = 0; for (int i = 1; i < N; i++) { if (s[i] == s[i - 1]) num++; else { if (num > 1) ans += num * (num - 1) / 2; num = 1; } } if (num > 1) ans += num * (num - 1) / 2; cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<string> s(N); for (int i = 0; i < N; i++) { cin >> s[i]; sort(s[i].begin(), s[i].end()); } sort(s.begin(), s.end()); long num = 1; long ans = 0; for (int i = 1; i < N; i++) { if (s[i] == s[i - 1]) num++; else { if (num > 1) ans += num * (num - 1) / 2; num = 1; } } if (num > 1) ans += num * (num - 1) / 2; cout << ans << endl; }
[ "variable_declaration.type.primitive.change" ]
749,584
749,585
u689245321
cpp
p02947
#include <bits/stdc++.h> using namespace std; long long ans; char c[100010][13]; vector<string> v; int main() { int n; string tmp; cin >> n; for (int i = 1; i <= n; i++) { cin >> c[i]; sort(c[i], c[i] + 10); for (int j = 0; j < 10; j++) { tmp.append(1, c[i][j]); } // cout<<tmp<<endl; v.push_back(tmp); tmp = ""; } int t = 1; sort(v.begin(), v.end()); // for(int i=0;i<n;i++) // cout<<v[i]<<endl; for (int i = 1; i < n; i++) { if (v[i] == v[i - 1]) { t++; } else { ans += (t * (t - 1)) / 2; t = 1; } } ans += ((t * (t - 1)) / 2); cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; unsigned long long ans; char c[100010][13]; vector<string> v; int main() { int n; string tmp; cin >> n; for (int i = 1; i <= n; i++) { cin >> c[i]; sort(c[i], c[i] + 10); for (int j = 0; j < 10; j++) { tmp.append(1, c[i][j]); } // cout<<tmp<<endl; v.push_back(tmp); tmp = ""; } unsigned long long t = 1; sort(v.begin(), v.end()); // for(int i=0;i<n;i++) // cout<<v[i]<<endl; for (int i = 1; i < n; i++) { if (v[i] == v[i - 1]) { t++; } else { ans += (t * (t - 1)) / 2; t = 1; } } ans += ((t * (t - 1)) / 2); cout << ans; return 0; }
[ "variable_declaration.type.widen.change", "variable_declaration.type.primitive.change" ]
749,586
749,587
u866828359
cpp
p02947
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; } vector<vector<char>> ss(n, vector<char>(10)); for (int i = 0; i < n; i++) { for (int j = 0; j < 10; j++) { ss[i][j] = s[i][j]; } sort(ss[i].begin(), ss[i].end()); for (int j = 0; j < 10; j++) { s[i][j] = ss[i][j]; } } sort(s.begin(), s.end()); int a = 0; ll ans = 0; for (int i = 1; i < n; i++) { if (s[i] == s[i - 1]) { a++; if (i == n - 1) { ans += a * (a + 1) / 2; } } else if (a > 0) { ans += a * (a + 1) / 2; a = 0; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; } vector<vector<char>> ss(n, vector<char>(10)); for (int i = 0; i < n; i++) { for (int j = 0; j < 10; j++) { ss[i][j] = s[i][j]; } sort(ss[i].begin(), ss[i].end()); for (int j = 0; j < 10; j++) { s[i][j] = ss[i][j]; } } sort(s.begin(), s.end()); ll a = 0; ll ans = 0; for (int i = 1; i < n; i++) { if (s[i] == s[i - 1]) { a++; if (i == n - 1) { ans += a * (a + 1) / 2; } } else if (a > 0) { ans += a * (a + 1) / 2; a = 0; } } cout << ans << endl; }
[ "variable_declaration.type.change" ]
749,590
749,591
u794565416
cpp
p02947
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll MOD = 1000000007; int main() { int N; cin >> N; vector<string> v; for (int i = 0; i < N; i++) { string S; cin >> S; sort(S.begin(), S.end()); v.push_back(S); } sort(v.begin(), v.end()); ll ans = 0; int tmp = 1; for (int i = 1; i < N; i++) { if (v[i] == v[i - 1]) { tmp++; } else { ans += (((tmp) * (tmp - 1)) / 2); tmp = 1; } } ans += (((tmp) * (tmp - 1)) / 2); cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll MOD = 1000000007; int main() { int N; cin >> N; vector<string> v; for (int i = 0; i < N; i++) { string S; cin >> S; sort(S.begin(), S.end()); v.push_back(S); } sort(v.begin(), v.end()); ll ans = 0; ll tmp = 1; for (int i = 1; i < N; i++) { if (v[i] == v[i - 1]) { tmp++; } else { ans += (((tmp) * (tmp - 1)) / 2); tmp = 1; } } ans += (((tmp) * (tmp - 1)) / 2); cout << ans << "\n"; return 0; }
[ "variable_declaration.type.change" ]
749,592
749,593
u872581897
cpp
p02947
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { const int MAX_N = 1e3 + 10; int N; string S[MAX_N]; cin >> N; for (int i = 0; i < N; ++i) { string s; cin >> s; int a[10]; for (int j = 0; j < 10; ++j) { a[j] = s[j] - 0; } sort(a, a + 10); for (int j = 0; j < 10; ++j) { s[j] = a[j]; } S[i] = s; } sort(S, S + N); long long ans = 0; long long sum = 1; string n, p = S[0]; for (int i = 1; i < N; ++i) { n = S[i]; if (p == n) { sum += 1; } else { ans += sum * (sum - 1) / 2; sum = 1; } p = n; } ans += sum * (sum - 1) / 2; cout << ans << endl; }
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { const int MAX_N = 1e5 + 10; int N; string S[MAX_N]; cin >> N; for (int i = 0; i < N; ++i) { string s; cin >> s; int a[10]; for (int j = 0; j < 10; ++j) { a[j] = s[j] - 0; } sort(a, a + 10); for (int j = 0; j < 10; ++j) { s[j] = a[j]; } S[i] = s; } sort(S, S + N); long long ans = 0; long long sum = 1; string n, p = S[0]; for (int i = 1; i < N; ++i) { n = S[i]; if (p == n) { sum += 1; } else { ans += sum * (sum - 1) / 2; sum = 1; } p = n; } ans += sum * (sum - 1) / 2; cout << ans << endl; }
[ "literal.number.change", "expression.operation.binary.change" ]
749,594
749,595
u128142352
cpp
p02947
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mod = 1e9 + 7; const int maxn = 1e5 + 10; string s[maxn]; int m, n; map<string, int> ma; int main() { std::ios::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> s[i]; sort(s[i].begin(), s[i].end()); } int ans = 0; for (int i = 0; i < n; i++) { // cout<<s[i]<<endl; ans += ma[s[i]]; ma[s[i]]++; } cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mod = 1e9 + 7; const int maxn = 1e5 + 10; string s[maxn]; int m, n; map<string, int> ma; int main() { std::ios::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> s[i]; sort(s[i].begin(), s[i].end()); } ll ans = 0; for (int i = 0; i < n; i++) { // cout<<s[i]<<endl; ans += ma[s[i]]; ma[s[i]]++; } cout << ans << '\n'; return 0; }
[ "variable_declaration.type.change" ]
749,596
749,597
u914135866
cpp
p02947
#include <bits/stdc++.h> #include <iostream> #include <string> #define foreach(c, itr) \ for (__typeof((c).begin(), (c).end()) itr = c.begin(); itr != c.end(); itr++) using namespace std; int main() { int n; cin >> n; map<string, int> mp; for (int i = 0; i < n; i++) { char buf[10]; scanf("%s", buf); sort(buf, buf + 10); mp[buf]++; } int ans = 0; foreach (mp, itr) { if (itr->second != 0) { ans += itr->second * (itr->second - 1) / 2; } } cout << ans; return 0; }
#include <bits/stdc++.h> #include <iostream> #include <string> #define foreach(c, itr) \ for (__typeof((c).begin(), (c).end()) itr = c.begin(); itr != c.end(); itr++) using namespace std; int main() { int n; cin >> n; map<string, long long> mp; for (int i = 0; i < n; i++) { char buf[10]; scanf("%s", buf); sort(buf, buf + 10); mp[buf]++; } long long ans = 0; foreach (mp, itr) { if (itr->second != 0) { ans += itr->second * (itr->second - 1) / 2; } } cout << ans; return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
749,598
749,599
u811897616
cpp
p02947
#include <bits/stdc++.h> using namespace std; char s[11]; string ss[200001]; bool issame(string a, string b) { for (int i = 1; i <= 10; ++i) { if (a[i] != b[i]) return false; } return true; } int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%s", s + 1); sort(s + 1, s + 1 + 10); for (int j = 1; j <= 10; ++j) ss[i] += s[j]; } sort(ss + 1, ss + 1 + n); long long tmp = 0; long long ans = 0; for (int i = 1; i < n; ++i) { if (issame(ss[i], ss[i + 1])) { tmp++; for (int j = i + 1; j < n; ++j) { i = j; if (issame(ss[j], ss[j + 1])) tmp++; else break; } ans += tmp * (tmp + 1) / 2; // cout<<i<<" "<<tmp<<endl; tmp = 0; } } printf("%lld\n", ans); }
#include <bits/stdc++.h> using namespace std; char s[11]; string ss[200001]; bool issame(string a, string b) { for (int i = 0; i < 10; ++i) { if (a[i] != b[i]) return false; } return true; } int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%s", s + 1); sort(s + 1, s + 1 + 10); for (int j = 1; j <= 10; ++j) ss[i] += s[j]; } sort(ss + 1, ss + 1 + n); long long tmp = 0; long long ans = 0; for (int i = 1; i < n; ++i) { if (issame(ss[i], ss[i + 1])) { tmp++; for (int j = i + 1; j < n; ++j) { i = j; if (issame(ss[j], ss[j + 1])) tmp++; else break; } ans += tmp * (tmp + 1) / 2; // cout<<i<<" "<<tmp<<endl; tmp = 0; } } printf("%lld\n", ans); }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
749,600
749,601
u910114570
cpp
p02947
#include <bits/stdc++.h> using namespace std; char s[11]; string ss[200001]; bool issame(string a, string b) { for (int i = 1; i <= 10; ++i) { if (a[i] != b[i]) return false; } return true; } int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%s", s + 1); sort(s + 1, s + 1 + 10); for (int j = 1; j <= 10; ++j) ss[i] += s[j]; } sort(ss + 1, ss + 1 + n); long long tmp = 0; long long ans = 0; for (int i = 1; i <= n; ++i) { if (issame(ss[i], ss[i + 1])) { tmp++; for (int j = i + 1; j <= n; ++j) { i = j; if (issame(ss[j], ss[j + 1])) tmp++; else break; } ans += tmp * (tmp + 1) / 2; // cout<<tmp<<" "<<i<<endl; tmp = 0; } } printf("%lld\n", ans); }
#include <bits/stdc++.h> using namespace std; char s[11]; string ss[200001]; bool issame(string a, string b) { for (int i = 0; i < 10; ++i) { if (a[i] != b[i]) return false; } return true; } int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%s", s + 1); sort(s + 1, s + 1 + 10); for (int j = 1; j <= 10; ++j) ss[i] += s[j]; } sort(ss + 1, ss + 1 + n); long long tmp = 0; long long ans = 0; for (int i = 1; i < n; ++i) { if (issame(ss[i], ss[i + 1])) { tmp++; for (int j = i + 1; j < n; ++j) { i = j; if (issame(ss[j], ss[j + 1])) tmp++; else break; } ans += tmp * (tmp + 1) / 2; // cout<<i<<" "<<tmp<<endl; tmp = 0; } } printf("%lld\n", ans); }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "control_flow.branch.if.condition.change" ]
749,602
749,601
u910114570
cpp
p02947
#include <algorithm> #include <cctype> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <set> #include <string> #define ll long long #define il inline #define rgi register int using namespace std; const int N = 100000 + 10; int n, cnt, ans; set<string> s; map<string, int> vis; il int read() { rgi x = 0, f = 0, ch; while (!isdigit(ch = getchar())) f |= ch == '-'; while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar(); return f ? -x : x; } int main() { int n = read(); for (rgi i = 1; i <= n; ++i) { string str; cin >> str; sort(str.begin(), str.end()); s.insert(str); vis[str]++; } for (set<string>::iterator it = s.begin(); it != s.end(); ++it) ans += vis[*it] * (vis[*it] - 1) / 2; printf("%d", ans); return 0; }
#include <algorithm> #include <cctype> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <set> #include <string> #define ll long long #define il inline #define rgi register ll using namespace std; const int N = 100000 + 10; ll n, cnt, ans; set<string> s; map<string, ll> vis; il ll read() { rgi x = 0, f = 0, ch; while (!isdigit(ch = getchar())) f |= ch == '-'; while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar(); return f ? -x : x; } int main() { n = read(); for (rgi i = 1; i <= n; ++i) { string str; cin >> str; sort(str.begin(), str.end()); s.insert(str); vis[str]++; } for (set<string>::iterator it = s.begin(); it != s.end(); ++it) ans += vis[*it] * (vis[*it] - 1) / 2; printf("%lld", ans); return 0; }
[ "preprocessor.define.value.change", "variable_declaration.type.change", "identifier.change", "literal.string.change", "call.arguments.change", "io.output.change" ]
749,603
749,604
u469810874
cpp
p02947
#include <bits/stdc++.h> using namespace std; int main() { map<string, int> m; int n, sum = 0; cin >> n; while (n--) { char a[11]; string s1; cin >> a; sort(a, a + 10); for (int i = 0; i < 10; i++) { s1 += a[i]; } m[s1]++; } map<string, int>::iterator it; for (it = m.begin(); it != m.end(); it++) { for (int i = 1; i <= it->second - 1; i++) { sum += i; } } printf("%d\n", sum); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { map<string, int> m; long long n, sum = 0; cin >> n; while (n--) { char a[11]; string s1; cin >> a; sort(a, a + 10); for (int i = 0; i < 10; i++) { s1 += a[i]; } m[s1]++; } map<string, int>::iterator it; for (it = m.begin(); it != m.end(); it++) { for (int i = 1; i <= it->second - 1; i++) { sum += i; } } printf("%lld\n", sum); return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change", "literal.string.change", "call.arguments.change", "io.output.change" ]
749,605
749,606
u333991119
cpp
p02947
#include <algorithm> #include <iostream> #include <string> using namespace std; int N_MAX = 100000; int main() { int n, i, j, t; long long res = 0; string s[N_MAX]; cin >> n; for (i = 0; i < n; i++) { cin >> s[i]; sort(s[i].begin(), s[i].end()); } sort(s, s + n); for (i = 1, j = 0; i < n; i++) if (s[i] != s[i - 1]) { t = i - j; res += t * (t - 1) / 2; j = i; } t = n - j; res += t * (t - 1) / 2; cout << res << endl; return 0; }
#include <algorithm> #include <iostream> #include <string> using namespace std; int N_MAX = 100000; int main() { int n, i, j; long long t, res = 0; string s[N_MAX]; cin >> n; for (i = 0; i < n; i++) { cin >> s[i]; sort(s[i].begin(), s[i].end()); } sort(s, s + n); for (i = 1, j = 0; i < n; i++) if (s[i] != s[i - 1]) { t = i - j; res += t * (t - 1) / 2; j = i; } t = n - j; res += t * (t - 1) / 2; cout << res << endl; return 0; }
[ "variable_declaration.remove", "variable_declaration.add" ]
749,610
749,611
u784283302
cpp
p02947
#include <algorithm> #include <cmath> #include <iostream> #include <limits.h> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, m, n) for (int i = m; i < n; i++) #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() #define check(v) \ rep(i, v.size()) cout << v[i] << " "; \ cout << endl #define INF 1e8 typedef long long ll; using namespace std; //オーバーフローに気をつけろよおおおおおお //確認忘れるなよおおおおおお ll siguma(int a) { int ans = 0; for (int i = 1; i < a; i++) { ans += i; } return ans; } int main() { int n; cin >> n; map<string, int> m; ll ans = 0; rep(i, n) { string s; cin >> s; sort(s.begin(), s.end()); m[s]++; } for (auto a : m) { ans += siguma(a.second); } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <limits.h> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, m, n) for (int i = m; i < n; i++) #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() #define check(v) \ rep(i, v.size()) cout << v[i] << " "; \ cout << endl #define INF 1e8 typedef long long ll; using namespace std; //オーバーフローに気をつけろよおおおおおお //確認忘れるなよおおおおおお ll siguma(int a) { ll ans = 0; for (int i = 1; i < a; i++) { ans += i; } return ans; } int main() { int n; cin >> n; map<string, int> m; ll ans = 0; rep(i, n) { string s; cin >> s; sort(s.begin(), s.end()); m[s]++; } for (auto a : m) { ans += siguma(a.second); } cout << ans << endl; return 0; }
[ "variable_declaration.type.change" ]
749,615
749,616
u008582165
cpp
p02947
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; vector<char> vc; for (size_t j = 0; j < 10; j++) { vc.push_back(s[i][j]); } sort(vc.begin(), vc.end()); s[i] = string(vc.begin(), vc.end()); // cout<<s[i]<<endl; } sort(s.begin(), s.end()); long long o = 0; int c = 1; for (int i = 1; i < n; i++) { if (s[i - 1] == s[i]) { c++; } else { o += c * (c - 1) / 2; c = 1; } } o += c * (c - 1) / 2; cout << o << endl; return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; vector<char> vc; for (size_t j = 0; j < 10; j++) { vc.push_back(s[i][j]); } sort(vc.begin(), vc.end()); s[i] = string(vc.begin(), vc.end()); // cout<<s[i]<<endl; } sort(s.begin(), s.end()); long long o = 0; long c = 1; for (int i = 1; i < n; i++) { if (s[i - 1] == s[i]) { c++; } else { o += c * (c - 1) / 2; c = 1; } } o += c * (c - 1) / 2; cout << o << endl; return 0; }
[ "variable_declaration.type.primitive.change" ]
749,617
749,618
u737252485
cpp
p02947
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<string> S(N); for (int i = 0; i < N; i++) { string tmp; cin >> tmp; sort(tmp.begin(), tmp.end()); S[i] = tmp; } sort(S.begin(), S.end()); S.push_back(""); long long ans = 0; string tmp = S[0]; int term = 1; for (int i = 1; i <= N; i++) { if (tmp == S[i]) term++; else { ans += (term * (term - 1)) / 2; term = 1; tmp = S[i]; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<string> S(N); for (int i = 0; i < N; i++) { string tmp; cin >> tmp; sort(tmp.begin(), tmp.end()); S[i] = tmp; } sort(S.begin(), S.end()); S.push_back(""); long long ans = 0; string tmp = S[0]; long long term = 1; for (int i = 1; i <= N; i++) { if (tmp == S[i]) term++; else { ans += (term * (term - 1)) / 2; term = 1; tmp = S[i]; } } cout << ans << endl; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
749,628
749,629
u570018655
cpp
p02947
/*Author: Gautam*/ #include <bits/stdc++.h> #define FastIO \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); using namespace std; #define MOD 1000000007 #define INF 1e10 #define ull unsigned long long int /* TYPE DEFINITIONS */ typedef long long int ll; typedef vector<ll> vi; typedef pair<ll, ll> pi; /* Prime Checker!!! */ bool isPrime(ull n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (ull i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } /* MACROS */ #define all(A) (A).begin(), (A).end() #define rall(A) (A).rbegin(), (A).rend() #define sz(A) (int)(A).size() #define pb push_back #define ppb pop_back #define mp make_pair #define ln(X) (int)(X).length() #define square(X) ((X) * (X)) #define cube(X) ((X) * (X) * (X)) #define forn(i, n) for (int i = 0; i < int(n); i++) #define forr(i, n) for (int i = int(n - 1); i >= 0; i--) #define fora(i, a, b) for (int i = int(a); i <= int(b); i++) #define forb(i, a, b) for (int i = int(a); i >= int(b); i--) #define fore(it, a) \ for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) int ncr(int n, int k) { int res = 1; if (k > n - k) k = n - k; for (int i = 0; i < k; ++i) { res *= (n - i); res /= (i + 1); } return res; } void solve() { ll n, c = 0; cin >> n; unordered_map<string, ll> memo; forn(i, n) { string s; cin >> s; sort(all(s)); // cout<<s<<endl; memo[s]++; // cout<<memo[s]<<endl; } for (auto i : memo) if (i.second > 1) c += ncr(i.second, 2); cout << c; } int main() { FastIO; ll t = 1; // cin>>t; // double start_time = clock(); while (t--) { solve(); } // double end_time = clock(); // printf( "\nTime = %lf ms\n", ( (end_time - start_time) / // CLOCKS_PER_SEC)*1000); }
/*Author: Gautam*/ #include <bits/stdc++.h> #define FastIO \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); using namespace std; #define MOD 1000000007 #define INF 1e10 #define ull unsigned long long int /* TYPE DEFINITIONS */ typedef long long int ll; typedef vector<ll> vi; typedef pair<ll, ll> pi; /* Prime Checker!!! */ bool isPrime(ull n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (ull i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } /* MACROS */ #define all(A) (A).begin(), (A).end() #define rall(A) (A).rbegin(), (A).rend() #define sz(A) (int)(A).size() #define pb push_back #define ppb pop_back #define mp make_pair #define ln(X) (int)(X).length() #define square(X) ((X) * (X)) #define cube(X) ((X) * (X) * (X)) #define forn(i, n) for (int i = 0; i < int(n); i++) #define forr(i, n) for (int i = int(n - 1); i >= 0; i--) #define fora(i, a, b) for (int i = int(a); i <= int(b); i++) #define forb(i, a, b) for (int i = int(a); i >= int(b); i--) #define fore(it, a) \ for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) ll ncr(ll n, ll k) { ll res = 1; if (k > n - k) k = n - k; for (ll i = 0; i < k; ++i) { res *= (n - i); res /= (i + 1); } return res; } void solve() { ll n, c = 0; cin >> n; unordered_map<string, ll> memo; forn(i, n) { string s; cin >> s; sort(all(s)); // cout<<s<<endl; memo[s]++; // cout<<memo[s]<<endl; } for (auto i : memo) if (i.second > 1) c += ncr(i.second, 2); cout << c; } int main() { FastIO; ll t = 1; // cin>>t; // double start_time = clock(); while (t--) { solve(); } // double end_time = clock(); // printf( "\nTime = %lf ms\n", ( (end_time - start_time) / // CLOCKS_PER_SEC)*1000); }
[ "variable_declaration.type.change", "control_flow.loop.for.initializer.change" ]
749,630
749,631
u689000653
cpp
p02947
#include <bits/stdc++.h> #include <iostream> using namespace std; map<map<char, int>, int> pairs; int main() { int n; string str; cin >> n; for (int i = 0; i < n; ++i) { cin >> str; map<char, int> m; for (char c : str) { m[c]++; } pairs[m]++; } int result = 0; for (auto &p : pairs) { for (int i = 1; i < p.second; i++) { result += i; } } cout << result << endl; }
#include <bits/stdc++.h> #include <iostream> using namespace std; map<map<char, int>, int> pairs; int main() { int n; string str; cin >> n; for (int i = 0; i < n; ++i) { cin >> str; map<char, int> m; for (char c : str) { m[c]++; } pairs[m]++; } long long result = 0; for (auto &p : pairs) { for (int i = 1; i < p.second; i++) { result += i; } } cout << result << endl; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
749,632
749,633
u427073088
cpp
p02947
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; const ll INF = 0x3f3f3f3f; const double PI = acos(-1.0); const double eps = 1e-6; const int mod = 1e9 + 7; const int maxn = 200005; ll T, n, m; string s[maxn]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> s[i]; sort(s[i].begin(), s[i].end()); } sort(s, s + n); int cnt = 1; ll sum = 0; for (int i = 0; i < n; i++) { if (s[i] != s[i + 1] && cnt != 1) { sum += (cnt * (cnt - 1)) / 2; cnt = 1; } else if (s[i] != s[i + 1] && cnt == 1) { cnt = 1; } else { cnt++; } } sum += (cnt * (cnt - 1)) / 2; cout << sum << endl; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; const ll INF = 0x3f3f3f3f; const double PI = acos(-1.0); const double eps = 1e-6; const int mod = 1e9 + 7; const int maxn = 200005; ll T, n, m; string s[maxn]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> s[i]; sort(s[i].begin(), s[i].end()); } sort(s, s + n); ll cnt = 1; ll sum = 0; for (ll i = 0; i < n; i++) { if (s[i] != s[i + 1] && cnt != 1) { sum += (cnt * (cnt - 1)) / 2; cnt = 1; } else if (s[i] != s[i + 1] && cnt == 1) { cnt = 1; } else { cnt++; } } sum += (cnt * (cnt - 1)) / 2; cout << sum << endl; }
[ "variable_declaration.type.change", "control_flow.loop.for.initializer.change" ]
749,636
749,637
u269278772
cpp
p02947
#include <bits/stdc++.h> using namespace std; #define LL long long #define ULL long long unsigned #define LD long double #define FOR(i, n) for (int i = 0; i < n; i++) #define FLR(i, n) for (LL i = 0; i < n; i++) #define RFOR(i, n) for (int i = n - 1; i >= 0; i--) #define RFLR(i, n) for (LL i = n - 1; i >= 0; i--) #define rep(i, a, b) for (int i = a; i <= b; i++) #define repl(i, a, b) for (LL i = a; i <= b; i++) #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(0); #define all(a) a.begin(), a.end() #define ABS(x) ((x) < 0 ? -(x) : (x)) #define NL "\n" #define pb push_back #define pi acos(-1.0) #define prec(n) fixed << setprecision(n) int main() { fast; int ans = 0, n, i, j, k, x, knt; string s; map<string, int> mp; cin >> n; FOR(i, n) { cin >> s; sort(all(s)); mp[s]++; knt = mp[s]; if (mp[s] > 1) { ans += (knt * (knt - 1) - (knt - 1) * (knt - 2)) / 2; } } cout << ans; }
#include <bits/stdc++.h> using namespace std; #define LL long long #define ULL long long unsigned #define LD long double #define FOR(i, n) for (int i = 0; i < n; i++) #define FLR(i, n) for (LL i = 0; i < n; i++) #define RFOR(i, n) for (int i = n - 1; i >= 0; i--) #define RFLR(i, n) for (LL i = n - 1; i >= 0; i--) #define rep(i, a, b) for (int i = a; i <= b; i++) #define repl(i, a, b) for (LL i = a; i <= b; i++) #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(0); #define all(a) a.begin(), a.end() #define ABS(x) ((x) < 0 ? -(x) : (x)) #define NL "\n" #define pb push_back #define pi acos(-1.0) #define prec(n) fixed << setprecision(n) int main() { fast; LL ans = 0, n, i, j, k, x, knt; string s; map<string, LL> mp; cin >> n; FOR(i, n) { cin >> s; sort(all(s)); mp[s]++; knt = mp[s]; if (mp[s] > 1) { ans += (knt * (knt - 1) - (knt - 1) * (knt - 2)) / 2; } } cout << ans; }
[ "variable_declaration.type.change" ]
749,638
749,639
u939474202
cpp
p02947
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; const int INF = INT_MAX; const ll LINF = LLONG_MAX; const ll MOD = 1e9 + 7; template <class T> ostream &operator<<(ostream &o, const vector<T> &v) { o << "["; for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i]; o << "]"; return o; } template <class T, class U> ostream &operator<<(ostream &o, const pair<T, U> &p) { o << "{" << p.first << ", " << p.second << "}"; return o; } template <class T, class U> ostream &operator<<(ostream &o, const map<T, U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } int main() { cin.tie(0); ios::sync_with_stdio(false); map<string, int> cnt; int n; string s; ll ans = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> s; sort(s.begin(), s.end()); if (cnt.find(s) == cnt.end()) cnt[s] = 0; cnt[s]++; } for (auto v : cnt) { ans += v.second * (v.second - 1) / 2; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; const int INF = INT_MAX; const ll LINF = LLONG_MAX; const ll MOD = 1e9 + 7; template <class T> ostream &operator<<(ostream &o, const vector<T> &v) { o << "["; for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i]; o << "]"; return o; } template <class T, class U> ostream &operator<<(ostream &o, const pair<T, U> &p) { o << "{" << p.first << ", " << p.second << "}"; return o; } template <class T, class U> ostream &operator<<(ostream &o, const map<T, U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } int main() { cin.tie(0); ios::sync_with_stdio(false); map<string, ll> cnt; int n; string s; ll ans = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> s; sort(s.begin(), s.end()); if (cnt.find(s) == cnt.end()) cnt[s] = 0; cnt[s]++; } for (auto v : cnt) { ans += v.second * (v.second - 1) / 2; } cout << ans << endl; return 0; }
[]
749,645
749,646
u123276241
cpp
p02947
#include <bits/stdc++.h> using namespace std; #define itn int #define rep(i, x, y) for (int i = x; i < y; i++) #define range(a) a.begin(), a.end() #define print(A, n) \ rep(i, 0, n) { cout << (i ? " " : "") << A[i]; } \ cout << endl; #define pprint(A, m, n) \ rep(j, 0, m) { print(A[j], n); } const long mod = 1e9 + 7; const int size = 1e5; const long INF = 1e18; int main() { int N; cin >> N; char s[N][10]; string st[N] = {}; rep(i, 0, N) { rep(j, 0, 10) cin >> s[i][j]; sort(s[i], s[i] + 10); rep(j, 0, 10) st[i] += s[i][j]; } sort(st, st + N); string temp = " "; int ans = 0, count = 0; bool flag = false; rep(i, 0, N) { if (st[i] == temp) { count++; } else { ans += count * (count - 1) / 2; count = 1; temp = st[i]; } } cout << ans + count * (count - 1) / 2 << endl; // print(st,N); }
#include <bits/stdc++.h> using namespace std; #define itn int #define rep(i, x, y) for (int i = x; i < y; i++) #define range(a) a.begin(), a.end() #define print(A, n) \ rep(i, 0, n) { cout << (i ? " " : "") << A[i]; } \ cout << endl; #define pprint(A, m, n) \ rep(j, 0, m) { print(A[j], n); } const long mod = 1e9 + 7; const int size = 1e5; const long INF = 1e18; int main() { int N; cin >> N; char s[N][10]; string st[N] = {}; rep(i, 0, N) { rep(j, 0, 10) cin >> s[i][j]; sort(s[i], s[i] + 10); rep(j, 0, 10) st[i] += s[i][j]; } sort(st, st + N); string temp = " "; long ans = 0, count = 0; rep(i, 0, N) { if (st[i] == temp) { count++; } else { ans += count * (count - 1) / 2; count = 1; temp = st[i]; } } cout << ans + count * (count - 1) / 2 << endl; // print(st,N); }
[ "variable_declaration.type.primitive.change", "variable_declaration.remove" ]
749,652
749,653
u977554186
cpp
p02947
#include <algorithm> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int N; vector<string> s; string str; int ans = 0; cin >> N; for (int i = 0; i < N; i++) { cin >> str; sort(begin(str), end(str)); s.push_back(str); } sort(begin(s), end(s)); str = ""; int tmp = 0; for (auto itr = begin(s); itr != end(s); itr++) { if (str != *itr) { str = *itr; tmp = 0; } else { tmp++; ans += tmp; } } cout << ans << endl; return 0; }
#include <algorithm> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int N; vector<string> s; string str; long long int ans = 0; cin >> N; for (int i = 0; i < N; i++) { cin >> str; sort(begin(str), end(str)); s.push_back(str); } sort(begin(s), end(s)); str = ""; long long int tmp = 0; for (auto itr = begin(s); itr != end(s); itr++) { if (str != *itr) { str = *itr; tmp = 0; } else { tmp++; ans += tmp; } } cout << ans << endl; return 0; }
[ "variable_declaration.type.widen.change" ]
749,654
749,655
u426462442
cpp
p02947
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author */ #include <fstream> #include <iostream> #include <bits/stdc++.h> using namespace std; class CGreenBin { public: void solve(std::istream &cin, std::ostream &cout) { int n; cin >> n; vector<string> S(n); for (auto &s : S) cin >> s; map<string, int> count; for (auto &s : S) { sort(s.begin(), s.end()); count[s]++; } int64_t ans = 0; for (const auto &c : count) ans += c.second * (c.second - 1) / 2; cout << ans << endl; } }; int main() { CGreenBin solver; std::istream &in(std::cin); std::ostream &out(std::cout); solver.solve(in, out); return 0; }
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author */ #include <fstream> #include <iostream> #include <bits/stdc++.h> using namespace std; class CGreenBin { public: void solve(std::istream &cin, std::ostream &cout) { int n; cin >> n; vector<string> S(n); for (auto &s : S) cin >> s; map<string, int> count; for (auto &s : S) { sort(s.begin(), s.end()); count[s]++; } int64_t ans = 0; for (const auto &c : count) ans += c.second * (c.second - 1LL) / 2; cout << ans << endl; } }; int main() { CGreenBin solver; std::istream &in(std::cin); std::ostream &out(std::cout); solver.solve(in, out); return 0; }
[ "literal.number.type.widen.change" ]
749,656
749,657
u268793453
cpp
p02947
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<string> s(N); for (int i = 0; i < N; i++) cin >> s[i]; for (int i = 0; i < N; i++) sort(s[i].begin(), s[i].end()); // cout <<s[0]<<endl; map<string, int> card; // 名前→成績 for (int i = 0; i < N; i++) { if (card.count(s[i])) { card[s[i]]++; } else { card[s[i]] = 1; } } long c = 0; for (auto p : card) { auto v = p.second; c += v * (v - 1) / 2; } cout << c << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<string> s(N); for (int i = 0; i < N; i++) cin >> s[i]; for (int i = 0; i < N; i++) sort(s[i].begin(), s[i].end()); // cout <<s[0]<<endl; map<string, long> card; // 名前→成績 for (int i = 0; i < N; i++) { if (card.count(s[i])) { card[s[i]]++; } else { card[s[i]] = 1; } } long c = 0; for (auto p : card) { auto v = p.second; c += v * (v - 1) / 2; } cout << c << endl; }
[ "variable_declaration.type.primitive.change" ]
749,658
749,659
u223172354
cpp
p02947
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<string> s(n); int i, j; for (i = 0; i < n; i++) { cin >> s[i]; sort(s[i].begin(), s[i].end()); } sort(s.begin(), s.end()); int equre = 0; long long result = 0; for (i = 1; i < s.size(); i++) { if (s[i - 1] == s[i]) { equre++; } else { result += (equre * (equre + 1)) / 2; equre = 0; } } result += (equre * (equre + 1)) / 2; cout << result << endl; return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<string> s(n); int i, j; for (i = 0; i < n; i++) { cin >> s[i]; sort(s[i].begin(), s[i].end()); } sort(s.begin(), s.end()); long long equre = 0; long long result = 0; for (i = 1; i < s.size(); i++) { if (s[i - 1] == s[i]) { equre++; } else { result += (equre * (equre + 1)) / 2; equre = 0; } } result += (equre * (equre + 1)) / 2; cout << result << endl; return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
749,667
749,668
u883104091
cpp
p02947
#include <bits/stdc++.h> using namespace std; int N; map<string, int> m; int main() { cin >> N; for (int i = 0; i < N; i++) { string si; cin >> si; sort(si.begin(), si.end()); m[si]++; } long long sum = 0; for (map<string, int>::iterator it = m.begin(); it != m.end(); it++) { sum += it->second * (it->second - 1) / 2; } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int N; map<string, int> m; int main() { cin >> N; for (int i = 0; i < N; i++) { string si; cin >> si; sort(si.begin(), si.end()); m[si]++; } long long sum = 0; for (map<string, int>::iterator it = m.begin(); it != m.end(); it++) { sum += it->second * 1LL * (it->second * 1LL - 1) / 2; } cout << sum << endl; return 0; }
[ "assignment.change" ]
749,669
749,670
u740650265
cpp
p02947
#include <bits/stdc++.h> using namespace std; string s[100001]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> s[i]; for (int j = 0; j < s[i].length(); j++) { for (int k = j + 1; k < s[i].length(); k++) { if (s[i][k] < s[i][j]) swap(s[i][k], s[i][j]); } } } sort(s + 1, s + n + 1); int ans = 0, l = 1; for (int i = 2; i <= n; i++) { if (s[i] == s[i - 1]) l++; else { ans += l * (l - 1) / 2; l = 1; } } ans += l * (l - 1) / 2; printf("%d", ans); }
#include <bits/stdc++.h> using namespace std; string s[100001]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> s[i]; for (int j = 0; j < s[i].length(); j++) { for (int k = j + 1; k < s[i].length(); k++) { if (s[i][k] < s[i][j]) swap(s[i][k], s[i][j]); } } } sort(s + 1, s + n + 1); long long ans = 0, l = 1; for (int i = 2; i <= n; i++) { if (s[i] == s[i - 1]) l++; else { ans += l * (l - 1) / 2; l = 1; } } ans += l * (l - 1) / 2; printf("%lld", ans); }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change", "literal.string.change", "call.arguments.change", "io.output.change" ]
749,673
749,674
u718954939
cpp
p02947
// AtCoder // Beginner Contest 137 // C - Green Bin #include <bits/stdc++.h> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long int ll; typedef long double ld; typedef pair<ll, int> PLI; typedef pair<int, int> PII; const ll mxsize = 1e5 + 15; const ll linf = 1e9; const long double inf = 10000000000.0; #define fastIO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); const ll mod = 1e9 + 7; /******************************************* IMPORTANT CODE SNIPPETS * ************************************************/ ll pow(ll x, ll n) { if (n == 0) return 1ll; ll temp; temp = pow(x, n / 2); if (n % 2 == 0) return temp * temp; else return x * temp * temp; } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } int sum_digit(int val) { if (val < 0) return -1; if (val == 0) return 0; int ans = 0; while (val > 0) { ans = ans + val % 10; val = val / 10; } return ans; } ll count_div(ll l, ll r, ll val) { if (l % val == 0) return (((r / val) - (l / val)) + 1); else return ((r / val) - (l / val)); } int powmod(int x, int y, int m) { int res = 1; // x = x % mod; while (y > 0) { if (y & 1) res = (res * x) % m; cout << res << endl; y = y / 2; cout << x << endl; x = (x * x) % m; } // cout << res << endl; return res; } /******************************************** CODE STARTS FROM HERE * *************************************************/ int main() { int n; cin >> n; unordered_map<string, int> mp; for (int i = 0; i < n; i++) { string s; cin >> s; sort(s.begin(), s.end()); mp[s]++; } ll ans = 0; for (auto x : mp) { if (x.second >= 2) { ans = ans + (ll)((x.second) * (x.second - 1)) / 2; } } cout << ans << endl; }
// AtCoder // Beginner Contest 137 // C - Green Bin #include <bits/stdc++.h> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long int ll; typedef long double ld; typedef pair<ll, int> PLI; typedef pair<int, int> PII; const ll mxsize = 1e5 + 15; const ll linf = 1e9; const long double inf = 10000000000.0; #define fastIO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); const ll mod = 1e9 + 7; /******************************************* IMPORTANT CODE SNIPPETS * ************************************************/ ll pow(ll x, ll n) { if (n == 0) return 1ll; ll temp; temp = pow(x, n / 2); if (n % 2 == 0) return temp * temp; else return x * temp * temp; } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } int sum_digit(int val) { if (val < 0) return -1; if (val == 0) return 0; int ans = 0; while (val > 0) { ans = ans + val % 10; val = val / 10; } return ans; } ll count_div(ll l, ll r, ll val) { if (l % val == 0) return (((r / val) - (l / val)) + 1); else return ((r / val) - (l / val)); } int powmod(int x, int y, int m) { int res = 1; // x = x % mod; while (y > 0) { if (y & 1) res = (res * x) % m; cout << res << endl; y = y / 2; cout << x << endl; x = (x * x) % m; } // cout << res << endl; return res; } /******************************************** CODE STARTS FROM HERE * *************************************************/ int main() { int n; cin >> n; unordered_map<string, ll> mp; for (ll i = 0; i < n; i++) { string s; cin >> s; sort(s.begin(), s.end()); mp[s]++; } ll ans = 0; for (auto x : mp) { if (x.second >= 2) { ans = ans + ((x.second) * (x.second - 1)) / 2; } } cout << ans << endl; }
[ "control_flow.loop.for.initializer.change", "variable_declaration.type.change", "call.remove" ]
749,675
749,676
u576105797
cpp
p02947
#include <bits/stdc++.h> using namespace std; const int N = 1000005; string s[N]; map<string, int> mp; int main() { int n; int t; scanf("%d", &n); mp.clear(); for (int i = 0; i < n; ++i) { cin >> s[i]; // cout<<s[i]<<endl; sort(s[i].begin(), s[i].end()); // cout<<s[i]<<endl; mp[s[i]]++; } map<string, int>::iterator it; long long ans = 0; for (it = mp.begin(); it != mp.end(); ++it) { if (it->second > 1) { ans += (it->second * (it->second - 1)) / 2; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1000005; string s[N]; map<string, long long> mp; int main() { int n; int t; scanf("%d", &n); mp.clear(); for (int i = 0; i < n; ++i) { cin >> s[i]; // cout<<s[i]<<endl; sort(s[i].begin(), s[i].end()); // cout<<s[i]<<endl; mp[s[i]]++; } map<string, long long>::iterator it; long long ans = 0; for (it = mp.begin(); it != mp.end(); ++it) { if (it->second > 1) { ans += (it->second * (it->second - 1)) / 2; } } cout << ans << endl; return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
749,677
749,678
u812942729
cpp
p02947
#include <bits/stdc++.h> using namespace std; const int N = 1000005; string s[N]; map<string, int> mp; int main() { int n; int t; scanf("%d", &n); mp.clear(); for (int i = 0; i < n; ++i) { cin >> s[i]; // cout<<s[i]<<endl; sort(s[i].begin(), s[i].end()); // cout<<s[i]<<endl; mp[s[i]]++; } map<string, int>::iterator it; int ans = 0; for (it = mp.begin(); it != mp.end(); ++it) { if (it->second > 1) { ans += (it->second * (it->second - 1)) / 2; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1000005; string s[N]; map<string, long long> mp; int main() { int n; int t; scanf("%d", &n); mp.clear(); for (int i = 0; i < n; ++i) { cin >> s[i]; // cout<<s[i]<<endl; sort(s[i].begin(), s[i].end()); // cout<<s[i]<<endl; mp[s[i]]++; } map<string, long long>::iterator it; long long ans = 0; for (it = mp.begin(); it != mp.end(); ++it) { if (it->second > 1) { ans += (it->second * (it->second - 1)) / 2; } } cout << ans << endl; return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
749,679
749,678
u812942729
cpp
p02947
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string ss[n]; for (int i = 0; i < n; i++) { string s; cin >> s; sort(s.begin(), s.end()); ss[i] = s; } sort(ss, ss + n); long long idx1 = 0; long long idx2 = 1; long long ans = 0; while (idx1 < n) { while (idx2 < n) { if (ss[idx1] != ss[idx2]) { break; } ++idx2; } ans += (idx2 - idx1) * (idx2 - idx1 - 1) / 2; idx1 += idx2; ++idx2; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string ss[n]; for (int i = 0; i < n; i++) { string s; cin >> s; sort(s.begin(), s.end()); ss[i] = s; } sort(ss, ss + n); long long idx1 = 0; long long idx2 = 1; long long ans = 0; while (idx1 < n) { while (idx2 < n) { if (ss[idx1] != ss[idx2]) { break; } ++idx2; } ans += (idx2 - idx1) * (idx2 - idx1 - 1) / 2; idx1 = idx2; ++idx2; } cout << ans << endl; }
[ "assignment.value.change" ]
749,680
749,681
u313766957
cpp
p02947
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string ss[n]; for (int i = 0; i < n; i++) { string s; cin >> s; sort(s.begin(), s.end()); ss[i] = s; } sort(ss, ss + n); int idx1 = 0; int idx2 = 1; long long ans = 0; while (idx1 < n) { while (idx2 < n) { if (ss[idx1] != ss[idx2]) { break; } ++idx2; } ans += (idx2 - idx1) * (idx2 - idx1 - 1) / 2; idx1 += idx2; ++idx2; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string ss[n]; for (int i = 0; i < n; i++) { string s; cin >> s; sort(s.begin(), s.end()); ss[i] = s; } sort(ss, ss + n); long long idx1 = 0; long long idx2 = 1; long long ans = 0; while (idx1 < n) { while (idx2 < n) { if (ss[idx1] != ss[idx2]) { break; } ++idx2; } ans += (idx2 - idx1) * (idx2 - idx1 - 1) / 2; idx1 = idx2; ++idx2; } cout << ans << endl; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change", "assignment.value.change" ]
749,682
749,681
u313766957
cpp
p02947
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string s; map<string, int> mp; while (n--) { cin >> s; sort(s.begin(), s.end()); mp[s]++; } ll ans = 0; for (auto item : mp) { // cout<<item.first<<" "<<item.second<<endl; ll res = item.second * (item.second - 1); res /= 2; // cout<<res<<endl; ans += res; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string s; map<string, ll> mp; while (n--) { cin >> s; sort(s.begin(), s.end()); mp[s]++; } ll ans = 0; for (auto item : mp) { // cout<<item.first<<" "<<item.second<<endl; ll res = item.second * (item.second - 1); res /= 2; // cout<<res<<endl; ans += res; } cout << ans << endl; return 0; }
[]
749,683
749,684
u781659997
cpp
p02947
#include "bits/stdc++.h" using namespace std; // vector<long long> factors; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define _ << '\n' #define __ << ' ' #define all(x) (x).begin(), (x).end() #define gcd __gcd int IT_MAX = 1 << 17; int MOD = 998244353; const int INF = 0x3f3f3f3f; const ll LL_INF = 0x0f3f3f3f3f3f3f3f; const double PI = acos(-1); const double ERR = 1e-10; #define szz(x) (int)(x).size() #define IOS \ ios_base::sync_with_stdio(false); \ cout.tie(0); \ cin.tie(0); #define flush fflush(stdout) ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; } //****************************don't use int!!!!!!!****************************// //***************************code starts here!!!!!****************************// int main() { IOS int n; cin >> n; vector<string> vs(n); for (int i = 0; i < n; ++i) { cin >> vs[i]; } for (auto &st : vs) { sort(all(st)); } sort(all(vs)); ll ans = 0; for (int i = 0; i < n; ++i) { ll cur_cnt = 0; int cur_i = i; while (cur_i < n && vs[i] == vs[cur_i]) { ++cur_i; ++cur_cnt; } i = cur_i; ans += (cur_cnt) * (cur_cnt - 1) / 2; } cout << ans; return 0; }
#include "bits/stdc++.h" using namespace std; // vector<long long> factors; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define _ << '\n' #define __ << ' ' #define all(x) (x).begin(), (x).end() #define gcd __gcd int IT_MAX = 1 << 17; int MOD = 998244353; const int INF = 0x3f3f3f3f; const ll LL_INF = 0x0f3f3f3f3f3f3f3f; const double PI = acos(-1); const double ERR = 1e-10; #define szz(x) (int)(x).size() #define IOS \ ios_base::sync_with_stdio(false); \ cout.tie(0); \ cin.tie(0); #define flush fflush(stdout) ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; } //****************************don't use int!!!!!!!****************************// //***************************code starts here!!!!!****************************// int main() { IOS int n; cin >> n; vector<string> vs(n); for (int i = 0; i < n; ++i) { cin >> vs[i]; } for (auto &st : vs) { sort(all(st)); } sort(all(vs)); ll ans = 0; for (int i = 0; i < n; ++i) { ll cur_cnt = 0; int cur_i = i; while (cur_i < n && vs[i] == vs[cur_i]) { ++cur_i; ++cur_cnt; } i = cur_i - 1; ans += (cur_cnt) * (cur_cnt - 1) / 2; } cout << ans; return 0; }
[ "assignment.change" ]
749,687
749,688
u559507546
cpp
p02947
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pii> vii; typedef vector<vector<int>> vvi; #define clr(a, b) memset(a, b, sizeof(a)) #define pb push_back #define frpn(x) \ freopen(#x ".in", "r", stdin); \ freopen(#x ".out", "w", stdout); #define all(a) a.begin(), a.end() #define mkp make_pair #define forn(i, n) for (int i = 0; i < (int)(n); ++i) #define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i) #define fornd(i, n) for (int i = (int)(n); i >= 0; --i) const int INF = (int)1e6 + 5; const int NAX = (int)1e5 + 5; const int MOD = (int)1e9 + 7; template <class T> inline void rem(T &n) { n = (-MOD <= n && n <= MOD) ? n : n % MOD; if (n < 0) n += MOD; } // modular inverse // inv(a,m) - inverse of a mod m template <class T> inline T inv(T a, T m) { return 1 < a ? m - inv(m % a, a) * m / a : 1; } int a[NAX][26]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; string s[n]; vector<string> v; for (int i = 0; i < n; ++i) { cin >> s[i]; sort(all(s[i])); v.push_back(s[i]); } sort(all(v), [&](const string a, const string b) { return (a < b); }); ll res = 0; for (int i = 0; i < v.size() - 1; ++i) { int c = 1, p = i; while (p + 1 < n && v[p] == v[p + 1]) { ++c; ++p; } if (c > 1) i = p - 1; res += c * (c - 1) / 2; } cout << res << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pii> vii; typedef vector<vector<int>> vvi; #define clr(a, b) memset(a, b, sizeof(a)) #define pb push_back #define frpn(x) \ freopen(#x ".in", "r", stdin); \ freopen(#x ".out", "w", stdout); #define all(a) a.begin(), a.end() #define mkp make_pair #define forn(i, n) for (int i = 0; i < (int)(n); ++i) #define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i) #define fornd(i, n) for (int i = (int)(n); i >= 0; --i) const int INF = (int)1e6 + 5; const int NAX = (int)1e5 + 5; const int MOD = (int)1e9 + 7; template <class T> inline void rem(T &n) { n = (-MOD <= n && n <= MOD) ? n : n % MOD; if (n < 0) n += MOD; } // modular inverse // inv(a,m) - inverse of a mod m template <class T> inline T inv(T a, T m) { return 1 < a ? m - inv(m % a, a) * m / a : 1; } int a[NAX][26]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; string s[n]; vector<string> v; for (int i = 0; i < n; ++i) { cin >> s[i]; sort(all(s[i])); v.push_back(s[i]); } sort(all(v), [&](const string a, const string b) { return (a < b); }); ll res = 0; for (int i = 0; i < v.size() - 1; ++i) { ll c = 1; int p = i; while (p + 1 < n && v[p] == v[p + 1]) { ++c; ++p; } if (c > 1) i = p - 1; res += c * (c - 1) / 2; } // v.resize(unique(all(v)) - v.begin()); cout << res << "\n"; return 0; }
[ "variable_declaration.type.change" ]
749,689
749,690
u882821419
cpp
p02947
#include <bits/stdc++.h> using namespace std; map<string, int> m; int n, ans; string s, s1[100005]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> s; for (int j = 0; j < 10; j++) for (int k = 1; k < 10; k++) if (s[j] > s[k]) swap(s[j], s[k]); m[s]++; s1[i] = s; } for (int i = 1; i <= n; i++) { if (m[s1[i]]) { ans += m[s1[i]] * (m[s1[i]] - 1) / 2; m[s1[i]] = 0; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; map<string, long long> m; long long n, ans; string s, s1[100005]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> s; for (int j = 0; j < 10; j++) for (int k = 1; k < 10; k++) if (s[j] > s[k]) swap(s[j], s[k]); m[s]++; s1[i] = s; } for (int i = 1; i <= n; i++) { if (m[s1[i]]) { ans += m[s1[i]] * (m[s1[i]] - 1) / 2; m[s1[i]] = 0; } } cout << ans; return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
749,691
749,692
u051670389
cpp
p02947
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; ll ans = 0; string str; map<string, int> mp; cin >> n; for (int i = 0; i < n; i++) { cin >> str; sort(str.begin(), str.end()); mp[str]++; } for (auto it = mp.begin(); it != mp.end(); it++) { n = it->second; ans += (n * (n - 1)) / 2; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll n; ll ans = 0; string str; map<string, ll> mp; cin >> n; for (int i = 0; i < n; i++) { cin >> str; sort(str.begin(), str.end()); mp[str]++; } for (auto it = mp.begin(); it != mp.end(); it++) { n = it->second; ans += (n * (n - 1)) / 2; } cout << ans << endl; return 0; }
[ "variable_declaration.type.change" ]
749,699
749,700
u525363585
cpp
p02947
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; int main() { int N; cin >> N; string s; map<string, int> m{}; rep(i, N) { cin >> s; sort(s.begin(), s.end()); // cout << s << endl; m[s]++; } ll ans = 0; for (auto itr = m.begin(); itr != m.end(); ++itr) { // cout << itr->first << " " << itr->second << endl; int a = itr->second; ans += a * (a - 1) / 2; } cout << ans << endl; }
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; int main() { int N; cin >> N; string s; map<string, int> m{}; rep(i, N) { cin >> s; sort(s.begin(), s.end()); // cout << s << endl; m[s]++; } ll ans = 0; for (auto itr = m.begin(); itr != m.end(); ++itr) { // cout << itr->first << " " << itr->second << endl; ll a = itr->second; ans += a * (a - 1) / 2; } cout << ans << endl; }
[ "variable_declaration.type.change" ]
749,701
749,702
u555962250
cpp
p02947
#include <bits/stdc++.h> using namespace std; #define endl '\n' int main(void) { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vector<string> v(n); for (int i = 0; i < n; i++) cin >> v[i]; for (int i = 0; i < n; i++) sort(v[i].begin(), v[i].end()); map<string, int> m; for (int i = 0; i < v.size(); i++) m[v[i]]++; long Count = 0; for (auto itr = m.begin(); itr != m.end(); itr++) if (itr->second > 1) Count += ((itr->second * (itr->second - 1)) / 2); cout << Count << endl; }
#include <bits/stdc++.h> using namespace std; #define endl '\n' int main(void) { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long n; cin >> n; vector<string> v(n); for (long i = 0; i < n; i++) cin >> v[i]; for (long i = 0; i < n; i++) sort(v[i].begin(), v[i].end()); map<string, long> m; for (long i = 0; i < v.size(); i++) m[v[i]]++; long Count = 0; for (auto itr = m.begin(); itr != m.end(); itr++) if (itr->second > 1) Count += ((itr->second * (itr->second - 1)) / 2); cout << Count << endl; }
[ "variable_declaration.type.primitive.change", "control_flow.loop.for.initializer.change" ]
749,703
749,704
u874258059
cpp
p02947
#include <algorithm> #include <stdio.h> #include <string> #include <vector> // const long long mod = 1000000007; const long long mod = 998244353; int main() { int N; scanf("%d", &N); std::string *s = new std::string[N]; for (int i = 0; i < N; i++) { char q[11]; scanf("%s", q); std::sort(q, q + 10); s[i] = q; } std::sort(s, s + N); std::string c; int n = -1; long long res = 0; for (int i = 1; i < N; i++) { if (n == -1) { if (s[i] == s[i - 1]) { n = 2; c = s[i]; } } else { if (s[i] == c) { n++; } else { res += n * (n - 1) / 2; n = -1; } } } if (n != -1) { res += n * (n - 1) / 2; } printf("%lld", res); return 0; }
#include <algorithm> #include <stdio.h> #include <string> #include <vector> // const long long mod = 1000000007; const long long mod = 998244353; int main() { int N; scanf("%d", &N); std::string *s = new std::string[N]; for (int i = 0; i < N; i++) { char q[11]; scanf("%s", q); std::sort(q, q + 10); s[i] = q; } std::sort(s, s + N); std::string c; long long n = -1; long long res = 0; for (int i = 1; i < N; i++) { if (n == -1) { if (s[i] == s[i - 1]) { n = 2; c = s[i]; } } else { if (s[i] == c) { n++; } else { res += n * (n - 1) / 2; n = -1; } } } if (n != -1) { res += n * (n - 1) / 2; } printf("%lld", res); return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
749,705
749,706
u617987447
cpp
p02947
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = (a); i <= (int)(b); ++i) #define per(i, a, b) for (int i = (a); i >= (int)(b); --i) #define debug(x) cerr << #x << ' ' << x << endl; using namespace std; typedef long long ll; const int MAXN = 2e5 + 7; int main() { int n; cin >> n; map<string, int> mp; rep(i, 1, n) { string s; cin >> s; sort(s.begin(), s.end()); mp[s]++; } ll res = 0; for (auto i = mp.begin(); i != mp.end(); ++i) { res += ((*i).second - 1) * (*i).second / 2; } cout << res << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = (a); i <= (int)(b); ++i) #define per(i, a, b) for (int i = (a); i >= (int)(b); --i) #define debug(x) cerr << #x << ' ' << x << endl; using namespace std; typedef long long ll; const int MAXN = 2e5 + 7; int main() { int n; cin >> n; map<string, ll> mp; rep(i, 1, n) { string s; cin >> s; sort(s.begin(), s.end()); mp[s]++; } ll res = 0; for (auto i = mp.begin(); i != mp.end(); ++i) { res += 1LL * ((*i).second - 1) * (*i).second / 2; } cout << res << endl; return 0; }
[ "assignment.change" ]
749,707
749,708
u613520453
cpp
p02947
#include <algorithm> #include <stdio.h> int n, x; char s[100000][15]; long long a[100000]; long long ans; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", s[i]); std::sort(s[i], s[i] + 10); } for (int i = 0; i < n; i++) { for (int j = 0; j < 10; j++) { a[i] *= 26; a[i] += s[i][j] - 'a'; } } std::sort(a, a + n); x = 1; for (int i = 1; i < n; i++) { if (a[i] == a[i - 1]) x++; else { ans += x * (x - 1) / 2; x = 1; } } ans += x * (x - 1) / 2; printf("%lld\n", ans); }
#include <algorithm> #include <stdio.h> int n; long long x; char s[100000][15]; long long a[100000]; long long ans; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", s[i]); std::sort(s[i], s[i] + 10); } for (int i = 0; i < n; i++) { for (int j = 0; j < 10; j++) { a[i] *= 26; a[i] += s[i][j] - 'a'; } } std::sort(a, a + n); x = 1; for (int i = 1; i < n; i++) { if (a[i] == a[i - 1]) x++; else { ans += x * (x - 1) / 2; x = 1; } } ans += x * (x - 1) / 2; printf("%lld\n", ans); }
[ "variable_declaration.type.widen.change" ]
749,709
749,710
u546925116
cpp
p02947
#include <bits/stdc++.h> using ll = long long; using namespace std; ll mod = 1e9 + 7; int main() { int N; string s[100000]; cin >> N; for (int i(0); i < N; i++) cin >> s[i]; for (int i(0); i < N; i++) { sort(s[i].begin(), s[i].end()); } sort(s, s + N); int ans(0); int cnt(1); for (int i(0); i < N - 1; i++) { if (s[i] == s[i + 1]) cnt += 1; else { ans += cnt * (cnt - 1) / 2; cnt = 1; } } ans += cnt * (cnt - 1) / 2; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using ll = long long; using namespace std; ll mod = 1e9 + 7; int main() { int N; string s[100000]; cin >> N; for (int i(0); i < N; i++) cin >> s[i]; for (int i(0); i < N; i++) { sort(s[i].begin(), s[i].end()); } sort(s, s + N); ll ans(0); ll cnt(1); for (int i(0); i < N - 1; i++) { if (s[i] == s[i + 1]) cnt += 1; else { ans += cnt * (cnt - 1) / 2; cnt = 1; } } ans += cnt * (cnt - 1) / 2; cout << ans << endl; return 0; }
[ "variable_declaration.type.change" ]
749,711
749,712
u991846372
cpp
p02947
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1e+9; typedef pair<ll, ll> P; #define fi first #define se second int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<string> a(n); for (int i = 0; i < n; i++) { cin >> a.at(i); sort(a.at(i).begin(), a.at(i).end()); } sort(a.begin(), a.end()); int cnt = 1; ll ans = 0; for (int i = 0; i < n - 1; i++) { if (a.at(i) == a.at(i + 1)) cnt++; else { ans += cnt * (cnt - 1) / 2; cnt = 1; } } if (cnt > 1) ans += cnt * (cnt - 1) / 2; cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1e+9; typedef pair<ll, ll> P; #define fi first #define se second int main() { ios::sync_with_stdio(false); cin.tie(0); ll n; cin >> n; vector<string> a(n); for (int i = 0; i < n; i++) { cin >> a.at(i); sort(a.at(i).begin(), a.at(i).end()); } sort(a.begin(), a.end()); ll cnt = 1; ll ans = 0; for (int i = 0; i < n - 1; i++) { if (a.at(i) == a.at(i + 1)) cnt++; else { ans += cnt * (cnt - 1) / 2; cnt = 1; } } if (cnt > 1) ans += cnt * (cnt - 1) / 2; cout << ans << endl; }
[ "variable_declaration.type.change" ]
749,713
749,714
u822169805
cpp
p02947
#include <algorithm> #include <array> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; int main() { int num; cin >> num; vector<string> v; for (int i = 0; i < num; i++) { string current1; cin >> current1; vector<string> vec; for (int i = 0; i < 10; i++) { vec.push_back(current1.substr(i, 1)); } sort(vec.begin(), vec.end()); string current2; for (int i = 0; i < 10; i++) { current2 += vec[i]; } v.push_back(current2); } sort(v.begin(), v.end()); long ans = 0; int current = 0; for (int i = 1; i < num; i++) { if (v[i] == v[i - 1]) { current++; } else { ans += (current * (current + 1)) / 2; current = 0; } } ans += (current * (current + 1)) / 2; cout << ans << endl; return 0; }
#include <algorithm> #include <array> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; int main() { int num; cin >> num; vector<string> v; for (int i = 0; i < num; i++) { string current1; cin >> current1; vector<string> vec; for (int i = 0; i < 10; i++) { vec.push_back(current1.substr(i, 1)); } sort(vec.begin(), vec.end()); string current2; for (int i = 0; i < 10; i++) { current2 += vec[i]; } v.push_back(current2); } sort(v.begin(), v.end()); long ans = 0; long current = 0; for (int i = 1; i < num; i++) { if (v[i] == v[i - 1]) { current++; } else { ans += (current * (current + 1)) / 2; current = 0; } } ans += (current * (current + 1)) / 2; cout << ans << endl; return 0; }
[ "variable_declaration.type.primitive.change" ]
749,717
749,718
u881705752
cpp
p02947
#include <bits/stdc++.h> using namespace std; #define ll long long #define mx 100005 int main() { map<string, int> m; int t, re = 0; cin >> t; while (t--) { string s; cin >> s; sort(s.begin(), s.end()); m[s]++; } for (auto it : m) { re += (it.second * (it.second - 1)) / 2; } cout << re << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define mx 100005 int main() { map<string, ll> m; ll t, re = 0; cin >> t; while (t--) { string s; cin >> s; sort(s.begin(), s.end()); m[s]++; } for (auto it : m) { re += (it.second * (it.second - 1)) / 2; } cout << re << endl; return 0; }
[ "variable_declaration.type.change" ]
749,719
749,720
u802094864
cpp
p02947
#include <bits/stdc++.h> using namespace std; map<string, long long> str; int main() { long long n; cin >> n; long long a[n] = {0}; string x; long long s = 0; for (int i = 1; i <= n; i++) { cin >> x; sort(x.begin(), x.end()); if (str[x] == 0) { s++; str[x] = s; a[s]++; } else { a[str[x]]++; } } long long ans = 0; for (int i = 1; i <= s; i++) { ans += (a[i] * a[i] - a[i]) / 2; } cout << ans; }
#include <bits/stdc++.h> using namespace std; map<string, long long> str; int main() { long long n; cin >> n; long long a[n + 1] = {0}; string x; long long s = 0; for (int i = 1; i <= n; i++) { cin >> x; sort(x.begin(), x.end()); if (str[x] == 0) { s++; str[x] = s; a[s]++; } else { a[str[x]]++; } } long long ans = 0; for (int i = 1; i <= s; i++) { ans += (a[i] * a[i] - a[i]) / 2; } cout << ans; return 0; }
[ "variable_declaration.array_dimensions.change", "assignment.change", "control_flow.return.add", "control_flow.return.0.add" ]
749,723
749,724
u837133513
cpp
p02947
#include <bits/stdc++.h> using namespace std; int64_t C(int64_t x) { int ret = (x * (x - 1)) / 2; return ret; } int main() { int N; cin >> N; vector<char> a(10); vector<string> b(N); string k = "abcdefghij"; for (int i = 0; i < N; i++) { for (int j = 0; j < 10; j++) { cin >> a.at(j); } sort(a.begin(), a.end()); for (int l = 0; l < 10; l++) { k.at(l) = a.at(l); } b.at(i) = k; } sort(b.begin(), b.end()); int64_t ans = 0; int64_t count = 1; b.push_back("a"); for (int i = 1; i <= N; i++) { if (b[i] == b[i - 1]) { count++; } if (b[i] != b[i - 1]) { ans += C(count); count = 1; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int64_t C(int64_t x) { int64_t ret = (x * (x - 1)) / 2; return ret; } int main() { int N; cin >> N; vector<char> a(10); vector<string> b(N); string k = "abcdefghij"; for (int i = 0; i < N; i++) { for (int j = 0; j < 10; j++) { cin >> a.at(j); } sort(a.begin(), a.end()); for (int l = 0; l < 10; l++) { k.at(l) = a.at(l); } b.at(i) = k; } sort(b.begin(), b.end()); int64_t ans = 0; int64_t count = 1; b.push_back("a"); for (int i = 1; i <= N; i++) { if (b[i] == b[i - 1]) { count++; } if (b[i] != b[i - 1]) { ans += C(count); count = 1; } } cout << ans << endl; }
[ "variable_declaration.type.primitive.change" ]
749,725
749,726
u983062344
cpp
p02947
/* author: diradon 10-Aug-19 17:39:36 */ #include <bits/stdc++.h> typedef long long int ll; using namespace std; void count(vector<string> v) { ll ans = 0; map<string, int> m; for (int i = 0; i < v.size(); i++) { m[v[i]]++; } for (auto it = m.begin(); it != m.end(); it++) { int count = it->second; ans += (count * (count - 1)) / 2; } cout << ans << "\n"; } int main() { // ios_base::sync_with_stdio(false); // cin.tie(NULL); vector<string> v; int n; string s; cin >> n; for (int i = 0; i < n; i++) { cin >> s; sort(s.begin(), s.end()); v.push_back(s); } count(v); }
/* author: diradon 10-Aug-19 17:39:36 */ #include <bits/stdc++.h> typedef long long int ll; using namespace std; void count(vector<string> v) { ll ans = 0; map<string, ll> m; for (ll i = 0; i < v.size(); i++) { m[v[i]]++; } for (auto it = m.begin(); it != m.end(); it++) { ll count = it->second; ans += (count * (count - 1)) / 2; } cout << ans << "\n"; } int main() { // ios_base::sync_with_stdio(false); // cin.tie(NULL); vector<string> v; int n; string s; cin >> n; for (int i = 0; i < n; i++) { cin >> s; sort(s.begin(), s.end()); v.push_back(s); } count(v); }
[ "control_flow.loop.for.initializer.change", "variable_declaration.type.change" ]
749,727
749,728
u837495281
cpp
p02947
#include <bits/stdc++.h> using namespace std; #define SPEED \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) #define fileio freopen("in.in", "r", stdin), freopen("out.out", "w", stdout); #define ll long long int #define FF first #define SS second #define mp make_pair #define pb push_back #define pii pair<int, int> #define pll pair<long long int, long long int> #define sd(x) scanf("%d", &x) #define slld(x) scanf("%lld", &x) #define pd(x) printf("%d\n", x) #define plld(x) printf("%lld\n", x) #define pss printf #define MOD 1000000007 #define INF 1e18 #define eps 0.00001 #define endl '\n' #define debug(n1) cout << n1 << endl const int N = 1e5; // limit for array size ll n; // array size /*template<typename T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rand(int l, int r){ uniform_int_distribution<int> uid(l, r); return uid(rng); } */ int main() { unordered_map<string, int> mpp; int n; cin >> n; string s; for (int i = 0; i < n; i++) { cin >> s; sort(s.begin(), s.end()); mpp[s]++; } ll ans = 0; unordered_map<string, int>::iterator itr; for (itr = mpp.begin(); itr != mpp.end(); itr++) { int temp = itr->second; ans += (temp * (temp - 1)) / 2; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define SPEED \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) #define fileio freopen("in.in", "r", stdin), freopen("out.out", "w", stdout); #define ll long long int #define FF first #define SS second #define mp make_pair #define pb push_back #define pii pair<int, int> #define pll pair<long long int, long long int> #define sd(x) scanf("%d", &x) #define slld(x) scanf("%lld", &x) #define pd(x) printf("%d\n", x) #define plld(x) printf("%lld\n", x) #define pss printf #define MOD 1000000007 #define INF 1e18 #define eps 0.00001 #define endl '\n' #define debug(n1) cout << n1 << endl const int N = 1e5; // limit for array size ll n; // array size /*template<typename T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rand(int l, int r){ uniform_int_distribution<int> uid(l, r); return uid(rng); } */ int main() { unordered_map<string, ll> mpp; ll n; cin >> n; string s; for (int i = 0; i < n; i++) { cin >> s; sort(s.begin(), s.end()); mpp[s]++; } ll ans = 0; unordered_map<string, ll>::iterator itr; for (itr = mpp.begin(); itr != mpp.end(); itr++) { ll temp = itr->second; ans += (temp * (temp - 1)) / 2; } cout << ans << endl; return 0; }
[ "variable_declaration.type.change" ]
749,729
749,730
u831027829
cpp
p02947
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <functional> #include <iomanip> #include <ios> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <vector> #define REP(i, a) for (int i = 0; i < (a); ++i) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i) #define ALL(obj) (obj).begin(), (obj).end() #define SIZE(obj) (int)(obj).sizeT() #define YESNO(cond, yes, no) \ { cout << ((cond) ? (yes) : (no)) << endl; } #define SORT(list) sort(ALL((list))); #define RSORT(list) sort((list).rbegin(), (list).rend()) #define ASSERT(cond, mes) assert(cond &&mes) using namespace std; using ll = long long; constexpr int MOD = 1'000'000'007; constexpr int INF = 1'050'000'000; template <typename T> T round_up(const T &a, const T &b) { return (a + (b - 1)) / b; } template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; } template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> &p) { os << p.first << p.second; return os; } template <typename T> istream &operator>>(istream &is, vector<T> &v) { REP(i, (int)v.size()) is >> v[i]; return is; } template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { REP(i, (int)v.size()) os << v[i] << endl; return os; } template <typename T> T clamp(T &n, T a, T b) { if (n < a) n = a; if (n > b) n = b; return n; } template <typename T> static T GCD(T u, T v) { T r; while (v != 0) { r = u % v; u = v; v = r; } return u; } template <typename T> static T LCM(T u, T v) { return u / GCD(u, v) * v; } std::vector<int> enum_div(int n) { std::vector<int> ret; for (int i = 1; i * i <= n; ++i) { if (n % i == 0) { ret.push_back(i); if (i != 1 && i * i != n) { ret.push_back(n / i); } } } return ret; } template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } ll modpow(ll a, ll b, ll mod) { ll res = 1; while (b > 0) { if (b & 1) res = res * a % mod; a = a * a % mod; b >>= 1; } return res; } ll modinv(ll a, ll mod) { return modpow(a, mod - 2, mod); } ll p(ll a, ll mod) { ll res = 1; FOR(i, 1, a + 1) { res *= modinv(i, mod); res %= mod; } return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); std::cout << fixed << setprecision(20); int N; cin >> N; vector<string> S(N); cin >> S; vector<map<char, int>> m(N); REP(i, N) { REP(s, S[i].length()) { m[i][S[i][s]]++; } } map<map<char, int>, int> ansmap; REP(i, N) { ansmap[m[i]]++; } ll ans = 0; for (auto &&mi : ansmap) { ans += (mi.second * (mi.second - 1)) / 2; } cout << ans << endl; return 0; }
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <functional> #include <iomanip> #include <ios> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <vector> #define REP(i, a) for (int i = 0; i < (a); ++i) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i) #define ALL(obj) (obj).begin(), (obj).end() #define SIZE(obj) (int)(obj).sizeT() #define YESNO(cond, yes, no) \ { cout << ((cond) ? (yes) : (no)) << endl; } #define SORT(list) sort(ALL((list))); #define RSORT(list) sort((list).rbegin(), (list).rend()) #define ASSERT(cond, mes) assert(cond &&mes) using namespace std; using ll = long long; constexpr int MOD = 1'000'000'007; constexpr int INF = 1'050'000'000; template <typename T> T round_up(const T &a, const T &b) { return (a + (b - 1)) / b; } template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; } template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> &p) { os << p.first << p.second; return os; } template <typename T> istream &operator>>(istream &is, vector<T> &v) { REP(i, (int)v.size()) is >> v[i]; return is; } template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { REP(i, (int)v.size()) os << v[i] << endl; return os; } template <typename T> T clamp(T &n, T a, T b) { if (n < a) n = a; if (n > b) n = b; return n; } template <typename T> static T GCD(T u, T v) { T r; while (v != 0) { r = u % v; u = v; v = r; } return u; } template <typename T> static T LCM(T u, T v) { return u / GCD(u, v) * v; } std::vector<int> enum_div(int n) { std::vector<int> ret; for (int i = 1; i * i <= n; ++i) { if (n % i == 0) { ret.push_back(i); if (i != 1 && i * i != n) { ret.push_back(n / i); } } } return ret; } template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } ll modpow(ll a, ll b, ll mod) { ll res = 1; while (b > 0) { if (b & 1) res = res * a % mod; a = a * a % mod; b >>= 1; } return res; } ll modinv(ll a, ll mod) { return modpow(a, mod - 2, mod); } ll p(ll a, ll mod) { ll res = 1; FOR(i, 1, a + 1) { res *= modinv(i, mod); res %= mod; } return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); std::cout << fixed << setprecision(20); int N; cin >> N; vector<string> S(N); cin >> S; vector<map<char, int>> m(N); REP(i, N) { REP(s, S[i].length()) { m[i][S[i][s]]++; } } map<map<char, int>, ll> ansmap; REP(i, N) { ansmap[m[i]]++; } ll ans = 0; for (auto &&mi : ansmap) { ans += (mi.second * (mi.second - 1)) / 2; } cout << ans << endl; return 0; }
[]
749,731
749,732
u303039933
cpp
p02947
#include <bits/stdc++.h> using namespace std; long long Cn2(int x) { if (x % 2 == 0) return (x / 2) * (x - 1); else return ((x - 1) / 2) * x; } int main() { int n; cin >> n; map<string, int> mp; string s; for (int i = 0; i < n; ++i) { cin >> s; sort(s.begin(), s.end()); mp[s]++; } long long count = 0; for (auto it = mp.begin(); it != mp.end(); ++it) { long long x = Cn2(it->second); count += x; } cout << count; return 0; }
#include <bits/stdc++.h> using namespace std; long long Cn2(long long x) { if (x % 2 == 0) return (x / 2) * (x - 1); else return ((x - 1) / 2) * x; } int main() { long long n; cin >> n; map<string, long long> mp; string s; for (int i = 0; i < n; ++i) { cin >> s; sort(s.begin(), s.end()); mp[s]++; } long long count = 0; for (auto it = mp.begin(); it != mp.end(); ++it) { long long x = Cn2(it->second); count += x; } cout << count; return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
749,733
749,734
u878838754
cpp
p02947
#include <bits/stdc++.h> using namespace std; int main() { int N; long long ans = 0; cin >> N; vector<string> S(N); for (auto &i : S) cin >> i; for (auto &i : S) sort(i.begin(), i.end()); sort(S.begin(), S.end()); int c = 1; for (int i = 0; i < N; i++) { if (i == N - 1) { ans += c * (c - 1) / 2; } else if (S[i] == S[i + 1]) c++; else { ans += c * (c - 1) / 2; c = 1; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N; long long ans = 0; cin >> N; vector<string> S(N); for (auto &i : S) cin >> i; for (auto &i : S) sort(i.begin(), i.end()); sort(S.begin(), S.end()); long long c = 1; for (int i = 0; i < N; i++) { if (i == N - 1) { ans += c * (c - 1) / 2; } else if (S[i] == S[i + 1]) c++; else { ans += c * (c - 1) / 2; c = 1; } } cout << ans << endl; return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
749,735
749,736
u573082373
cpp
p02947
#include <algorithm> #include <cmath> #include <iostream> #include <queue> #include <unordered_map> #include <vector> using namespace std; int main() { int n; cin >> n; vector<string> ss(n); for (int i = 0; i < n; i++) { string s; cin >> s; sort(s.begin(), s.end()); ss[i] = s; } sort(ss.begin(), ss.end()); int result = 0; string s_base = ""; int group_count = 0; for (int i = 0; i < n; i++) { if (s_base == ss[i]) { group_count++; } else { result += group_count * (group_count + 1) / 2; group_count = 0; s_base = ss[i]; } } result += group_count * (group_count + 1) / 2; cout << result << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <queue> #include <unordered_map> #include <vector> using namespace std; int main() { int n; cin >> n; vector<string> ss(n); for (int i = 0; i < n; i++) { string s; cin >> s; sort(s.begin(), s.end()); ss[i] = s; } sort(ss.begin(), ss.end()); unsigned long long result = 0; string s_base = ""; unsigned long long group_count = 0; for (int i = 0; i < n; i++) { if (s_base == ss[i]) { group_count++; } else { result += group_count * (group_count + 1) / 2; group_count = 0; s_base = ss[i]; } } result += group_count * (group_count + 1) / 2; cout << result << endl; return 0; }
[ "variable_declaration.type.primitive.change" ]
749,737
749,738
u538188080
cpp
p02947
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <string> #define int long long using namespace std; const int INF = 0x3f3f3f3f; const int N = 100010; int n, ans; string str[N]; signed main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { cin >> str[i]; sort(str[i].begin(), str[i].end()); } sort(str + 1, str + 1 + n); string pre = str[1]; int cnt = 1; for (int i = 2; i <= n; i++) { if (str[i] == pre) { cnt++; } else { ans += cnt * (cnt - 1) / 2; cnt = 1; pre = str[i]; } } ans += cnt * (cnt - 1) / 2; printf("%d\n", ans); return 0; }
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <string> #define int long long using namespace std; const int INF = 0x3f3f3f3f; const int N = 100010; int n, ans; string str[N]; signed main() { scanf("%lld", &n); for (int i = 1; i <= n; i++) { cin >> str[i]; sort(str[i].begin(), str[i].end()); } sort(str + 1, str + 1 + n); string pre = str[1]; int cnt = 1; for (int i = 2; i <= n; i++) { if (str[i] == pre) { cnt++; } else { ans += cnt * (cnt - 1) / 2; cnt = 1; pre = str[i]; } } ans += cnt * (cnt - 1) / 2; printf("%lld\n", ans); return 0; }
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
749,739
749,740
u287323477
cpp
p02947
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { string t; cin >> t; sort(t.begin(), t.end()); s[i] = t; } sort(s.begin(), s.end()); // s.erase(unique(s.begin(),s.end()),s.end()); int ans = 0; int same = 1; for (int i = 1; i < n; i++) { if (s[i] == s[i - 1]) same++; else { ans += (same * (same - 1)) / 2; same = 1; } } ans += (same * (same - 1)) / 2; cout << ans; /*for(int i=0; i<n; i++){ cout<<s[i]<<endl; }*/ return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { string t; cin >> t; sort(t.begin(), t.end()); s[i] = t; } sort(s.begin(), s.end()); // s.erase(unique(s.begin(),s.end()),s.end()); ll ans = 0; ll same = 1; for (int i = 1; i < n; i++) { if (s[i] == s[i - 1]) same++; else { ans += (same * (same - 1)) / 2; same = 1; } } ans += (same * (same - 1)) / 2; cout << ans; /*for(int i=0; i<n; i++){ cout<<s[i]<<endl; }*/ return 0; }
[ "variable_declaration.type.change" ]
749,747
749,748
u129667379
cpp
p02947
#include <bits/stdc++.h> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) using namespace std; int N; vector<string> S; long long C2(int suc) { return suc * (suc - 1) / 2; } int main() { cin >> N; string s; rep(i, N) { cin >> s; sort(s.begin(), s.end()); S.push_back(s); } sort(S.begin(), S.end()); long long cnt = 0; int suc = 1; rep(i, N - 1) { if (S[i] == S[i + 1]) { suc++; } else { if (suc != 1) { cnt += C2(suc); } suc = 1; } } if (suc != 1) { cnt += C2(suc); } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) using namespace std; int N; vector<string> S; long long C2(long long suc) { return suc * (suc - 1) / 2; } int main() { cin >> N; string s; rep(i, N) { cin >> s; sort(s.begin(), s.end()); S.push_back(s); } sort(S.begin(), S.end()); long long cnt = 0; int suc = 1; rep(i, N - 1) { if (S[i] == S[i + 1]) { suc++; } else { if (suc != 1) { cnt += C2(suc); } suc = 1; } } if (suc != 1) { cnt += C2(suc); } cout << cnt << endl; return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
749,749
749,750
u499824662
cpp
p02947
#include <bits/stdc++.h> #define fastIO \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); using namespace std; const int inf = (int)1e9 + 7; int n; map<string, int> m; int main() { fastIO; cin >> n; for (int i = 0; i < n; i++) { string x; cin >> x; sort(x.begin(), x.end()); m[x]++; } long long ans = 0; for (auto x : m) { ans += ((x.second * (x.second - 1)) / 2); } cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> #define fastIO \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); using namespace std; const int inf = (int)1e9 + 7; int n; map<string, long long int> m; int main() { fastIO; cin >> n; for (int i = 0; i < n; i++) { string x; cin >> x; sort(x.begin(), x.end()); m[x]++; } long long int ans = 0; for (auto x : m) { ans += ((x.second * (x.second - 1)) / 2); } cout << ans << '\n'; return 0; }
[ "variable_declaration.type.widen.change" ]
749,751
749,752
u377947781
cpp
p02947
#define rep(i, a, b) for (int i = a; i < b; ++i) #define repr(i, a, b) for (int i = a; i > b; --i) #define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb) #define null NULL #define eps 0.000000001 #define mod 1000000007 #define PI 3.14159265358979323846 #define pb push_back #define pf push_front #define mp make_pair #define fi first #define se second #define ALL(V) V.begin(), V.end() #define sz(V) (int)V.size() #define _ << " " << #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef pair<int, pair<int, int>> iii; typedef vector<ii> vii; int main() { ios_base::sync_with_stdio(0); cin.tie(0); // freopen ("test.txt","r",stdin); ll n; cin >> n; string arr[n]; for (int i = 0; i < n; ++i) { cin >> arr[i]; sort(arr[i].begin(), arr[i].end()); } sort(arr, arr + n); ll ans = 0; ll c = 1; for (int i = 0; i < n - 1; ++i) { if (arr[i] != arr[i + 1]) { if (c >= 2) { ans += (c * (c - 1)) / 2; c = 1; continue; } } c++; } // cout<<c<<endl; if (c >= 2) { ans += (c * (c - 1)) / 2; } cout << ans; }
#define rep(i, a, b) for (int i = a; i < b; ++i) #define repr(i, a, b) for (int i = a; i > b; --i) #define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb) #define null NULL #define eps 0.000000001 #define mod 1000000007 #define PI 3.14159265358979323846 #define pb push_back #define pf push_front #define mp make_pair #define fi first #define se second #define ALL(V) V.begin(), V.end() #define sz(V) (int)V.size() #define _ << " " << #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef pair<int, pair<int, int>> iii; typedef vector<ii> vii; int main() { ios_base::sync_with_stdio(0); cin.tie(0); // // freopen ("test.txt","r",stdin); ll n; cin >> n; string arr[n]; for (int i = 0; i < n; ++i) { cin >> arr[i]; sort(arr[i].begin(), arr[i].end()); } sort(arr, arr + n); /*for (int i = 0; i < n; ++i) { cout<<arr[i]<<" "; } cout<<endl;*/ ll ans = 0; ll c = 1; for (int i = 0; i < n - 1; ++i) { if (arr[i] != arr[i + 1]) { if (c >= 2) { ans += (c * (c - 1)) / 2; c = 1; } continue; } c++; } // cout<<c<<endl; if (c >= 2) { ans += (c * (c - 1)) / 2; } cout << ans; }
[]
749,755
749,756
u853795518
cpp
p02947
#include <algorithm> #include <bits/stdc++.h> #include <cstdio> #include <cstring> #include <iostream> #include <vector> #define rep(a, b, c) for (ll a = b; a <= c; a++) #define per(a, b, c) for (ll a = b; a >= c; a--) #define pb push_back #define mk make_pair #define pii pair<int, int> #define mem(a, b) memset(a, b, sizeof(a)) using namespace std; typedef long long ll; typedef double db; const int inf = 0x3f3f3f3f; const int N = 1e5 + 5; int n, m; string s; map<string, int> mp; int main() { cin >> n; rep(i, 1, n) { cin >> s; sort(s.begin(), s.end()); if (mp[s] > 0) mp[s]++; else mp[s] = 1; } int ans = 0; for (auto x : mp) { int y = x.second; // printf("y=%d\n",y); ans += (y * (y - 1)) / 2; } cout << ans << endl; return 0; }
#include <algorithm> #include <bits/stdc++.h> #include <cstdio> #include <cstring> #include <iostream> #include <vector> #define rep(a, b, c) for (ll a = b; a <= c; a++) #define per(a, b, c) for (ll a = b; a >= c; a--) #define pb push_back #define mk make_pair #define pii pair<int, int> #define mem(a, b) memset(a, b, sizeof(a)) using namespace std; typedef long long ll; typedef double db; const int inf = 0x3f3f3f3f; const int N = 1e5 + 5; int n, m; string s; map<string, ll> mp; int main() { cin >> n; rep(i, 1, n) { cin >> s; sort(s.begin(), s.end()); if (mp[s] > 0) mp[s]++; else mp[s] = 1; } ll ans = 0; for (auto x : mp) { ll y = x.second; // printf("y=%d\n",y); ans += (y * (y - 1)) / 2; } cout << ans << endl; return 0; }
[ "variable_declaration.type.change" ]
749,757
749,758
u493249745
cpp
p02947
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define rep2(i, start, end) for (int i = start; i < end; i++) #define ll long long const ll N = 4e3 + 200; const ll INF = 0x3f3f3f3f; int main() { int n; cin >> n; std::vector<string> v; map<string, int> mp; rep(i, n) { string s; cin >> s; sort(s.begin(), s.end()); // cout<<s<<endl; if (mp[s] == 0) { v.push_back(s); } mp[s]++; } int len = v.size(); ll sum = 0; rep(i, len) { int k = mp[v[i]]; if (k >= 2) sum += (k * (k - 1)) / 2; } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define rep2(i, start, end) for (int i = start; i < end; i++) #define ll long long const ll N = 4e3 + 200; const ll INF = 0x3f3f3f3f; int main() { ll n; cin >> n; std::vector<string> v; map<string, ll> mp; rep(i, n) { string s; cin >> s; sort(s.begin(), s.end()); // cout<<s<<endl; if (mp[s] == 0) { v.push_back(s); } mp[s]++; } int len = v.size(); ll sum = 0; rep(i, len) { ll k = mp[v[i]]; if (k >= 2) sum += (k * (k - 1)) / 2; } cout << sum << endl; return 0; }
[ "variable_declaration.type.change" ]
749,759
749,760
u624688258
cpp
p02947
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string buf; map<string, int> t; for (int i = 0; i < n; i++) { cin >> buf; sort(buf.begin(), buf.end()); if (t.count(buf) == 0) t.insert(make_pair(buf, 1)); else t.at(buf)++; } long long a = 0; for (auto i : t) { a += i.second * (i.second - 1) / 2; } cout << a << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string buf; map<string, int> t; for (int i = 0; i < n; i++) { cin >> buf; sort(buf.begin(), buf.end()); if (t.count(buf) == 0) t.insert(make_pair(buf, 1)); else t.at(buf)++; } long long a = 0; for (auto i : t) { a += (long long)i.second * (i.second - 1) / 2; } cout << a << endl; return 0; }
[ "type_conversion.add" ]
749,761
749,762
u331948661
cpp
p02947
#include <bits/stdc++.h> using namespace std; template <typename T> T load() { T r; cin >> r; return r; } template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); auto n = load<int>(); auto counts = map<array<int, 26>, int>(); for (auto i = 0; i < n; ++i) { auto count = array<int, 26>{}; auto text = load<string>(); for (auto chr : text) ++count[chr - 'a']; ++counts[count]; } auto answer = 0ll; for (auto &&entry : counts) answer += entry.second * (entry.second - 1) / 2; cout << answer << '\n'; }
#include <bits/stdc++.h> using namespace std; template <typename T> T load() { T r; cin >> r; return r; } template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); auto n = load<int>(); auto counts = map<array<int, 26>, int>(); for (auto i = 0; i < n; ++i) { auto count = array<int, 26>{}; auto text = load<string>(); for (auto chr : text) ++count[chr - 'a']; ++counts[count]; } auto answer = 0ll; for (auto &&entry : counts) answer += (long long)entry.second * (entry.second - 1) / 2; cout << answer << '\n'; }
[ "type_conversion.add" ]
749,763
749,764
u870233611
cpp
p02947
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) typedef long long ll; typedef pair<ll, ll> P; const int MAX = 1e5 + 10; const int INF = 1e9; const int MOD = 1e9 + 7; int N; string s[MAX]; int main() { cin >> N; rep(i, N) cin >> s[i]; rep(i, N) { sort(s[i].begin(), s[i].end()); } sort(s, s + N); map<string, int> m; rep(i, N) { m[s[i]]++; } ll ans = 0; for (auto i : m) { ans += i.second * (i.second - 1) / 2; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) typedef long long ll; typedef pair<ll, ll> P; const int MAX = 1e5 + 10; const int INF = 1e9; const int MOD = 1e9 + 7; int N; string s[MAX]; int main() { cin >> N; rep(i, N) cin >> s[i]; rep(i, N) { sort(s[i].begin(), s[i].end()); } sort(s, s + N); map<string, ll> m; rep(i, N) { m[s[i]]++; } ll ans = 0; for (auto i : m) { ans += (ll)i.second * (i.second - 1) / 2; } cout << ans << endl; }
[ "type_conversion.add" ]
749,765
749,766
u992875223
cpp
p02947
#include <bits/stdc++.h> using namespace std; using ll = long long int; int n; map<string, int> mp; int main() { cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; sort(s.begin(), s.end()); mp[s]++; } ll ans = 0; for (auto e : mp) { int cnt = e.second; ans += cnt * (cnt - 1) / 2; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long int; int n; map<string, ll> mp; int main() { cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; sort(s.begin(), s.end()); mp[s]++; } ll ans = 0; for (auto e : mp) { ll cnt = e.second; ans += cnt * (cnt - 1) / 2; } cout << ans << endl; }
[ "variable_declaration.type.change" ]
749,767
749,768
u194268736
cpp
p02947
#include <iostream> #include <algorithm> #include <cstdio> #include <cstdlib> #include <fstream> #include <iomanip> #include <map> #include <queue> #include <stack> #include <string> #include <typeinfo> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) #define REP2(i, s, n) for (int i = s; i < n; i++) #define REP_1(i, n) for (int i = 1; i < n + 1; i++) #define bitSearch(bit, n) for (int bit = 0; bit < (1 << N); bit++) using namespace std; void printAns(long long a) { cout << a << endl; } void yesno(bool a) { if (a) cout << "Yes" << endl; else cout << "No" << endl; } void YESNO(bool a) { if (a) cout << "YES" << endl; else cout << "NO" << endl; } typedef long long ll; typedef unsigned long ul; typedef long double ld; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } // ll INF = 10000000; // ll mod = 1000000007;//10^9+7 // using Graph = vector<vector<pair<int, int>>>; // Graph G(100100); //番号ズレ注意!! int main() { int N; cin >> N; vector<vector<char>> s(N); REP(i, N) { REP(j, 10) { char c; cin >> c; s[i].push_back(c); } } REP(i, N) { sort(s[i].begin(), s[i].end()); } sort(s.begin(), s.end()); vector<int> same; ll cnt = 1; REP(i, N) { if (s[i] == s[i + 1]) { cnt++; } else { same.push_back(cnt); cnt = 1; } } ll ans = 0; REP(i, same.size()) { ans += same[i] * (same[i] - 1) / 2; } printAns(ans); }
#include <iostream> #include <algorithm> #include <cstdio> #include <cstdlib> #include <fstream> #include <iomanip> #include <map> #include <queue> #include <stack> #include <string> #include <typeinfo> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) #define REP2(i, s, n) for (int i = s; i < n; i++) #define REP_1(i, n) for (int i = 1; i < n + 1; i++) #define bitSearch(bit, n) for (int bit = 0; bit < (1 << N); bit++) using namespace std; void printAns(long long a) { cout << a << endl; } void yesno(bool a) { if (a) cout << "Yes" << endl; else cout << "No" << endl; } void YESNO(bool a) { if (a) cout << "YES" << endl; else cout << "NO" << endl; } typedef long long ll; typedef unsigned long ul; typedef long double ld; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } // ll INF = 10000000; // ll mod = 1000000007;//10^9+7 // using Graph = vector<vector<pair<int, int>>>; // Graph G(100100); //番号ズレ注意!! int main() { int N; cin >> N; vector<vector<char>> s(N); REP(i, N) { REP(j, 10) { char c; cin >> c; s[i].push_back(c); } } REP(i, N) { sort(s[i].begin(), s[i].end()); } sort(s.begin(), s.end()); vector<ll> same; ll cnt = 1; REP(i, N) { if (s[i] == s[i + 1]) { cnt++; } else { same.push_back(cnt); cnt = 1; } } ll ans = 0; REP(i, same.size()) { ans += same[i] * (same[i] - 1) / 2; } printAns(ans); }
[]
749,771
749,772
u741556152
cpp
p02947
#include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define ll long long #define vi vector<ll> #define sll(x) scanf("%lld", &x) #define prll(x) printf("%lld ", x) #define pri(x) printf("%d ", x) #define si(x) scanf("%d", &x) #define el printf("\n") #define pb push_back #define f first #define s second #define arrondi(a) (long long)floor(a + 0.5); #define NIL -1 ll N = 500005; ll MAX = 9223372036854775807; ll MOD = 1000000007; long double PI = 4 * atan(1); int main() { IOS; cout.precision(30); int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; } map<string, int> mp; for (int i = 0; i < n; i++) { sort(s[i].begin(), s[i].end()); mp[s[i]]++; } ll ans = 0; for (map<string, int>::iterator it = mp.begin(); it != mp.end(); it++) { ans += (it->second - 1) * (it->second) / 2; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define ll long long #define vi vector<ll> #define sll(x) scanf("%lld", &x) #define prll(x) printf("%lld ", x) #define pri(x) printf("%d ", x) #define si(x) scanf("%d", &x) #define el printf("\n") #define pb push_back #define f first #define s second #define arrondi(a) (long long)floor(a + 0.5); #define NIL -1 ll N = 500005; ll MAX = 9223372036854775807; ll MOD = 1000000007; long double PI = 4 * atan(1); int main() { IOS; cout.precision(30); int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; } map<string, ll> mp; for (int i = 0; i < n; i++) { sort(s[i].begin(), s[i].end()); mp[s[i]]++; } ll ans = 0; for (map<string, ll>::iterator it = mp.begin(); it != mp.end(); it++) { ans += ((it->second - 1) * (it->second)) / 2; } cout << ans; return 0; }
[ "control_flow.loop.for.initializer.change" ]
749,775
749,776
u514114987
cpp
p02947
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--) #define DEBUG(x) cout << #x << ": " << (x) << endl #define PRINT(x) cout << x << endl #define all(x) x.begin(), x.end() int main() { int N; cin >> N; unordered_map<string, ll> M; REP(i, N) { string s; cin >> s; sort(s.begin(), s.end()); M[s]++; } ll ans = 0; for (auto m : M) { if (m.second == 1) continue; int tmp = m.second - 1; ans += (tmp * (tmp + 1)) / 2; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--) #define DEBUG(x) cout << #x << ": " << (x) << endl #define PRINT(x) cout << x << endl #define all(x) x.begin(), x.end() int main() { int N; cin >> N; unordered_map<string, ll> M; REP(i, N) { string s; cin >> s; sort(s.begin(), s.end()); M[s]++; } ll ans = 0; for (auto m : M) { if (m.second == 1) continue; ll tmp = m.second - 1; ans += (tmp * (tmp + 1)) / 2; } cout << ans << endl; }
[ "variable_declaration.type.change" ]
749,777
749,778
u239375815
cpp
p02947
#include <bits/stdc++.h> using namespace std; long long fs = 0, n; string s; map<string, int> mp; vector<string> ans; int main() { int i; cin >> n; for (i = 0; i < n; i++) { cin >> s; sort(s.begin(), s.end()); mp[s]++; if (mp[s] == 1) { ans.push_back(s); } } for (i = 0; i < ans.size(); i++) { if (mp[ans[i]] > 1) { fs += mp[ans[i]] * (mp[ans[i]] - 1) / 2; } } cout << fs << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long fs = 0, n; string s; map<string, long long> mp; vector<string> ans; int main() { long long i; cin >> n; for (i = 0; i < n; i++) { cin >> s; sort(s.begin(), s.end()); mp[s]++; if (mp[s] == 1) { ans.push_back(s); } } for (i = 0; i < ans.size(); i++) { if (mp[ans[i]] > 1) { fs += mp[ans[i]] * (mp[ans[i]] - 1) / 2; } } cout << fs << endl; return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
749,779
749,780
u038054933
cpp
p02947
#include <algorithm> #include <iostream> #include <math.h> #include <queue> #include <stdio.h> #include <string.h> #include <vector> #define testin freopen("1.txt", "r", stdin); #define testout freopen("out.txt", "w", stdout); #define ll long long using namespace std; const int maxn = (int)1e5 + 10; struct node { char c[20]; void getdata() { cin >> c; sort(c, c + strlen(c)); } } s[maxn]; int cmp(struct node a, struct node b) { return strcmp(a.c, b.c) > 0; } int main() { int n, cnt; ll ans = 0; cin >> n; for (int i = 0; i < n; i++) s[i].getdata(); sort(s, s + n, cmp); int now = 0; while (now < n) { cnt = 1; while (strcmp(s[now + 1].c, s[now].c) == 0) { cnt++; now++; if (now == n - 1) break; } ans += ((cnt - 1) * cnt) / 2; now++; } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <math.h> #include <queue> #include <stdio.h> #include <string.h> #include <vector> #define testin freopen("1.txt", "r", stdin); #define testout freopen("out.txt", "w", stdout); #define ll long long using namespace std; const int maxn = (int)1e5 + 10; struct node { char c[20]; void getdata() { cin >> c; sort(c, c + strlen(c)); } } s[maxn]; int cmp(struct node a, struct node b) { return strcmp(a.c, b.c) > 0; } int main() { int n; ll ans = 0, cnt; cin >> n; for (int i = 0; i < n; i++) s[i].getdata(); sort(s, s + n, cmp); int now = 0; while (now < n) { cnt = 1; while (strcmp(s[now + 1].c, s[now].c) == 0) { cnt++; now++; if (now == n - 1) break; } ans += ((cnt - 1) * cnt) / 2; now++; } cout << ans << endl; return 0; }
[ "variable_declaration.remove", "variable_declaration.add" ]
749,781
749,782
u558099842
cpp
p02947
#include <algorithm> #include <cassert> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; typedef long long ll; int main() { int N; cin >> N; vector<string> v(N); for (int i = 0; i < N; ++i) { string s; cin >> s; sort(s.begin(), s.end()); v[i] = s; } sort(v.begin(), v.end()); ll ans = 0; string cur = v[0]; int cnt = 1; for (int i = 1; i < N; ++i) { if (v[i] == cur) { ++cnt; } else { ans += cnt * (cnt - 1) / 2; cur = v[i]; cnt = 1; } } ans += cnt * (cnt - 1) / 2; cout << ans << endl; return 0; }
#include <algorithm> #include <cassert> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; typedef long long ll; int main() { int N; cin >> N; vector<string> v(N); for (int i = 0; i < N; ++i) { string s; cin >> s; sort(s.begin(), s.end()); v[i] = s; } sort(v.begin(), v.end()); ll ans = 0; string cur = v[0]; ll cnt = 1; for (int i = 1; i < N; ++i) { if (v[i] == cur) { ++cnt; } else { ans += cnt * (cnt - 1) / 2; cur = v[i]; cnt = 1; } } ans += cnt * (cnt - 1) / 2; cout << ans << endl; return 0; }
[ "variable_declaration.type.change" ]
749,785
749,786
u045679746
cpp
p02947
#include <algorithm> #include <array> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; #define INF 10e17 #define rep(i, n) for (long long i = 0; i < n; i++) #define repr(i, n, m) for (long long i = m; i < n; i++) #define END cout << endl #define MOD 1000000007 #define pb push_back #define sorti(x) sort(x.begin(), x.end()) #define sortd(x) sort(x.begin(), x.end(), std::greater<long long>()) #define debug(x) std::cerr << (x) << std::endl; #define roll(x) \ for (auto &&itr : x) { \ debug(itr); \ } template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t; } template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t; } int main() { ll n; cin >> n; vector<string> s(n); map<string, int> p; rep(i, n) { array<char, 26> arr; cin >> s[i]; sort(s[i].begin(), s[i].end()); p[s[i]] += 1; } ll ans = 0; for (auto itr : p) { // cout << itr.second << endl; ans += itr.second * (itr.second - 1) / 2; } cout << ans << endl; }
#include <algorithm> #include <array> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; #define INF 10e17 #define rep(i, n) for (long long i = 0; i < n; i++) #define repr(i, n, m) for (long long i = m; i < n; i++) #define END cout << endl #define MOD 1000000007 #define pb push_back #define sorti(x) sort(x.begin(), x.end()) #define sortd(x) sort(x.begin(), x.end(), std::greater<long long>()) #define debug(x) std::cerr << (x) << std::endl; #define roll(x) \ for (auto &&itr : x) { \ debug(itr); \ } template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t; } template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t; } int main() { ll n; cin >> n; vector<string> s(n); map<string, ll> p; rep(i, n) { array<char, 26> arr; cin >> s[i]; sort(s[i].begin(), s[i].end()); p[s[i]] += 1; } ll ans = 0; for (auto itr : p) { // cout << itr.second << endl; ans += itr.second * (itr.second - 1) / 2; } cout << ans << endl; }
[]
749,787
749,788
u898749314
cpp
p02947
#include <algorithm> #include <iostream> #include <string> #include <unordered_map> #include <vector> #define MOD 1000000007LL using namespace std; typedef long long ll; int main() { int n; cin >> n; unordered_map<string, int> mp; for (int i = 0; i < n; i++) { string s; cin >> s; sort(s.begin(), s.end()); mp[s] += 1; } ll ans = 0; for (pair<string, int> p : mp) { ll tmp = p.second; ll tmp2 = (tmp * (tmp - 1) / 2); ans = (ans + tmp2) % MOD; } cout << ans << endl; }
#include <algorithm> #include <iostream> #include <string> #include <unordered_map> #include <vector> #define MOD 1000000007LL using namespace std; typedef long long ll; int main() { int n; cin >> n; unordered_map<string, int> mp; for (int i = 0; i < n; i++) { string s; cin >> s; sort(s.begin(), s.end()); mp[s] += 1; } ll ans = 0; for (pair<string, int> p : mp) { ll tmp = p.second; ll tmp2 = (tmp * (tmp - 1) / 2); ans = (ans + tmp2); } cout << ans << endl; }
[ "expression.operation.binary.remove" ]
749,793
749,794
u508729896
cpp
p02947
#include <algorithm> #include <iostream> #include <map> #include <vector> using namespace std; typedef long long int ll; #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) int main(int argc, const char *argv[]) { int N; cin >> N; map<string, int> words; for (int i = 0; i < N; i++) { string S; cin >> S; sort(S.begin(), S.end()); words[S] += 1; } ll sum = 0; for (auto idx = words.begin(); idx != words.end(); idx++) { sum += idx->second * (idx->second - 1) / 2; } cout << sum; return 0; }
#include <algorithm> #include <iostream> #include <map> #include <vector> using namespace std; typedef long long int ll; #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) int main(int argc, const char *argv[]) { int N; cin >> N; map<string, ll> words; for (int i = 0; i < N; i++) { string S; cin >> S; sort(S.begin(), S.end()); words[S] += 1; } ll sum = 0; for (auto idx = words.begin(); idx != words.end(); idx++) { sum += idx->second * (idx->second - 1) / 2; } cout << sum; return 0; }
[]
749,795
749,796
u505025747
cpp
p02947
#include <algorithm> // sort #include <cmath> #include <iomanip> #include <iostream> #include <map> // pair #include <queue> #include <set> #include <string> #include <vector> #define ABS(x) ((x) > 0 ? (x) : -(x)) #define MIN(x, y) ((x) > (y) ? (y) : (x)) #define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0])) using namespace std; typedef long long ll; ll newton(long long int a, long long int b) { if (a == b) return a; while (a != 0 && b != 0) { if (a > b) { b += a; a = b - a; b -= a; } b %= a; } return a; } struct UnionFind { vector<int> p; UnionFind(int N) : p(N) { for (int i = 0; i < N; i++) { p[i] = i; } } int root(int x) { if (p[x] == x) return x; return p[x] = root(p[x]); } void unite(int x, int y) { int rx = root(x); int ry = root(y); if (rx == ry) return; p[rx] = ry; } bool issame(int x, int y) { int rx = root(x); int ry = root(y); return rx == ry; } }; //大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる ll div2mul_calc(ll a, ll b, ll m) { if (b == 0) { return 1; } else if (b % 2 == 0) { ll d = div2mul_calc(a, b / 2, m); return (d * d) % m; } else { return (a * div2mul_calc(a, b - 1, m)) % m; } } ll div2mul(ll n, ll mod) { return div2mul_calc(n, mod - 2, mod); } ll twoRow(ll a, ll b, ll mod) { ll ret = 1; for (ll i = 1; i <= a + b; ++i) { ret *= i; ret %= mod; } for (ll i = 1; i <= a; ++i) { ret *= div2mul(i, mod); ret %= mod; } for (ll i = 1; i <= b; ++i) { ret *= div2mul(i, mod); ret %= mod; } return ret; } vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end()); return (ret); } int main() { map<string, int> s; string once; int N; cin >> N; for (int i = 0; i < N; ++i) { cin >> once; sort(once.begin(), once.end()); if (s.count(once) == 0) s[once] = 1; else s[once]++; } ll ans = 0; for (auto i = s.begin(); i != s.end(); ++i) { // cout << i->first << " " << i->second << endl; ans += i->second * (i->second - 1) / 2; } cout << ans << endl; return 0; }
#include <algorithm> // sort #include <cmath> #include <iomanip> #include <iostream> #include <map> // pair #include <queue> #include <set> #include <string> #include <vector> #define ABS(x) ((x) > 0 ? (x) : -(x)) #define MIN(x, y) ((x) > (y) ? (y) : (x)) #define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0])) using namespace std; typedef long long ll; ll newton(long long int a, long long int b) { if (a == b) return a; while (a != 0 && b != 0) { if (a > b) { b += a; a = b - a; b -= a; } b %= a; } return a; } struct UnionFind { vector<int> p; UnionFind(int N) : p(N) { for (int i = 0; i < N; i++) { p[i] = i; } } int root(int x) { if (p[x] == x) return x; return p[x] = root(p[x]); } void unite(int x, int y) { int rx = root(x); int ry = root(y); if (rx == ry) return; p[rx] = ry; } bool issame(int x, int y) { int rx = root(x); int ry = root(y); return rx == ry; } }; //大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる ll div2mul_calc(ll a, ll b, ll m) { if (b == 0) { return 1; } else if (b % 2 == 0) { ll d = div2mul_calc(a, b / 2, m); return (d * d) % m; } else { return (a * div2mul_calc(a, b - 1, m)) % m; } } ll div2mul(ll n, ll mod) { return div2mul_calc(n, mod - 2, mod); } ll twoRow(ll a, ll b, ll mod) { ll ret = 1; for (ll i = 1; i <= a + b; ++i) { ret *= i; ret %= mod; } for (ll i = 1; i <= a; ++i) { ret *= div2mul(i, mod); ret %= mod; } for (ll i = 1; i <= b; ++i) { ret *= div2mul(i, mod); ret %= mod; } return ret; } vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end()); return (ret); } int main() { map<string, ll> s; string once; ll N; cin >> N; for (int i = 0; i < N; ++i) { cin >> once; sort(once.begin(), once.end()); if (s.count(once) == 0) s[once] = 1; else s[once]++; } ll ans = 0; for (auto i = s.begin(); i != s.end(); ++i) { // cout << i->first << " " << i->second << endl; ans += i->second * (i->second - 1) / 2; } cout << ans << endl; return 0; }
[ "variable_declaration.type.change" ]
749,799
749,800
u869595612
cpp
p02947
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; const int MOD = 1000000007; typedef long long ll; typedef pair<ll, ll> p; const int INF = (1 << 28); const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0}; const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define INF 2e9 #define ALL(v) v.begin(), v.end() int n; string s[100000]; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; int ans = 0; for (int i = 0; i < n; i++) { cin >> s[i]; } for (int i = 0; i < n; i++) { sort(s[i].begin(), s[i].end()); } sort(s, s + n); int count = 1; for (int i = 1; i < n; i++) { if (s[i] == s[i - 1]) { ans += count; count++; } else { count = 1; } } cout << ans << "\n"; }
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; const int MOD = 1000000007; typedef long long ll; typedef pair<ll, ll> p; const int INF = (1 << 28); const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0}; const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define INF 2e9 #define ALL(v) v.begin(), v.end() int n; string s[100000]; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; ll ans = 0; for (int i = 0; i < n; i++) { cin >> s[i]; } for (int i = 0; i < n; i++) { sort(s[i].begin(), s[i].end()); } sort(s, s + n); int count = 1; for (int i = 1; i < n; i++) { if (s[i] == s[i - 1]) { ans += count; count++; } else { count = 1; } } cout << ans << "\n"; }
[ "variable_declaration.type.change" ]
749,803
749,804
u155416173
cpp
p02947
#include <bits/stdc++.h> #define ll long long using namespace std; int n; map<string, int> m; ll sol; int main() { cin >> n; for (int i = 0; i < n; ++i) { string s; cin >> s; sort(s.begin(), s.end()); if (m.count(s)) m[s]++; else m.insert({s, 1}); } for (auto kv : m) sol += kv.second * (kv.second - 1) / 2; cout << sol; return 0; }
#include <bits/stdc++.h> #define ll long long using namespace std; int n; map<string, int> m; ll sol; int main() { cin >> n; for (int i = 0; i < n; ++i) { string s; cin >> s; sort(s.begin(), s.end()); if (m.count(s)) m[s]++; else m.insert({s, 1}); } for (auto kv : m) sol += ((ll)kv.second) * (kv.second - 1) / 2; cout << sol; return 0; }
[]
749,809
749,810
u905164447
cpp
p02947
/* * * Author : Amit Kumar * Date : August 10 * */ #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <memory.h> #include <numeric> #include <set> #include <sstream> #include <stack> #include <utility> #include <vector> #define FAST_INPUT_OUTPUT //#define MORE_THAN_ONE_TESTCASE // COMMENT IT #define vi vector<int> #define vl vector<long long> #define mii map<int, int> #define mll map<long long, long long> #define msi map<string, i> #define msl map<string, long long> #define umii unordered_map<int, int> #define umll unordered_map<long long, long long> #define umsi unordered_map<string, int> #define umsl map<string, long long> #define si set<int> #define sl set<long long> #define pii pair<int, int> #define psi pair<string, int> #define psl pair<string, long> #define pll pair<long long, long long> #define vpii vector<pii> #define vpll vector<pll> #define vpsi vector<psi> #define vpsl vector<psl> #define pqi priority_queue<int> #define pql priority_queue<long long> #define ub upper_bound #define lb lower_bound #define bint long long int #define ff first #define ss second #define all(x) x.begin(), x.end() #define pb push_back #define eb emplace_back #define mp make_pair #define iv(v) \ for (auto &i : v) { \ cin >> i; \ } #define ov(v) \ for (auto i : v) { \ cout << i << " "; \ } \ cout << endl; #define ovn(v) \ for (auto i : v) { \ cout << i << endl; \ } #define euv(v) \ for (auto i : v) { \ cerr << i << " "; \ } \ cerr << endl; #define eovn(v) \ for (auto i : v) { \ cerr << i << endl; \ } #define os(s) \ for (auto itr : s) { \ cout << itr << " "; \ } \ cout << endl; #define osn(s) \ for (auto itr : s) { \ cout << itr << endl; \ } #define eos(s) \ for (auto itr : s) { \ cerr << itr << " "; \ } \ cerr << endl; #define eosn(s) \ for (auto itr : s) { \ cerr << itr << endl; \ } #define rep(x) for (auto i = 0; i < (x); ++i) #define _rep(a, b) for (auto i = (a); i < (b); ++i) #define ef else if #define wh while #define el else #define ivv(x) \ int x; \ cin >> x #define lv(x) \ bint x; \ cin >> x #define sv(x) \ string x; \ cin >> x #define cv(x) \ char x; \ cin >> x #define fv(x) \ float x; \ cin >> x #define dv(x) \ double x; \ cin >> x #define endl '\n' using namespace std; auto SOLUTION_FUNCTION(void) -> void { // your solution goes here ivv(n); map<string, int> m; while (n--) { sv(s); sort(all(s)); m[s]++; } bint counter = 0; for (auto itr = m.begin(); itr != m.end(); ++itr) { counter += (itr->ss * (itr->ss - 1)) / 2; } cout << counter << endl; return; } int main(void) { #ifdef FAST_INPUT_OUTPUT ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout << setprecision(10); cout << fixed; cout << boolalpha; #endif #ifdef MY_LOCAL_PROJECT freopen("input", "r", stdin); freopen("output", "w", stdout); #endif int testcase = 1; #ifdef MORE_THAN_ONE_TESTCASE cin >> testcase; #endif while (testcase--) { SOLUTION_FUNCTION(); } #ifdef MY_LOCAL_PROJECT cout << "Time : " << 1.0 * (double)clock() / CLOCKS_PER_SEC << endl; #endif return 0; }
/* * * Author : Amit Kumar * Date : August 10 * */ #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <memory.h> #include <numeric> #include <set> #include <sstream> #include <stack> #include <utility> #include <vector> #define FAST_INPUT_OUTPUT //#define MORE_THAN_ONE_TESTCASE // COMMENT IT #define vi vector<int> #define vl vector<long long> #define mii map<int, int> #define mll map<long long, long long> #define msi map<string, i> #define msl map<string, long long> #define umii unordered_map<int, int> #define umll unordered_map<long long, long long> #define umsi unordered_map<string, int> #define umsl map<string, long long> #define si set<int> #define sl set<long long> #define pii pair<int, int> #define psi pair<string, int> #define psl pair<string, long> #define pll pair<long long, long long> #define vpii vector<pii> #define vpll vector<pll> #define vpsi vector<psi> #define vpsl vector<psl> #define pqi priority_queue<int> #define pql priority_queue<long long> #define ub upper_bound #define lb lower_bound #define bint long long int #define ff first #define ss second #define all(x) x.begin(), x.end() #define pb push_back #define eb emplace_back #define mp make_pair #define iv(v) \ for (auto &i : v) { \ cin >> i; \ } #define ov(v) \ for (auto i : v) { \ cout << i << " "; \ } \ cout << endl; #define ovn(v) \ for (auto i : v) { \ cout << i << endl; \ } #define euv(v) \ for (auto i : v) { \ cerr << i << " "; \ } \ cerr << endl; #define eovn(v) \ for (auto i : v) { \ cerr << i << endl; \ } #define os(s) \ for (auto itr : s) { \ cout << itr << " "; \ } \ cout << endl; #define osn(s) \ for (auto itr : s) { \ cout << itr << endl; \ } #define eos(s) \ for (auto itr : s) { \ cerr << itr << " "; \ } \ cerr << endl; #define eosn(s) \ for (auto itr : s) { \ cerr << itr << endl; \ } #define rep(x) for (auto i = 0; i < (x); ++i) #define _rep(a, b) for (auto i = (a); i < (b); ++i) #define ef else if #define wh while #define el else #define ivv(x) \ int x; \ cin >> x #define lv(x) \ bint x; \ cin >> x #define sv(x) \ string x; \ cin >> x #define cv(x) \ char x; \ cin >> x #define fv(x) \ float x; \ cin >> x #define dv(x) \ double x; \ cin >> x #define endl '\n' using namespace std; auto SOLUTION_FUNCTION(void) -> void { // your solution goes here ivv(n); map<string, bint> m; while (n--) { sv(s); sort(all(s)); m[s]++; } bint counter = 0; for (auto itr = m.begin(); itr != m.end(); ++itr) { counter += (itr->ss * (itr->ss - 1LL)) / 2LL; } cout << counter << endl; return; } int main(void) { #ifdef FAST_INPUT_OUTPUT ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout << setprecision(10); cout << fixed; cout << boolalpha; #endif #ifdef MY_LOCAL_PROJECT freopen("input", "r", stdin); freopen("output", "w", stdout); #endif int testcase = 1; #ifdef MORE_THAN_ONE_TESTCASE cin >> testcase; #endif while (testcase--) { SOLUTION_FUNCTION(); } #ifdef MY_LOCAL_PROJECT cout << "Time : " << 1.0 * (double)clock() / CLOCKS_PER_SEC << endl; #endif return 0; }
[ "literal.number.type.widen.change" ]
749,815
749,816
u896543512
cpp
p02947
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; map<string, int> m; cin >> n; int ans = 0; for (int i = 0; i < n; i++) { cin >> s; sort(s.begin(), s.end()); ans += m[s]; m[s] += 1; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; map<string, int> m; cin >> n; long long int ans = 0; for (int i = 0; i < n; i++) { cin >> s; sort(s.begin(), s.end()); ans += m[s]; m[s] += 1; } cout << ans << endl; return 0; }
[ "variable_declaration.type.widen.change" ]
749,817
749,818
u225181923
cpp
p02947
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s[n]; long ans = 0; unordered_map<string, long> mp; for (int i = 0; i < n; i++) { char str_s[11]; cin >> str_s; sort(str_s, str_s + 10); s[i] = string(str_s); } for (int i = 0; i < n; i++) { mp[s[i]]++; } for (auto p : mp) { int x = p.second; ans += x * (x - 1) / 2; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s[n]; long ans = 0; unordered_map<string, long> mp; for (int i = 0; i < n; i++) { char str_s[11]; cin >> str_s; sort(str_s, str_s + 10); s[i] = string(str_s); } for (int i = 0; i < n; i++) { mp[s[i]]++; } for (auto p : mp) { long x = p.second; ans += x * (x - 1) / 2; } cout << ans << endl; return 0; }
[ "variable_declaration.type.primitive.change" ]
749,827
749,828
u280512618
cpp
p02947
/*Alohomora*/ #include <bits/stdc++.h> #define ll long long #define fl(i, n) for (i = 0; i < n; i++) #define fld(i, a, b) for (i = a; i > b; i--) #define fli(i, a, n) for (i = a; i < n; i++) #define inp(i, a, n) \ for (i = 0; i < n; i++) { \ cin >> a[i]; \ } #define op(i, a, n) \ for (i = 0; i < n; i++) { \ cout << a[i] << " "; \ } #define pb push_back #define mp make_pair #define mod1 100000000000007 #define speedup ios_base::sync_with_stdio(false), cin.tie(0) using namespace std; ll fact(ll n) { if (n == 0) { return 1; } return (n * fact(n - 1)) % mod1; } ll power(ll x, ll y) { ll temp; if (y == 0) return 1; temp = power(x, y / 2); if (y % 2 == 0) return temp * temp; else return x * temp * temp; } ll gcd(ll a, ll b) { if (b == 0) { return a; } gcd(b, a % b); } ll a[2000000]; void sieve() { ll i, j; fli(i, 2, 1000001) { if (a[i] == 0) { for (j = i * i; j < 1000001; j += i) { a[j] = 1; } } } } map<ll, vector<ll>> m1; vector<ll> v1; bool compar(const pair<ll, ll> &a, const pair<ll, ll> &b) { return (a.second < b.second); } ll level[1000000]; vector<ll> root; set<ll> s1; void factorise(long long n) { while (!(n % 2)) { n >>= 1; s1.insert(2); } for (long long i = 3; i <= sqrt(n); i += 2) { while (n % i == 0) { s1.insert(i); n = n / i; } } if (n > 2) { s1.insert(n); } } void comp() { ll a, b, c, d, e, i; cin >> a; map<string, int> m1; string s; fl(i, a) { cin >> s; sort(s.begin(), s.end()); m1[s]++; } map<string, int>::iterator it = m1.begin(); ll ans = 0; while (it != m1.end()) { ans += (it->second * (it->second - 1)) / 2; it++; } cout << ans << "\n"; } int main() { speedup; ll i = 0, t; ll n; // cin>>t; t = 1; while (t--) { comp(); } }
/*Alohomora*/ #include <bits/stdc++.h> #define ll long long #define fl(i, n) for (i = 0; i < n; i++) #define fld(i, a, b) for (i = a; i > b; i--) #define fli(i, a, n) for (i = a; i < n; i++) #define inp(i, a, n) \ for (i = 0; i < n; i++) { \ cin >> a[i]; \ } #define op(i, a, n) \ for (i = 0; i < n; i++) { \ cout << a[i] << " "; \ } #define pb push_back #define mp make_pair #define mod1 100000000000007 #define speedup ios_base::sync_with_stdio(false), cin.tie(0) using namespace std; ll fact(ll n) { if (n == 0) { return 1; } return (n * fact(n - 1)) % mod1; } ll power(ll x, ll y) { ll temp; if (y == 0) return 1; temp = power(x, y / 2); if (y % 2 == 0) return temp * temp; else return x * temp * temp; } ll gcd(ll a, ll b) { if (b == 0) { return a; } gcd(b, a % b); } ll a[2000000]; void sieve() { ll i, j; fli(i, 2, 1000001) { if (a[i] == 0) { for (j = i * i; j < 1000001; j += i) { a[j] = 1; } } } } map<ll, vector<ll>> m1; vector<ll> v1; bool compar(const pair<ll, ll> &a, const pair<ll, ll> &b) { return (a.second < b.second); } ll level[1000000]; vector<ll> root; set<ll> s1; void factorise(long long n) { while (!(n % 2)) { n >>= 1; s1.insert(2); } for (long long i = 3; i <= sqrt(n); i += 2) { while (n % i == 0) { s1.insert(i); n = n / i; } } if (n > 2) { s1.insert(n); } } void comp() { ll a, b, c, d, e, i; cin >> a; map<string, ll> m1; string s; fl(i, a) { cin >> s; sort(s.begin(), s.end()); m1[s]++; } map<string, ll>::iterator it = m1.begin(); ll ans = 0; while (it != m1.end()) { ans += (it->second * (it->second - 1)) / 2; it++; } cout << ans << "\n"; } int main() { speedup; ll i = 0, t; ll n; // cin>>t; t = 1; while (t--) { comp(); } }
[]
749,829
749,830
u037844054
cpp
p02947
#include <algorithm> #include <iostream> #include <map> using lint = int64_t; using namespace std; int main() { lint N; string s[100010] = {}; map<string, lint> m; cin >> N; for (int i = 0; i < N; i++) cin >> s[i]; for (int i = 0; i < N; i++) { sort(s[i].begin(), s[i].end()); m[s[i]]++; } lint ans = 0; for (auto &&i : m) { int n = i.second; ans += ((n * (n - 1)) / 2); } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <map> using lint = int64_t; using namespace std; int main() { lint N; string s[100010] = {}; map<string, lint> m; cin >> N; for (int i = 0; i < N; i++) cin >> s[i]; for (int i = 0; i < N; i++) { sort(s[i].begin(), s[i].end()); m[s[i]]++; } lint ans = 0; for (auto &&i : m) { lint n = i.second; ans += ((n * (n - 1)) / 2); } cout << ans << endl; return 0; }
[ "variable_declaration.type.change" ]
749,831
749,832
u021423660
cpp
p02947
#include <bits/stdc++.h> using namespace std; long long a[234234], ans; int b[234], n; char s[123]; int main() { int i, j; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%s", s + 1); for (j = 1; j <= 10; j++) b[j] = s[j] - 'a'; sort(b + 1, b + 1 + 10); for (j = 1; j <= 10; j++) a[i] = a[i] * 10 + b[j]; } sort(a + 1, a + 1 + n); a[n + 1] = -1; for (i = 1; i <= n; i++) { j = i + 1; while (a[j] == a[i]) j++; ans += (long long)(j - i) * (j - i - 1) / 2; i = j - 1; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; long long a[234234], ans; int b[234], n; char s[123]; int main() { int i, j; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%s", s + 1); for (j = 1; j <= 10; j++) b[j] = s[j] - 'a'; sort(b + 1, b + 1 + 10); for (j = 1; j <= 10; j++) a[i] = a[i] * 26 + b[j]; } sort(a + 1, a + 1 + n); a[n + 1] = -1; for (i = 1; i <= n; i++) { j = i + 1; while (a[j] == a[i]) j++; ans += (long long)(j - i) * (j - i - 1) / 2; i = j - 1; } cout << ans << endl; }
[ "literal.number.change", "assignment.value.change", "expression.operation.binary.change" ]
749,833
749,834
u437187732
cpp
p02947
#include <bits/stdc++.h> #define IO \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) using namespace std; int n; string s; map<string, int> m; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> s; sort(s.begin(), s.end()); m[s]++; } long long ans = 0; for (auto it : m) { ans = ans + (it.second * (it.second - 1)) / 2; } cout << ans; return 0; }
#include <bits/stdc++.h> #define IO \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) using namespace std; int n; string s; map<string, long long> m; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> s; sort(s.begin(), s.end()); m[s]++; } long long ans = 0; for (auto it : m) { ans = ans + (it.second * (it.second - 1)) / 2; } cout << ans; return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
749,837
749,838
u172288782
cpp
p02947
// by Himanshu Shukla #pragma GCC optimize("O2") #include <bits/stdc++.h> using namespace std; #define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define ll long long #define v32 vector<int> #define v64 vector<ll> #define s32 set<int> #define s64 set<ll> #define graph vector<s32> #define p32 pair<int, int> #define p64 pair<ll, ll> #define fi first #define se second #define ln '\n' #define debug(x) cout << (#x) << ": " << (x) << ln mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); } inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); } const double EPS = 1e-6; const ll MOD = 1e9 + 7; template <typename T, typename U> ostream &operator<<(ostream &out, const pair<T, U> &p) { out << '[' << p.fi << ", " << p.se << ']'; return out; } template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args> void print_container(const ContainerType<ValueType, Args...> &c) { cout << "{ "; for (const auto &v : c) cout << v << ' '; cout << '}' << ln; } int main() { FASTIO; int n; cin >> n; string str; map<string, int> M; for (int i = 0; i < n; i++) { cin >> str; sort(str.begin(), str.end()); M[str]++; } ll ans = 0; for (auto itr : M) ans += (itr.se * (itr.se - 1)) / 2; cout << ans << ln; return 0; }
// by Himanshu Shukla #pragma GCC optimize("O2") #include <bits/stdc++.h> using namespace std; #define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define ll long long #define v32 vector<int> #define v64 vector<ll> #define s32 set<int> #define s64 set<ll> #define graph vector<s32> #define p32 pair<int, int> #define p64 pair<ll, ll> #define fi first #define se second #define ln '\n' #define debug(x) cout << (#x) << ": " << (x) << ln mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); } inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); } const double EPS = 1e-6; const ll MOD = 1e9 + 7; template <typename T, typename U> ostream &operator<<(ostream &out, const pair<T, U> &p) { out << '[' << p.fi << ", " << p.se << ']'; return out; } template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args> void print_container(const ContainerType<ValueType, Args...> &c) { cout << "{ "; for (const auto &v : c) cout << v << ' '; cout << '}' << ln; } int main() { FASTIO; int n; cin >> n; string str; map<string, int> M; for (int i = 0; i < n; i++) { cin >> str; sort(str.begin(), str.end()); M[str]++; } ll ans = 0; for (auto itr : M) ans += (1ll * itr.se * (itr.se - 1)) / 2; cout << ans << ln; return 0; }
[ "assignment.change" ]
749,839
749,840
u257192613
cpp
p02947
#include <bits/stdc++.h> using namespace std; #define pp pair<int, int> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define ll long long ll MOD = 1000000007; int inf = 1000000000; ll INF = 10000000000000000; int main() { int n; cin >> n; vector<string> s(n); rep(i, n) { string u; cin >> u; sort(u.begin(), u.end()); s.at(i) = u; } sort(s.begin(), s.end()); int q = 1; int ans = 0; rep(i, n - 1) { if (s.at(i) == s.at(i + 1)) { q++; } else { ans += q * (q - 1) / 2; q = 1; } } ans += q * (q - 1) / 2; q = 1; cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define pp pair<int, int> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define ll long long ll MOD = 1000000007; int inf = 1000000000; ll INF = 10000000000000000; int main() { int n; cin >> n; vector<string> s(n); rep(i, n) { string u; cin >> u; sort(u.begin(), u.end()); s.at(i) = u; } sort(s.begin(), s.end()); ll q = 1; ll ans = 0; rep(i, n - 1) { if (s.at(i) == s.at(i + 1)) { q++; } else { ans += q * (q - 1) / 2; q = 1; } } ans += q * (q - 1) / 2; q = 1; cout << ans << endl; }
[ "variable_declaration.type.change" ]
749,841
749,842
u112775098
cpp
p02947
#include <bits/stdc++.h> using namespace std; int n, ans; string s; map<string, int> mp; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> s, sort(s.begin(), s.end()); ans += mp[s]; mp[s]++; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; long long n, ans; string s; map<string, long long> mp; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> s, sort(s.begin(), s.end()); ans += mp[s]; mp[s]++; } cout << ans; return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
749,847
749,848
u789439610
cpp
p02947
#include <bits/stdc++.h> using namespace std; string s[100005]; int n; map<string, int> mp; int main() { int ans = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { cin >> s[i]; sort(s[i].begin(), s[i].end()); ans += mp[s[i]]; mp[s[i]]++; } printf("%d", ans); }
#include <bits/stdc++.h> using namespace std; string s[100005]; int n; map<string, long> mp; int main() { long long ans = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { cin >> s[i]; sort(s[i].begin(), s[i].end()); ans += mp[s[i]]; mp[s[i]]++; } printf("%lld", ans); }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change", "literal.string.change", "call.arguments.change", "io.output.change" ]
749,849
749,850
u543848816
cpp
p02947
#include <bits/stdc++.h> using namespace std; int n, ans; char a[12]; map<string, int> mp; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%s", a); sort(a, a + 10); ans += mp[a]; mp[a]++; } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int n; long long ans; char a[12]; map<string, int> mp; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%s", a); sort(a, a + 10); ans += mp[a]; mp[a]++; } printf("%lld\n", ans); return 0; }
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
749,852
749,853
u196341564
cpp
p02947
#include <algorithm> #include <iostream> #include <map> #include <string> using namespace std; int main() { int n; cin >> n; map<string, int> mp; for (int i = 0; i < n; i++) { string str; cin >> str; sort(begin(str), end(str)); mp[str]++; } int ans = 0; for (auto &&i : mp) { ans += i.second * (i.second - 1) / 2; } cout << ans << "\n"; }
#include <algorithm> #include <iostream> #include <map> #include <string> using namespace std; int main() { int n; cin >> n; map<string, long long> mp; for (int i = 0; i < n; i++) { string str; cin >> str; sort(begin(str), end(str)); mp[str]++; } long long ans = 0; for (auto &&i : mp) { ans += i.second * (i.second - 1) / 2; } cout << ans << "\n"; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
749,858
749,857
u752074356
cpp
p02947
#include <bits/stdc++.h> #define el "\n" #define ll long long #define ull unsigned long long int #define pb push_back #define mp make_pair #define X first #define Y second #define M 1000000007 #define all(v) v.begin(), v.end() using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; string s; unordered_map<string, int> mp; for (int i = 0; i < n; i++) { cin >> s; sort(all(s)); mp[s]++; } ll ans = 0, tmp; for (auto x : mp) { tmp = (x.Y) * (x.Y - 1); tmp /= 2; ans += tmp; } cout << ans << el; return 0; }
#include <bits/stdc++.h> #define el "\n" #define ll long long #define ull unsigned long long int #define pb push_back #define mp make_pair #define X first #define Y second #define M 1000000007 #define all(v) v.begin(), v.end() using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n; cin >> n; string s; unordered_map<string, ll> mp; for (int i = 0; i < n; i++) { cin >> s; sort(all(s)); mp[s]++; } ll ans = 0, tmp = 0; for (auto x : mp) { tmp = (x.Y) * (x.Y - 1); tmp /= 2; ans += tmp; } cout << ans << el; return 0; }
[ "variable_declaration.type.change", "variable_declaration.value.change" ]
749,859
749,860
u245531500
cpp
p02947
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long int ll; typedef pair<int, int> P; #define all(x) x.begin(), x.end() const ll mod = 1e9 + 7; const ll INF = 1e9; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; } for (int i = 0; i < n; i++) { sort(all(s[i])); } sort(all(s)); // for(auto x : s){ // cout<<x<<endl; // } int ans = 0; int cnt = 0; for (int i = 1; i < n; i++) { if (s[i] == s[i - 1]) { if (cnt == 0) cnt = 2; else cnt++; } else { ans += cnt * (cnt - 1) / 2; cnt = 0; } } ans += cnt * (cnt - 1) / 2; cout << ans << endl; return 0; }
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long int ll; typedef pair<int, int> P; #define all(x) x.begin(), x.end() const ll mod = 1e9 + 7; const ll INF = 1e9; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; } for (int i = 0; i < n; i++) { sort(all(s[i])); } sort(all(s)); // for(auto x : s){ // cout<<x<<endl; // } ll ans = 0; ll cnt = 0; for (int i = 1; i < n; i++) { if (s[i] == s[i - 1]) { if (cnt == 0) cnt = 2; else cnt++; } else { ans += cnt * (cnt - 1) / 2; cnt = 0; } } ans += cnt * (cnt - 1) / 2; cout << ans << endl; return 0; }
[ "variable_declaration.type.change" ]
749,861
749,862
u700986952
cpp
p02947
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>; #define rep(i, n) for (ll i = 0; i < n; i++) #define all(i) i.begin(), i.end() template <class T, class U> bool cmax(T &a, U b) { if (a < b) { a = b; return true; } else return false; } template <class T, class U> bool cmin(T &a, U b) { if (a > b) { a = b; return true; } else return false; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; map<string, int> s; rep(i, n) { string t; cin >> t; sort(all(t)); s[t]++; } ll ans = 0; for (auto &&i : s) { ans += i.second * (i.second - 1) / 2; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>; #define rep(i, n) for (ll i = 0; i < n; i++) #define all(i) i.begin(), i.end() template <class T, class U> bool cmax(T &a, U b) { if (a < b) { a = b; return true; } else return false; } template <class T, class U> bool cmin(T &a, U b) { if (a > b) { a = b; return true; } else return false; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; map<string, ll> s; rep(i, n) { string t; cin >> t; sort(all(t)); s[t]++; } ll ans = 0; for (auto &&i : s) { ans += i.second * (i.second - 1) / 2; } cout << ans << endl; }
[]
749,865
749,866
u366644013
cpp
p02947
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, int> pli; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<pii> vpii; typedef vector<pli> vpli; inline ll read() { ll Hashimoto = 0; bool Kanna = 1; char I_Love = getchar(); while (I_Love < '0' || I_Love > '9') { if (I_Love == '-') Kanna = 0; I_Love = getchar(); } while (I_Love >= '0' && I_Love <= '9') { Hashimoto = Hashimoto * 10 + I_Love - '0'; I_Love = getchar(); } return (Kanna ? Hashimoto : -Hashimoto); } template <typename T1, typename T2> inline void Umax(T1 &a, T2 b) { if (a < b) a = b; } template <typename T1, typename T2> inline void Umin(T1 &a, T2 b) { if (a > b) a = b; } #define I_Love_Hashimoto_Kanna main #define fastio \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define filein(s) freopen(s, "r", stdin); #define fileout(s) freopen(s, "w", stdout); #define file freopen("I_Love_Hashimoto_Kanna.out", "w", stdout); #define RE cout << "I_Love_Hashimoto_Kanna" << endl; #define Tone(Kanna) cout << Kanna << endl; #define Tall(Hashimoto, Kanna) \ for (int I_Love = 0; I_Love < (Kanna); ++I_Love) \ cout << Hashimoto[I_Love] << (I_Love == (Kanna)-1 ? "\n" : " "); #define FOR(I_Love, Hashimoto, Kanna) \ for (int I_Love = Hashimoto; I_Love < (Kanna); ++I_Love) #define MP(Hashimoto, Kanna) make_pair(Hashimoto, Kanna) #define REV(Kanna) reverse(Kanna.begin(), Kanna.end()); #define SORT(Kanna) sort(Kanna.begin(), Kanna.end()); #define UNIQUE(Kanna) \ Kanna.erase(unique(Kanna.begin(), Kanna.end()), Kanna.end()); #define inf (1000000000) #define linf (1000000000000000000ll) #define mod (1000000007) int n; vector<string> s; int I_Love_Hashimoto_Kanna() { //完全想清楚了再开始写。 //写不顺、不知道怎么写、很乱的时候,停下来好好想想。 //做得慢总比做不出好。 fastio; n = read(); FOR(i, 0, n) { char str[11]; scanf("%s", str); sort(str, str + 10); s.push_back(""); FOR(j, 0, 10) s[i].push_back(str[j]); } SORT(s); int cur = 1; ll ans = 0; FOR(i, 1, n) { if (s[i] == s[i - 1]) cur++; else { ans += cur * (cur - 1) / 2; cur = 1; } } ans += cur * (cur - 1) / 2; Tone(ans) return 0; }
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, int> pli; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<pii> vpii; typedef vector<pli> vpli; inline ll read() { ll Hashimoto = 0; bool Kanna = 1; char I_Love = getchar(); while (I_Love < '0' || I_Love > '9') { if (I_Love == '-') Kanna = 0; I_Love = getchar(); } while (I_Love >= '0' && I_Love <= '9') { Hashimoto = Hashimoto * 10 + I_Love - '0'; I_Love = getchar(); } return (Kanna ? Hashimoto : -Hashimoto); } template <typename T1, typename T2> inline void Umax(T1 &a, T2 b) { if (a < b) a = b; } template <typename T1, typename T2> inline void Umin(T1 &a, T2 b) { if (a > b) a = b; } #define I_Love_Hashimoto_Kanna main #define fastio \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define filein(s) freopen(s, "r", stdin); #define fileout(s) freopen(s, "w", stdout); #define file freopen("I_Love_Hashimoto_Kanna.out", "w", stdout); #define RE cout << "I_Love_Hashimoto_Kanna" << endl; #define Tone(Kanna) cout << Kanna << endl; #define Tall(Hashimoto, Kanna) \ for (int I_Love = 0; I_Love < (Kanna); ++I_Love) \ cout << Hashimoto[I_Love] << (I_Love == (Kanna)-1 ? "\n" : " "); #define FOR(I_Love, Hashimoto, Kanna) \ for (int I_Love = Hashimoto; I_Love < (Kanna); ++I_Love) #define MP(Hashimoto, Kanna) make_pair(Hashimoto, Kanna) #define REV(Kanna) reverse(Kanna.begin(), Kanna.end()); #define SORT(Kanna) sort(Kanna.begin(), Kanna.end()); #define UNIQUE(Kanna) \ Kanna.erase(unique(Kanna.begin(), Kanna.end()), Kanna.end()); #define inf (1000000000) #define linf (1000000000000000000ll) #define mod (1000000007) int n; vector<string> s; int I_Love_Hashimoto_Kanna() { //完全想清楚了再开始写。 //写不顺、不知道怎么写、很乱的时候,停下来好好想想。 //做得慢总比做不出好。 fastio; n = read(); FOR(i, 0, n) { char str[11]; scanf("%s", str); sort(str, str + 10); s.push_back(""); FOR(j, 0, 10) s[i].push_back(str[j]); } SORT(s); ll cur = 1; ll ans = 0; FOR(i, 1, n) { if (s[i] == s[i - 1]) cur++; else { ans += cur * (cur - 1) / 2; cur = 1; } } ans += cur * (cur - 1) / 2; Tone(ans) return 0; }
[ "variable_declaration.type.change" ]
749,867
749,868
u004424779
cpp
p02947
#include <bits/stdc++.h> #define ff first #define ss second #define ii pair<int, int> #define iill pair<ii, ll> #define ill pair<int, ll> #define MAXN #define EPS 1e-9 #define MAXLOG #define MOD #define prt(a) printf("%d\n", a) #define prt2(a, b) printf("%d %d\n", a, b) #define prt3(a, b, c) printf("%d %d %d\n", a, b, c) #define sc(a) scanf("%d", &a) #define sc2(a, b) scanf("%d %d", &a, &b) #define sc3(a, b, c) scanf("%d %d %d", &a, &b, &c) #define readArr(arr, n) \ for (int i = 0; i < n; i++) \ scanf("%d", &arr[i]); #define EPS 1e-9 #define ll long long using namespace std; int main() { map<string, int> words; int n; cin >> n; string word; int res = 0; for (int i = 0; i < n; i++) { cin >> word; sort(word.begin(), word.end()); res += words[word]; words[word]++; } printf("%d\n", res); return 0; }
#include <bits/stdc++.h> #define ff first #define ss second #define ii pair<int, int> #define iill pair<ii, ll> #define ill pair<int, ll> #define MAXN #define EPS 1e-9 #define MAXLOG #define MOD #define prt(a) printf("%d\n", a) #define prt2(a, b) printf("%d %d\n", a, b) #define prt3(a, b, c) printf("%d %d %d\n", a, b, c) #define sc(a) scanf("%d", &a) #define sc2(a, b) scanf("%d %d", &a, &b) #define sc3(a, b, c) scanf("%d %d %d", &a, &b, &c) #define readArr(arr, n) \ for (int i = 0; i < n; i++) \ scanf("%d", &arr[i]); #define EPS 1e-9 #define ll long long using namespace std; int main() { map<string, ll> words; int n; cin >> n; string word; ll res = 0; for (int i = 0; i < n; i++) { cin >> word; sort(word.begin(), word.end()); res += words[word]; words[word]++; } printf("%lld\n", res); return 0; }
[ "variable_declaration.type.change", "literal.string.change", "call.arguments.change", "io.output.change" ]
749,869
749,870
u934308457
cpp
p02947
#include <bits/stdc++.h> using namespace std; #define rep(i, N) for (int i = 0, i##_max = (N); i < i##_max; ++i) #define repp(i, l, r) for (int i = (l), i##_max = (r); i < i##_max; ++i) #define per(i, N) for (int i = (N)-1; i >= 0; --i) #define perr(i, l, r) for (int i = r - 1, i##_min(l); i >= i##_min; --i) #define all(arr) (arr).begin(), (arr).end() #define SP << " " << #define SPF << " " #define SPEEDUP \ cin.tie(0); \ ios::sync_with_stdio(false); #define MAX_I INT_MAX // 1e9 #define MIN_I INT_MIN //-1e9 #define MAX_UI UINT_MAX // 1e9 #define MAX_LL LLONG_MAX // 1e18 #define MIN_LL LLONG_MIN //-1e18 #define MAX_ULL ULLONG_MAX // 1e19 typedef long long ll; typedef pair<int, int> PII; typedef pair<char, char> PCC; typedef pair<ll, ll> PLL; typedef pair<char, int> PCI; typedef pair<int, char> PIC; typedef pair<ll, int> PLI; typedef pair<int, ll> PIL; typedef pair<ll, char> PLC; typedef pair<char, ll> PCL; inline void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; } inline void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; } inline void Yay(bool b) { cout << (b ? "Yay!" : ":(") << endl; } int main(void) { SPEEDUP cout << setprecision(15); int N; cin >> N; map<string, ll> mp; rep(i, N) { string s; cin >> s; sort(all(s)); ++mp[s]; } ll ans = 0; for (const pair<string, int> &m : mp) { ans += m.second * (m.second - 1); } cout << ans / 2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, N) for (int i = 0, i##_max = (N); i < i##_max; ++i) #define repp(i, l, r) for (int i = (l), i##_max = (r); i < i##_max; ++i) #define per(i, N) for (int i = (N)-1; i >= 0; --i) #define perr(i, l, r) for (int i = r - 1, i##_min(l); i >= i##_min; --i) #define all(arr) (arr).begin(), (arr).end() #define SP << " " << #define SPF << " " #define SPEEDUP \ cin.tie(0); \ ios::sync_with_stdio(false); #define MAX_I INT_MAX // 1e9 #define MIN_I INT_MIN //-1e9 #define MAX_UI UINT_MAX // 1e9 #define MAX_LL LLONG_MAX // 1e18 #define MIN_LL LLONG_MIN //-1e18 #define MAX_ULL ULLONG_MAX // 1e19 typedef long long ll; typedef pair<int, int> PII; typedef pair<char, char> PCC; typedef pair<ll, ll> PLL; typedef pair<char, int> PCI; typedef pair<int, char> PIC; typedef pair<ll, int> PLI; typedef pair<int, ll> PIL; typedef pair<ll, char> PLC; typedef pair<char, ll> PCL; inline void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; } inline void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; } inline void Yay(bool b) { cout << (b ? "Yay!" : ":(") << endl; } int main(void) { SPEEDUP cout << setprecision(15); int N; cin >> N; map<string, ll> mp; rep(i, N) { string s; cin >> s; sort(all(s)); ++mp[s]; } ll ans = 0; for (const pair<string, ll> &m : mp) { ans += m.second * (m.second - 1); } cout << ans / 2 << endl; return 0; }
[]
749,871
749,872
u069450081
cpp
p02947
#include <algorithm> #include <array> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <tuple> #include <unistd.h> #include <vector> #define ALL(a) (a).begin(), (a).end() const long long MOD = 1000000007; //いろんなstlの使い方 https://qiita.com/tukejonny/items/f4013547df761a0b3523 // http://y-mazun.hatenablog.com/entry/20111202/1322840281 using namespace std; struct point { int x; int y; }; // https://ei1333.github.io/luzhiled/snippets/structure/union-find.html template <typename T> struct WeightedUnionFind { vector<int> data; vector<T> ws; WeightedUnionFind() {} WeightedUnionFind(int sz) : data(sz, -1), ws(sz) {} int find(int k) { if (data[k] < 0) return k; auto par = find(data[k]); ws[k] += ws[data[k]]; return data[k] = par; } T weight(int t) { find(t); return ws[t]; } bool unite(int x, int y, T w) { w += weight(x); w -= weight(y); x = find(x), y = find(y); if (x == y) return false; if (data[x] > data[y]) { swap(x, y); w *= -1; } data[x] += data[y]; data[y] = x; ws[y] = w; return true; } T diff(int x, int y) { return weight(y) - weight(x); } }; long long gcd(long long a, long long b) { if (a > b) { return gcd(b, a); } return a == 0 ? b : gcd(b % a, a); } long long lcm(long long m, long long n) { // 引数に0がある場合は0を返す if ((0 == m) || (0 == n)) return 0; return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n) } // lcm int input() { int x; cin >> x; return x; } int moji(char in) { int ans = (int)in - (int)'a'; if ((ans < 0) || (ans > 25)) { ans = 26; } return ans; } const int VV = 1; //場合に応じてVVの値のみ変更する必要あり // dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能 int cost[VV][VV]; int d[VV]; bool used[VV]; void dijkstra(int s) { fill(d, d + VV, 100000); fill(used, used + VV, false); d[s] = 0; while (true) { cout << "Hello" << endl; int v = -1; for (int u = 0; u < VV; u++) { if (!used[u] && (v == -1 || d[u] < d[v])) v = u; } if (v == -1) break; used[v] = true; for (int u = 0; u < VV; u++) { d[u] = min(d[u], d[v] + cost[v][u]); } } } int compare_int(const void *a, const void *b) // qsort(quick sort利用時に使用) { return *(int *)a - *(int *)b; } int binary_searchh(long long x, long long k[], int n) { int l = 0; int r = n; while (r - l >= 1) { int i = (l + r) / 2; if (k[i] == x) return i; else if (k[i] < x) l = i + 1; else r = i; } return -1; } struct File { int aa; int bb; File(const int &aa, const int &bb) : aa(aa), bb(bb) {} }; /*bool operator<(const File& a, const File& b) { // ファイル種別、ファイル名の順番で優先順位を付けて比較 return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb); }*/ long long kaijo(long long x) { long long l = 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 + 7; long long sum = 1; for (int i = x; i > 0; i--) { sum *= i; if (sum > l) { sum %= l; } } return sum; } template <class T> void chmin(T &a, T b) { if (a > b) { a = b; } } // formerは前方のindex(自分自身を含んで良い) template <class T> int former(const vector<T> &v, T x) { return upper_bound(v.begin(), v.end(), x) - v.begin() - 1; } // latterは後方のindex(自分自身を含んで良い) template <class T> int latter(const vector<T> &v, T x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); } struct UnionFind { // par[i]データiの属する木の親の番号。i==par[i]のときデータiは木の根ノードである vector<int> par; // sizes[i]:根ノードiの木に含まれるデータ数、iが根ノードでないときは無意味な値になる vector<int> sizes; UnionFind(int n) : par(n), sizes(n, 1) { //最初は全てのデータiがグループiに存在するものとして初期化 for (int i = 0; i < n; i++) { par[i] = i; } } //データxが属する木の根を得る int find(int x) { if (x == par[x]) { return x; } return par[x] = find(par[x]); } // 2つのデータx,yが属する木をマージする void unite(int x, int y) { //データの根ノードを得る x = find(x); y = find(y); //もしすでに同じ木に属しているならマージの必要はない if (x == y) { return; } // xの木がyの木よりも大きくなるようにする if (sizes[x] < sizes[y]) { swap(x, y); } // xがyの親になるように連結する par[y] = x; sizes[x] += sizes[y]; } // 2つのデータx,yが属する木が同じならtrueを返す bool same(int x, int y) { return find(x) == find(y); } //データxが含まれる木の大きさを返す int size(int x) { return sizes[find(x)]; } }; //クラスカル法 //頂点a,bをつなぐコストcostの(無向)辺 struct Edge { int a, b, cost; //コストの大小で順序定義 bool operator<(const Edge &o) const { return cost < o.cost; } }; //頂点数と辺集合の組として定義したグラフ /*struct Graph{ int n;//頂点数 vector<Edge>es;//辺集合 //クラスカル法で無向最小全域木のコストの和を計算する //グラフが非連結の時は最小全域森のコストの和になる //使い方http://dai1741.github.io/maximum-algo-2012/docs/minimum-spanning-tree/ int kruskal(){ //コストが小さい順にソーと sort(es.begin(),es.end()); UnionFind uf(n); int min_cost=0; for(int ei=0;ei<es.size();ei++){ Edge& e=es[ei]; if(!uf.same(e.a,e.b)){ //その辺によって2つの木が連結される min_cost+=e.cost; uf.unite(e.a,e.b); } } return min_cost; } };*/ //標準入力からグラフを読み込む /*Graph input_graph(){ Graph g; int m; cin>>g.n>>m; for(int i=0;i<m;i++){ Edge e; cin>>e.a>>e.b>>e.cost; g.es.push_back(e); } return g; }*/ long long labs(long long x) { if (x < 0) { return -x; } return x; } // a^n mod を計算する long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } // indexを用いてvectorから要素削除 template <typename T> void remove(std::vector<T> &vector, unsigned int index) { vector.erase(vector.begin() + index); } void modadd(long long &a, long long b) { a += b; if (a >= MOD) { a %= MOD; } } const int MAX = 100001; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } //木の直径 const int maxV = 2; vector<int> G[maxV]; // 頂点情報のみのグラフ // treeDFS(親, 現在地, 根から現在地までの距離, 根からの最大の距離, // 根から最大の距離となる頂点 void treeDFS(int from, int current, int dist, int &maxDist, int &maxVertex) { // 距離と終点を更新 if (dist > maxDist) { maxDist = dist; maxVertex = current; } for (auto to : G[current]) { // 逆流を防ぐ if (to == from) continue; treeDFS(current, to, dist + 1, maxDist, maxVertex); } } int getTreeDiameter() { int start = 0, end = 0, maxDist = 0; treeDFS(-1, start, 0, maxDist, end); start = end, end = 0, maxDist = 0; treeDFS(-1, start, 0, maxDist, end); return start; } int main() { int N; cin >> N; char s[N][10]; for (int i = 0; i < N; i++) { for (int j = 0; j < 10; j++) { cin >> s[i][j]; } sort(s[i], s[i] + 10); } vector<string> ss; for (int i = 0; i < N; i++) { string ll = ""; for (int j = 0; j < 10; j++) { ll += s[i][j]; } ss.push_back(ll); } sort(ss.begin(), ss.end()); long long ans = 0; int tmp = 1; for (int i = 0; i < N - 1; i++) { if (ss[i] == ss[i + 1]) { tmp++; } else { ans += (tmp * (tmp - 1)) / 2; tmp = 1; } } ans += (tmp * (tmp - 1)) / 2; cout << ans << endl; }
#include <algorithm> #include <array> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <tuple> #include <unistd.h> #include <vector> #define ALL(a) (a).begin(), (a).end() const long long MOD = 1000000007; //いろんなstlの使い方 https://qiita.com/tukejonny/items/f4013547df761a0b3523 // http://y-mazun.hatenablog.com/entry/20111202/1322840281 using namespace std; struct point { int x; int y; }; // https://ei1333.github.io/luzhiled/snippets/structure/union-find.html template <typename T> struct WeightedUnionFind { vector<int> data; vector<T> ws; WeightedUnionFind() {} WeightedUnionFind(int sz) : data(sz, -1), ws(sz) {} int find(int k) { if (data[k] < 0) return k; auto par = find(data[k]); ws[k] += ws[data[k]]; return data[k] = par; } T weight(int t) { find(t); return ws[t]; } bool unite(int x, int y, T w) { w += weight(x); w -= weight(y); x = find(x), y = find(y); if (x == y) return false; if (data[x] > data[y]) { swap(x, y); w *= -1; } data[x] += data[y]; data[y] = x; ws[y] = w; return true; } T diff(int x, int y) { return weight(y) - weight(x); } }; long long gcd(long long a, long long b) { if (a > b) { return gcd(b, a); } return a == 0 ? b : gcd(b % a, a); } long long lcm(long long m, long long n) { // 引数に0がある場合は0を返す if ((0 == m) || (0 == n)) return 0; return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n) } // lcm int input() { int x; cin >> x; return x; } int moji(char in) { int ans = (int)in - (int)'a'; if ((ans < 0) || (ans > 25)) { ans = 26; } return ans; } const int VV = 1; //場合に応じてVVの値のみ変更する必要あり // dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能 int cost[VV][VV]; int d[VV]; bool used[VV]; void dijkstra(int s) { fill(d, d + VV, 100000); fill(used, used + VV, false); d[s] = 0; while (true) { cout << "Hello" << endl; int v = -1; for (int u = 0; u < VV; u++) { if (!used[u] && (v == -1 || d[u] < d[v])) v = u; } if (v == -1) break; used[v] = true; for (int u = 0; u < VV; u++) { d[u] = min(d[u], d[v] + cost[v][u]); } } } int compare_int(const void *a, const void *b) // qsort(quick sort利用時に使用) { return *(int *)a - *(int *)b; } int binary_searchh(long long x, long long k[], int n) { int l = 0; int r = n; while (r - l >= 1) { int i = (l + r) / 2; if (k[i] == x) return i; else if (k[i] < x) l = i + 1; else r = i; } return -1; } struct File { int aa; int bb; File(const int &aa, const int &bb) : aa(aa), bb(bb) {} }; /*bool operator<(const File& a, const File& b) { // ファイル種別、ファイル名の順番で優先順位を付けて比較 return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb); }*/ long long kaijo(long long x) { long long l = 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 + 7; long long sum = 1; for (int i = x; i > 0; i--) { sum *= i; if (sum > l) { sum %= l; } } return sum; } template <class T> void chmin(T &a, T b) { if (a > b) { a = b; } } // formerは前方のindex(自分自身を含んで良い) template <class T> int former(const vector<T> &v, T x) { return upper_bound(v.begin(), v.end(), x) - v.begin() - 1; } // latterは後方のindex(自分自身を含んで良い) template <class T> int latter(const vector<T> &v, T x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); } struct UnionFind { // par[i]データiの属する木の親の番号。i==par[i]のときデータiは木の根ノードである vector<int> par; // sizes[i]:根ノードiの木に含まれるデータ数、iが根ノードでないときは無意味な値になる vector<int> sizes; UnionFind(int n) : par(n), sizes(n, 1) { //最初は全てのデータiがグループiに存在するものとして初期化 for (int i = 0; i < n; i++) { par[i] = i; } } //データxが属する木の根を得る int find(int x) { if (x == par[x]) { return x; } return par[x] = find(par[x]); } // 2つのデータx,yが属する木をマージする void unite(int x, int y) { //データの根ノードを得る x = find(x); y = find(y); //もしすでに同じ木に属しているならマージの必要はない if (x == y) { return; } // xの木がyの木よりも大きくなるようにする if (sizes[x] < sizes[y]) { swap(x, y); } // xがyの親になるように連結する par[y] = x; sizes[x] += sizes[y]; } // 2つのデータx,yが属する木が同じならtrueを返す bool same(int x, int y) { return find(x) == find(y); } //データxが含まれる木の大きさを返す int size(int x) { return sizes[find(x)]; } }; //クラスカル法 //頂点a,bをつなぐコストcostの(無向)辺 struct Edge { int a, b, cost; //コストの大小で順序定義 bool operator<(const Edge &o) const { return cost < o.cost; } }; //頂点数と辺集合の組として定義したグラフ /*struct Graph{ int n;//頂点数 vector<Edge>es;//辺集合 //クラスカル法で無向最小全域木のコストの和を計算する //グラフが非連結の時は最小全域森のコストの和になる //使い方http://dai1741.github.io/maximum-algo-2012/docs/minimum-spanning-tree/ int kruskal(){ //コストが小さい順にソーと sort(es.begin(),es.end()); UnionFind uf(n); int min_cost=0; for(int ei=0;ei<es.size();ei++){ Edge& e=es[ei]; if(!uf.same(e.a,e.b)){ //その辺によって2つの木が連結される min_cost+=e.cost; uf.unite(e.a,e.b); } } return min_cost; } };*/ //標準入力からグラフを読み込む /*Graph input_graph(){ Graph g; int m; cin>>g.n>>m; for(int i=0;i<m;i++){ Edge e; cin>>e.a>>e.b>>e.cost; g.es.push_back(e); } return g; }*/ long long labs(long long x) { if (x < 0) { return -x; } return x; } // a^n mod を計算する long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } // indexを用いてvectorから要素削除 template <typename T> void remove(std::vector<T> &vector, unsigned int index) { vector.erase(vector.begin() + index); } void modadd(long long &a, long long b) { a += b; if (a >= MOD) { a %= MOD; } } const int MAX = 100001; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } //木の直径 const int maxV = 2; vector<int> G[maxV]; // 頂点情報のみのグラフ // treeDFS(親, 現在地, 根から現在地までの距離, 根からの最大の距離, // 根から最大の距離となる頂点 void treeDFS(int from, int current, int dist, int &maxDist, int &maxVertex) { // 距離と終点を更新 if (dist > maxDist) { maxDist = dist; maxVertex = current; } for (auto to : G[current]) { // 逆流を防ぐ if (to == from) continue; treeDFS(current, to, dist + 1, maxDist, maxVertex); } } int getTreeDiameter() { int start = 0, end = 0, maxDist = 0; treeDFS(-1, start, 0, maxDist, end); start = end, end = 0, maxDist = 0; treeDFS(-1, start, 0, maxDist, end); return start; } int main() { long long N; cin >> N; char s[N][10]; for (int i = 0; i < N; i++) { for (int j = 0; j < 10; j++) { cin >> s[i][j]; } sort(s[i], s[i] + 10); } vector<string> ss; for (int i = 0; i < N; i++) { string ll = ""; for (int j = 0; j < 10; j++) { ll += s[i][j]; } ss.push_back(ll); } sort(ss.begin(), ss.end()); long long ans = 0; long long tmp = 1; for (int i = 0; i < N - 1; i++) { if (ss[i] == ss[i + 1]) { tmp++; } else { ans += (tmp * (tmp - 1)) / 2; tmp = 1; } } ans += (tmp * (tmp - 1)) / 2; cout << ans << endl; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
749,873
749,874
u334656323
cpp