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;
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());
}
ll ans = 0;
int count = 1;
sort(s.begin(), s.end());
string s_tmp = s[0];
for (int i = 1; i < n; i++) {
if (s[i] == s[i - 1])
count++;
else {
ans += count * (count - 1) / 2;
count = 1;
// s_tmp = s[i];
}
}
ans += count * (count - 1) / 2;
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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());
}
ll ans = 0;
ll count = 1;
sort(s.begin(), s.end());
string s_tmp = s[0];
for (int i = 1; i < n; i++) {
if (s[i] == s[i - 1])
count++;
else {
ans += count * (count - 1) / 2;
count = 1;
// s_tmp = s[i];
}
}
ans += count * (count - 1) / 2;
cout << ans << endl;
} | [
"variable_declaration.type.change"
] | 748,962 | 748,963 | u590000849 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long int ll;
typedef pair<int, int> P;
#define INF 1e9 + 7
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
string s[n];
rep(i, n) cin >> s[i];
ll ans = 0;
rep(i, n) { sort(s[i].begin(), s[i].end()); }
map<string, int> m;
rep(i, n) { m[s[i]]++; }
for (auto itr = m.begin(); itr != m.end(); itr++) {
// cout << itr->first << ":" << itr->second << endl;
ans += (itr->second * (itr->second - 1)) / 2;
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long int ll;
typedef pair<int, int> P;
#define INF 1e9 + 7
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
string s[n];
rep(i, n) cin >> s[i];
ll ans = 0;
rep(i, n) { sort(s[i].begin(), s[i].end()); }
map<string, int> m;
rep(i, n) { m[s[i]]++; }
for (auto itr = m.begin(); itr != m.end(); itr++) {
// cout << itr->first << ":" << itr->second << endl;
ans += (itr->second * (ll)(itr->second - 1)) / 2;
}
cout << ans << endl;
return 0;
} | [] | 748,978 | 748,979 | u241908712 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
string s[N];
for (int i = 0; i < N; i++) {
cin >> s[i];
sort(s[i].begin(), s[i].end());
}
int ans = 0;
unordered_map<string, int> mp;
for (int i = 0; i < N; i++) {
if (mp.find(s[i]) == mp.end()) {
mp[s[i]] = 1;
} else {
ans += mp.at(s[i]);
mp[s[i]]++;
}
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
string s[N];
for (int i = 0; i < N; i++) {
cin >> s[i];
sort(s[i].begin(), s[i].end());
}
long long int ans = 0;
unordered_map<string, int> mp;
for (int i = 0; i < N; i++) {
if (mp.find(s[i]) == mp.end()) {
mp[s[i]] = 1;
} else {
ans += mp.at(s[i]);
mp[s[i]]++;
}
}
cout << ans << endl;
return 0;
} | [
"variable_declaration.type.widen.change"
] | 748,988 | 748,989 | u703472020 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
string s[N];
for (int i = 0; i < N; i++) {
cin >> s[i];
sort(s[i].begin(), s[i].end());
}
int ans = 0;
unordered_map<string, int> mp;
for (int i = 0; i < N; i++) {
if (mp.find(s[i]) == mp.end()) {
mp[s[i]] = 0;
} else {
ans += mp.at(s[i]);
mp[s[i]]++;
}
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
string s[N];
for (int i = 0; i < N; i++) {
cin >> s[i];
sort(s[i].begin(), s[i].end());
}
long long int ans = 0;
unordered_map<string, int> mp;
for (int i = 0; i < N; i++) {
if (mp.find(s[i]) == mp.end()) {
mp[s[i]] = 1;
} else {
ans += mp.at(s[i]);
mp[s[i]]++;
}
}
cout << ans << endl;
return 0;
} | [
"literal.number.change",
"assignment.value.change"
] | 748,990 | 748,989 | u703472020 | cpp |
p02947 | #include <algorithm>
#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.at(i);
}
for (int i = 0; i < n; i++) {
sort(s.at(i).begin(), s.at(i).end());
}
sort(s.begin(), s.end());
int64_t count = 0;
int sc = 1;
string s0 = "a";
for (int i = 0; i < n - 1; i++) {
string s1 = s.at(i);
string s2 = s.at(i + 1);
if (s2 != s1) {
count += sc * (sc - 1) / 2;
sc = 1;
} else {
sc += 1;
}
}
if (sc != 1) {
count += sc * (sc - 1) / 2;
}
cout << count << endl;
}
| #include <algorithm>
#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.at(i);
}
for (int i = 0; i < n; i++) {
sort(s.at(i).begin(), s.at(i).end());
}
sort(s.begin(), s.end());
int64_t count = 0;
int64_t sc = 1;
string s0 = "a";
for (int i = 0; i < n - 1; i++) {
string s1 = s.at(i);
string s2 = s.at(i + 1);
if (s2 != s1) {
count += sc * (sc - 1) / 2;
sc = 1;
} else {
sc += 1;
}
}
if (sc != 1) {
count += sc * (sc - 1) / 2;
}
cout << count << endl;
} | [
"variable_declaration.type.primitive.change"
] | 748,991 | 748,992 | u507414360 | cpp |
p02947 | #include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using ll = long long;
using namespace std;
int main(void) {
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());
}
// unordered_set<string> cache;
unordered_map<string, int> cache;
// sort(s.begin(), s.end());
int ans = 0;
for (int i = 0; i < n; ++i) {
if (cache.count(s[i]) == 0) {
cache[s[i]]++;
} else {
ans += cache[s[i]]++;
}
// for(int j = i +1; j < n; ++j) {
// if (cache.count(s[j])!= 0) {
// ans++;
// }
/*
else if (s[i] == s[j]) {
ans++;
cache.insert(s[i]);
}
*/
// else {
// break;
//}
// }
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using ll = long long;
using namespace std;
int main(void) {
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());
}
// unordered_set<string> cache;
unordered_map<string, int> cache;
// sort(s.begin(), s.end());
ll ans = 0;
for (int i = 0; i < n; ++i) {
if (cache.count(s[i]) == 0) {
cache[s[i]]++;
} else {
ans += cache[s[i]]++;
}
// for(int j = i +1; j < n; ++j) {
// if (cache.count(s[j])!= 0) {
// ans++;
// }
/*
else if (s[i] == s[j]) {
ans++;
cache.insert(s[i]);
}
*/
// else {
// break;
//}
// }
}
cout << ans << endl;
return 0;
} | [
"variable_declaration.type.change"
] | 748,993 | 748,994 | u871841829 | cpp |
p02947 | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<string> s(n);
for (size_t i = 0; i < n; i++) {
cin >> s.at(i);
sort(s.at(i).begin(), s.at(i).end());
}
sort(s.begin(), s.end());
int64_t ans = 0;
int count = 0;
for (size_t i = 0; i < n; i++) {
/* code */
if (s.at(i) == s.at(i + 1)) {
count++;
ans += count;
} else {
count = 0;
}
}
cout << ans << endl;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<string> s(n);
for (size_t i = 0; i < n; i++) {
cin >> s.at(i);
sort(s.at(i).begin(), s.at(i).end());
}
sort(s.begin(), s.end());
int64_t ans = 0;
int count = 0;
for (size_t i = 0; i < n - 1; i++) {
/* code */
if (s.at(i) == s.at(i + 1)) {
count++;
ans += count;
} else {
count = 0;
}
}
cout << ans << endl;
} | [
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 748,995 | 748,996 | u229148215 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<string> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
map<string, int> m;
int ans = 0;
for (int i = 0; i < n; i++) {
string s = a[i];
sort(s.begin(), s.end());
if (m.count(s)) {
ans += m[s];
m[s]++;
} else
m.insert({s, 1});
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<string> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
map<string, int> m;
long ans = 0;
for (int i = 0; i < n; i++) {
string s = a[i];
sort(s.begin(), s.end());
if (m.count(s)) {
ans += m[s];
m[s]++;
} else
m.insert({s, 1});
}
cout << ans << endl;
return 0;
} | [
"variable_declaration.type.primitive.change"
] | 748,999 | 748,998 | u868863576 | cpp |
p02947 | #include <algorithm>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
int main() {
int N;
cin >> N;
map<string, ll> strcnt;
for (int i = 0; i < N; i++) {
string s;
cin >> s;
sort(s.begin(), s.end());
strcnt[s]++;
}
ll cnt = 0;
for (pair<string, int> p : strcnt) {
cnt += p.second * (p.second - 1) / 2;
}
cout << cnt << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
int main() {
int N;
cin >> N;
map<string, ll> strcnt;
for (int i = 0; i < N; i++) {
string s;
cin >> s;
sort(s.begin(), s.end());
strcnt[s]++;
}
ll ans = 0;
for (pair<string, ll> p : strcnt) {
ans += p.second * (p.second - 1) / 2;
}
cout << ans << endl;
return 0;
} | [
"variable_declaration.name.change",
"identifier.change",
"assignment.variable.change",
"io.output.change"
] | 749,000 | 749,001 | u503906942 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
set<string> c;
string str;
vector<string> s;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> str;
s.push_back(str);
int l = str.length();
sort(str.begin(), str.end());
c.insert(str);
}
map<string, int> m;
for (auto x : c) {
m[x] = 0;
}
for (int i = 0; i < n; i++) {
sort(s[i].begin(), s[i].end());
m[s[i]]++;
}
long int ans = 0;
for (auto x : c) {
ans += (m[x] * (m[x] - 1)) / 2;
}
cout << ans;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
set<string> c;
string str;
vector<string> s;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> str;
s.push_back(str);
int l = str.length();
sort(str.begin(), str.end());
c.insert(str);
}
map<string, int> m;
for (auto x : c) {
m[x] = 0;
}
for (int i = 0; i < n; i++) {
sort(s[i].begin(), s[i].end());
m[s[i]]++;
}
long int ans = 0;
for (auto x : c) {
ans += ((long)m[x] * (m[x] - 1)) / 2;
}
cout << ans;
return 0;
} | [
"type_conversion.add"
] | 749,007 | 749,008 | u471769750 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
set<string> c;
string str;
vector<string> s;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> str;
s.push_back(str);
int l = str.length();
sort(str.begin(), str.end());
c.insert(str);
}
map<string, int> m;
for (auto x : c) {
m[x] = 0;
}
for (int i = 0; i < n; i++) {
sort(s[i].begin(), s[i].end());
m[s[i]]++;
}
int ans = 0;
for (auto x : c) {
ans += (m[x] * (m[x] - 1)) / 2;
}
cout << ans;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
set<string> c;
string str;
vector<string> s;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> str;
s.push_back(str);
int l = str.length();
sort(str.begin(), str.end());
c.insert(str);
}
map<string, int> m;
for (auto x : c) {
m[x] = 0;
}
for (int i = 0; i < n; i++) {
sort(s[i].begin(), s[i].end());
m[s[i]]++;
}
long int ans = 0;
for (auto x : c) {
ans += ((long)m[x] * (m[x] - 1)) / 2;
}
cout << ans;
return 0;
} | [
"variable_declaration.type.widen.change"
] | 749,009 | 749,008 | u471769750 | cpp |
p02947 | #include <algorithm>
#include <iostream>
#include <map>
#include <string>
int main(int argc, char *argv[]) {
unsigned int N;
std::cin >> N;
std::string string[N];
std::map<std::string, int> map;
for (auto &s : string) {
std::cin >> s;
std::sort(s.begin(), s.end());
map[s]++;
}
int anagrams = 0;
int count;
for (auto &hist : map) {
count = hist.second;
if (count == 1) {
continue;
}
anagrams += ((count) * (count - 1)) / 2;
}
std::cout << anagrams << std::endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <string>
int main(int argc, char *argv[]) {
unsigned int N;
std::cin >> N;
std::string string[N];
std::map<std::string, int> map;
for (auto &s : string) {
std::cin >> s;
std::sort(s.begin(), s.end());
map[s]++;
}
long int anagrams = 0;
long int count;
for (auto &hist : map) {
count = hist.second;
if (count == 1) {
continue;
}
anagrams += (count) * (count - 1) / 2;
}
std::cout << anagrams << std::endl;
return 0;
}
| [
"variable_declaration.type.widen.change"
] | 749,010 | 749,011 | u436832975 | cpp |
p02947 | #include <algorithm>
#include <iostream>
#include <map>
#include <string>
int main(int argc, char *argv[]) {
unsigned int N;
std::cin >> N;
std::string string[N];
std::map<std::string, int> map;
for (auto &s : string) {
std::cin >> s;
std::sort(s.begin(), s.end());
map[s]++;
}
int anagrams = 0;
int count;
for (auto &hist : map) {
count = hist.second;
if (count == 1) {
continue;
}
anagrams += (count) * (count - 1) / 2;
}
std::cout << anagrams << std::endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <string>
int main(int argc, char *argv[]) {
unsigned int N;
std::cin >> N;
std::string string[N];
std::map<std::string, int> map;
for (auto &s : string) {
std::cin >> s;
std::sort(s.begin(), s.end());
map[s]++;
}
long int anagrams = 0;
long int count;
for (auto &hist : map) {
count = hist.second;
if (count == 1) {
continue;
}
anagrams += (count) * (count - 1) / 2;
}
std::cout << anagrams << std::endl;
return 0;
}
| [
"variable_declaration.type.widen.change"
] | 749,012 | 749,011 | u436832975 | cpp |
p02947 | #include <algorithm>
#include <iostream>
#include <map>
#include <string>
int main(int argc, char *argv[]) {
unsigned int N;
std::cin >> N;
std::string string[N];
std::map<std::string, int> map;
for (auto &s : string) {
std::cin >> s;
std::sort(s.begin(), s.end());
map[s]++;
}
int anagrams = 0;
int count;
for (auto &hist : map) {
count = hist.second;
if (count == 1) {
continue;
}
anagrams += (count) * (count - 1) / 2;
}
std::cout << anagrams << std::endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <string>
int main(int argc, char *argv[]) {
unsigned int N;
std::cin >> N;
std::string string[N];
std::map<std::string, int> map;
for (auto &s : string) {
std::cin >> s;
std::sort(s.begin(), s.end());
map[s]++;
}
long int anagrams = 0;
long int count;
for (auto &hist : map) {
count = hist.second;
if (count == 1) {
continue;
}
anagrams += ((count) * (count - 1)) / 2;
}
std::cout << anagrams << std::endl;
return 0;
}
| [
"variable_declaration.type.widen.change"
] | 749,012 | 749,013 | u436832975 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define p(x) cout << x << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
int main() {
int n;
cin >> n;
vector<string> ss(n);
rep(i, n) {
cin >> ss.at(i);
sort(all(ss.at(i)));
}
map<string, int> sm;
rep(i, n) { sm[ss.at(i)]++; }
ll count = 0;
for (auto i = sm.begin(); i != sm.end(); ++i) {
ll j = i->second;
count = j * (j - 1) / 2;
};
p(count);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define p(x) cout << x << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
int main() {
int n;
cin >> n;
vector<string> ss(n);
rep(i, n) {
cin >> ss.at(i);
sort(all(ss.at(i)));
}
map<string, int> sm;
rep(i, n) { sm[ss.at(i)]++; }
ll count = 0;
for (auto i = sm.begin(); i != sm.end(); ++i) {
ll j = i->second;
count += j * (j - 1) / 2;
};
p(count);
return 0;
}
| [
"assignment.value.change"
] | 749,016 | 749,017 | u709879360 | cpp |
p02947 | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int N;
cin >> N;
string s[N];
for (int i = 0; i < N; i++) {
cin >> s[i];
sort(s[i].begin(), s[i].end());
}
long long count = 0;
sort(s, s + N);
for (int i = 0; i < N;) {
int j = 0;
while (s[i] == s[i + j]) {
j++;
if (i + j == N) {
i = N;
break;
}
}
i += j;
count += (j * (j - 1) / 2);
}
cout << count << endl;
} | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int N;
cin >> N;
string s[N];
for (int i = 0; i < N; i++) {
cin >> s[i];
sort(s[i].begin(), s[i].end());
}
long long count = 0;
sort(s, s + N);
for (int i = 0; i < N;) {
long long j = 0;
while (s[i] == s[i + j]) {
j++;
if (i + j == N) {
i = N;
break;
}
}
i += j;
count += (j * (j - 1) / 2);
}
cout << count << endl;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 749,022 | 749,023 | u879436400 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long times = 0;
int n;
cin >> n;
string s;
vector<string> v;
for (int i = 0; i < n; i++) {
cin >> s;
sort(s.begin(), s.end());
v.emplace_back(s);
}
sort(v.begin(), v.end());
int t = 1;
for (int i = 0; i < n - 1; i++) {
if (v[i] == v[i + 1])
t++;
else {
if (t > 1)
times += t * (t - 1) / 2;
t = 1;
}
}
if (t > 1)
times += t * (t - 1) / 2;
cout << times << "\n";
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
main() {
int times = 0;
int n;
cin >> n;
string s;
vector<string> v;
for (int i = 0; i < n; i++) {
cin >> s;
sort(s.begin(), s.end());
v.emplace_back(s);
}
sort(v.begin(), v.end());
int t = 1;
for (int i = 0; i < n - 1; i++) {
if (v[i] == v[i + 1])
t++;
else {
if (t > 1)
times += t * (t - 1) / 2;
t = 1;
}
}
if (t > 1)
times += t * (t - 1) / 2;
cout << times << "\n";
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.narrow.change"
] | 749,024 | 749,025 | u240875512 | cpp |
p02947 | #include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define MOD (long long int)(1e9 + 7)
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPS(i, n) for (int i = n; i > 0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a) < (b)) ? (b) : (a))
#define chmin(a, b) a = (((a) > (b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
/* ll comb(ll x, ll y);
int main(void);
ll comb(ll x, ll y){
}
*/
int main(void) {
int N;
cin >> N;
vector<string> S;
rep(i, N) {
string s;
cin >> s;
S.push_back(s);
}
rep(i, N) { sort(all(S[i])); }
sort(all(S));
string T = S[0];
int cnt = 0;
ll ans = 0;
rep(i, N) {
if (S[i] == T) {
cnt++;
} else {
ans += cnt * (cnt - 1) / 2;
T = S[i];
cnt = 1;
}
}
if (cnt > 1) {
ans += cnt * (cnt - 1) / 2;
}
/* rep(i,N){
cout << S[i] << endl;
} */
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define MOD (long long int)(1e9 + 7)
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPS(i, n) for (int i = n; i > 0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a) < (b)) ? (b) : (a))
#define chmin(a, b) a = (((a) > (b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
/* ll comb(ll x, ll y);
int main(void);
ll comb(ll x, ll y){
}
*/
int main(void) {
int N;
cin >> N;
vector<string> S;
rep(i, N) {
string s;
cin >> s;
S.push_back(s);
}
rep(i, N) { sort(all(S[i])); }
sort(all(S));
string T = S[0];
ll cnt = 0;
ll ans = 0;
rep(i, N) {
if (S[i] == T) {
cnt++;
} else {
ans += cnt * (cnt - 1) / 2;
T = S[i];
cnt = 1;
}
}
if (cnt > 1) {
ans += cnt * (cnt - 1) / 2;
}
/* rep(i,N){
cout << S[i] << endl;
} */
cout << ans << endl;
return 0;
}
| [
"variable_declaration.type.change"
] | 749,028 | 749,029 | u127344197 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define FORR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(o) (o).begin(), (o).end()
template <class T> using V = vector<T>;
template <class T, class U> using P = pair<T, U>;
template <class T> using PQ = priority_queue<T>;
template <class T> using PQR = priority_queue<T, vector<T>, greater<T>>;
int main() {
int n;
V<string> v;
string s;
cin >> n;
REP(i, n) {
cin >> s;
sort(ALL(s));
v.push_back(s);
}
sort(ALL(v));
v.push_back("zzzzzzzzzzzzzzzz");
ll ans = 0;
string t = v[0];
int cnt = 1;
FOR(i, 1, n + 1) {
if (t == v[i]) {
cnt++;
} else {
ans += cnt * (cnt - 1) / 2;
cnt = 1;
t = v[i];
}
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define FORR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(o) (o).begin(), (o).end()
template <class T> using V = vector<T>;
template <class T, class U> using P = pair<T, U>;
template <class T> using PQ = priority_queue<T>;
template <class T> using PQR = priority_queue<T, vector<T>, greater<T>>;
int main() {
int n;
V<string> v;
string s;
cin >> n;
REP(i, n) {
cin >> s;
sort(ALL(s));
v.push_back(s);
}
sort(ALL(v));
v.push_back("zzzzzzzzzzzzzzzz");
ll ans = 0;
string t = v[0];
ll cnt = 1;
FOR(i, 1, n + 1) {
if (t == v[i]) {
cnt++;
} else {
ans += cnt * (cnt - 1) / 2;
cnt = 1;
t = v[i];
}
}
cout << ans << endl;
}
| [
"variable_declaration.type.change"
] | 749,034 | 749,035 | u116518875 | cpp |
p02947 | #include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
int n;
scanf("%d", &n);
char s[11];
vector<string> v;
REP(i, n) {
scanf("%s", s);
sort(s, s + 10);
string str(s);
v.push_back(str);
}
sort(v.begin(), v.end());
// for(auto i:v)cout << i << endl;
int num = 1;
ll ans = 0;
int len = v.size();
for (int i = 1; i < len; i++) {
if (v[i - 1] == v[i]) {
num++;
} else {
ans += num * (num - 1) / 2;
num = 1;
}
}
ans += num * (num - 1) / 2;
printf("%lld\n", ans);
return 0;
} | #include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
int n;
scanf("%d", &n);
char s[11];
vector<string> v;
REP(i, n) {
scanf("%s", s);
sort(s, s + 10);
string str(s);
v.push_back(str);
}
sort(v.begin(), v.end());
// for(auto i:v)cout << i << endl;
ll num = 1;
ll ans = 0;
int len = v.size();
for (int i = 1; i < len; i++) {
if (v[i - 1] == v[i]) {
num++;
} else {
ans += num * (num - 1) / 2;
num = 1;
}
}
ans += num * (num - 1) / 2;
printf("%lld\n", ans);
return 0;
} | [
"variable_declaration.type.change"
] | 749,040 | 749,041 | u092002408 | cpp |
p02947 | #include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
//#include"functions.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define vpi vector<pair<int, int>>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pff pair<float, float>
#define pdd pair<double, double>
#define psi pair<string, int>
#define pis pair<int, string>
#define ppi pair<pii, int>
#define pdi pair<pii, pii>
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define LDEPS 1e-9
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a, b) for (int a = 0; a < b; a++)
#define forn(a, m, n) for (int a = m; a < n; a++)
#define repn(a, m, n, p) for (int a = m; a < n; a += p)
#define foreach(a, b) for (__typeof(b.begin()) a = b.begin(); a != b.end(); a++)
#define fillemp(a) memset(a, 0, sizeof(a))
#define fillinf(a) memset(a, 0xff, sizeof(a))
#define frestream \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
#define stdf(a, b) \
freopen(a, "r", stdin); \
freopen(b, "w", stdout);
#define inputf(a) freopen(a, "r", stdin);
#define outputf(a) freopen(a, "w", stdout);
#define sz(a) a.size()
#define all(a) a.begin(), a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;
map<string, int> mpp;
int main() {
ios::sync_with_stdio(0);
ll ans = 0;
int n;
cin >> n;
rep(i, n) {
string s;
cin >> s;
sort(s.begin(), s.end());
// cout<<s<<endl;
mpp[s]++;
}
foreach (i, mpp) {
int cur = i->second;
if (cur > 1) {
ans += cur * (cur - 1) / 2;
}
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
//#include"functions.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define vpi vector<pair<int, int>>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pff pair<float, float>
#define pdd pair<double, double>
#define psi pair<string, int>
#define pis pair<int, string>
#define ppi pair<pii, int>
#define pdi pair<pii, pii>
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define LDEPS 1e-9
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a, b) for (int a = 0; a < b; a++)
#define forn(a, m, n) for (int a = m; a < n; a++)
#define repn(a, m, n, p) for (int a = m; a < n; a += p)
#define foreach(a, b) for (__typeof(b.begin()) a = b.begin(); a != b.end(); a++)
#define fillemp(a) memset(a, 0, sizeof(a))
#define fillinf(a) memset(a, 0xff, sizeof(a))
#define frestream \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
#define stdf(a, b) \
freopen(a, "r", stdin); \
freopen(b, "w", stdout);
#define inputf(a) freopen(a, "r", stdin);
#define outputf(a) freopen(a, "w", stdout);
#define sz(a) a.size()
#define all(a) a.begin(), a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;
map<string, ll> mpp;
int main() {
ios::sync_with_stdio(0);
ll ans = 0;
int n;
cin >> n;
rep(i, n) {
string s;
cin >> s;
sort(s.begin(), s.end());
// cout<<s<<endl;
mpp[s]++;
}
foreach (i, mpp) {
ll cur = i->second;
if (cur > 1) {
ans += cur * (cur - 1) / 2;
}
}
cout << ans << endl;
return 0;
} | [
"variable_declaration.type.change"
] | 749,042 | 749,043 | u963646695 | cpp |
p02947 | #include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define MOD (long long int)(1e9 + 7)
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPS(i, n) for (int i = n; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)(b); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0, sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
std::fill((T *)array, (T *)(array + N), val);
}
//
// int combi(int n, int k) {
// if (n == k || k == 0)
// return 1;
// else {
// return combi(n - 1, k - 1) + combi(n - 1, k);
// }
// }
__attribute__((constructor)) void initial() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(15);
}
signed main() {
int n;
cin >> n;
// vector<vector<char> > S;
vector<string> S;
rep(i, n) {
string s;
cin >> s;
// vector<char> C;
// rep(j,10){
// C.PB(s[j]);
// }
// sort(ALL(C));
// S.PB(C);
sort(ALL(s));
S.PB(s);
// cout << s << endl;
}
sort(ALL(S));
// rep(i,n){
// cout << S[i] << endl;
// }
// cout << endl;
int ans = 0;
VI cnt;
int r = 1;
rep(i, n - 1) {
if (S[i] == S[i + 1])
r++;
else {
if (r != 1)
ans += (r * (r - 1) / 2);
r = 1;
}
// cout << r << " ";
}
ans += (r * (r - 1) / 2);
// cout << endl;
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define MOD (long long int)(1e9 + 7)
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPS(i, n) for (int i = n; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)(b); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0, sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
std::fill((T *)array, (T *)(array + N), val);
}
//
// int combi(int n, int k) {
// if (n == k || k == 0)
// return 1;
// else {
// return combi(n - 1, k - 1) + combi(n - 1, k);
// }
// }
__attribute__((constructor)) void initial() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(15);
}
signed main() {
int n;
cin >> n;
// vector<vector<char> > S;
vector<string> S;
rep(i, n) {
string s;
cin >> s;
// vector<char> C;
// rep(j,10){
// C.PB(s[j]);
// }
// sort(ALL(C));
// S.PB(C);
sort(ALL(s));
S.PB(s);
// cout << s << endl;
}
sort(ALL(S));
// rep(i,n){
// cout << S[i] << endl;
// }
// cout << endl;
ll ans = 0;
VI cnt;
ll r = 1;
rep(i, n - 1) {
if (S[i] == S[i + 1])
r++;
else {
if (r != 1)
ans += (r * (r - 1) / 2);
r = 1;
}
// cout << r << " ";
}
ans += (r * (r - 1) / 2);
// cout << endl;
cout << ans << endl;
return 0;
}
| [
"variable_declaration.type.change"
] | 749,044 | 749,045 | u050698451 | cpp |
p02947 | #include "bits/stdc++.h"
#define ll long long
#define ALL(x) (x.begin(), x.end())
using namespace std;
int main() {
ll N;
cin >> N;
vector<string> s(N);
for (ll i = 0; i < N; i++) {
cin >> s[i];
}
for (ll i = 0; i < N; i++) {
sort(s[i].begin(), s[i].end());
}
sort(s.begin(), s.end());
ll ans = 0;
ll tmp1, tmp2, tmp3;
tmp1 = 1;
for (ll i = 0; i < N; i++) {
if (s[i] == s[i - 1]) {
tmp1++;
continue;
} else {
if (tmp1 > 1) {
ans += tmp1 * (tmp1 - 1) / 2;
}
tmp1 = 1;
}
}
if (tmp1 > 1) {
ans += tmp1 * (tmp1 - 1) / 2;
}
cout << ans << endl;
return 0;
}
| #include "bits/stdc++.h"
#define ll long long
#define ALL(x) (x.begin(), x.end())
using namespace std;
int main() {
ll N;
cin >> N;
vector<string> s(N);
for (ll i = 0; i < N; i++) {
cin >> s[i];
}
for (ll i = 0; i < N; i++) {
sort(s[i].begin(), s[i].end());
}
sort(s.begin(), s.end());
ll ans = 0;
ll tmp1, tmp2, tmp3;
tmp1 = 1;
for (ll i = 1; i < N; i++) {
if (s[i] == s[i - 1]) {
tmp1++;
continue;
} else {
if (tmp1 > 1) {
ans += tmp1 * (tmp1 - 1) / 2;
}
tmp1 = 1;
}
}
if (tmp1 > 1) {
ans += tmp1 * (tmp1 - 1) / 2;
}
cout << ans << endl;
return 0;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 749,048 | 749,049 | u546736430 | cpp |
p02947 | #include "bits/stdc++.h"
#define ll long long
#define ALL(x) (x.begin(), x.end())
using namespace std;
int main() {
ll N;
cin >> N;
vector<string> s(N);
for (ll i = 0; i < N; i++) {
cin >> s[i];
}
for (ll i = 0; i < N; i++) {
sort(s[i].begin(), s[i].end());
}
sort(s.begin(), s.end());
ll ans = 0;
ll tmp1, tmp2, tmp3;
tmp1 = 1;
for (ll i = 0; i < N; i++) {
if (s[i] == s[i - 1]) {
tmp1++;
continue;
} else {
if (tmp1 > 1) {
ans += tmp1 * (tmp1 - 1) / 2;
}
tmp1 = 1;
}
}
if (tmp1 > 1) {
ans += tmp1 * (tmp1 - 1) / 2;
}
cout << ans << endl;
}
| #include "bits/stdc++.h"
#define ll long long
#define ALL(x) (x.begin(), x.end())
using namespace std;
int main() {
ll N;
cin >> N;
vector<string> s(N);
for (ll i = 0; i < N; i++) {
cin >> s[i];
}
for (ll i = 0; i < N; i++) {
sort(s[i].begin(), s[i].end());
}
sort(s.begin(), s.end());
ll ans = 0;
ll tmp1, tmp2, tmp3;
tmp1 = 1;
for (ll i = 1; i < N; i++) {
if (s[i] == s[i - 1]) {
tmp1++;
continue;
} else {
if (tmp1 > 1) {
ans += tmp1 * (tmp1 - 1) / 2;
}
tmp1 = 1;
}
}
if (tmp1 > 1) {
ans += tmp1 * (tmp1 - 1) / 2;
}
cout << ans << endl;
return 0;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"control_flow.return.add",
"control_flow.return.0.add"
] | 749,050 | 749,049 | u546736430 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(), A.end()
#define RALL(A) A.rbegin(), A.rend()
typedef long long LL;
typedef pair<LL, LL> P;
const LL mod = 1000000007;
const LL LINF = 1LL << 60;
const int INF = 1 << 30;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main() {
int n;
cin >> n;
map<string, int> ma;
int ans = 0;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
sort(ALL(s));
ans += ma[s]++;
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(), A.end()
#define RALL(A) A.rbegin(), A.rend()
typedef long long LL;
typedef pair<LL, LL> P;
const LL mod = 1000000007;
const LL LINF = 1LL << 60;
const int INF = 1 << 30;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main() {
int n;
cin >> n;
map<string, LL> ma;
LL ans = 0;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
sort(ALL(s));
ans += ma[s]++;
}
cout << ans << endl;
return 0;
}
| [
"variable_declaration.type.change"
] | 749,053 | 749,054 | u640323045 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
vector<string> s2;
for (int i = 0; i < n; i++) {
char s[10];
scanf("%s", s);
sort(s, s + 10);
s2.push_back(s);
}
int t = 0, sum = 0;
sort(s2.begin(), s2.end());
for (int i = 1; i < s2.size(); i++) {
if (s2[i] == s2[i - 1]) {
t++;
sum += t;
} else {
t = 0;
}
}
printf("%d\n", sum);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
vector<string> s2;
for (int i = 0; i < n; i++) {
char s[10];
scanf("%s", s);
sort(s, s + 10);
s2.push_back(s);
}
int t = 0;
long long sum = 0;
sort(s2.begin(), s2.end());
for (int i = 1; i < s2.size(); i++) {
if (s2[i] == s2[i - 1]) {
t++;
sum += t;
} else {
t = 0;
}
}
printf("%lld\n", sum);
return 0;
} | [
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 749,055 | 749,056 | u027057023 | cpp |
p02947 | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
string s[100005], c;
int main() {
long long n, a, b, i, j, k;
cin >> n;
for (i = 0; i < n; i++) {
cin >> c;
sort(c.begin(), c.end());
s[i] = c;
}
sort(s, s + n);
int sum = 1;
k = 0;
for (i = 1; i < n; i++) {
if (s[i] != s[i - 1]) {
k += (sum * (sum - 1)) / 2;
sum = 1;
continue;
} else if (i == n - 1) {
if (s[i] == s[i - 1])
sum++;
k += (sum * (sum - 1)) / 2;
}
sum++;
}
cout << k;
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
string s[100005], c;
int main() {
long long n, a, b, i, j, k;
cin >> n;
for (i = 0; i < n; i++) {
cin >> c;
sort(c.begin(), c.end());
s[i] = c;
}
sort(s, s + n);
long long sum = 1;
k = 0;
for (i = 1; i < n; i++) {
if (s[i] != s[i - 1]) {
k += (sum * (sum - 1)) / 2;
sum = 1;
continue;
} else if (i == n - 1) {
if (s[i] == s[i - 1])
sum++;
k += (sum * (sum - 1)) / 2;
}
sum++;
}
cout << k;
return 0;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 749,057 | 749,058 | u748042489 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
map<string, int> a;
map<string, int>::iterator it;
string s;
int main() {
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int n, l = 0;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> s;
sort(s.begin(), s.end());
a[s]++;
}
for (it = a.begin(); it != a.end(); it++) {
if ((*it).second > 1)
l += (*it).second * ((*it).second - 1) / 2;
}
cout << l;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
map<string, long long> a;
map<string, long long>::iterator it;
string s;
int main() {
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
long long n, l = 0;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> s;
sort(s.begin(), s.end());
a[s]++;
}
for (it = a.begin(); it != a.end(); it++) {
if ((*it).second > 1)
l += (*it).second * ((*it).second - 1) / 2;
}
cout << l;
return 0;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 749,063 | 749,064 | u879241796 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, a = 0, t;
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]++;
}
for (auto x : m) {
t = x.second;
a += (t * (t - 1)) / 2;
}
cout << a;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n, a = 0, t;
cin >> n;
unordered_map<string, long long> m;
for (long long i = 0; i < n; i++) {
string s;
cin >> s;
sort(s.begin(), s.end());
m[s]++;
}
for (auto x : m) {
t = x.second;
a += (t * (t - 1)) / 2;
}
cout << a;
return 0;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change",
"control_flow.loop.for.initializer.change"
] | 749,067 | 749,068 | u796610363 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i, c;
long long int r = 0;
string s[100005];
cin >> n;
for (i = 0; i < n; i++) {
cin >> s[i];
}
for (i = 0; i < n; i++) {
sort(s[i].begin(), s[i].end());
}
sort(s, s + n);
for (i = 1, c = 0; i < n; i++) {
if (s[i] == s[i - 1]) {
c++;
} else {
r = r + (c * (c + 1) / 2);
c = 0;
}
}
if (c > 0) {
r = r + (c * (c + 1) / 2);
}
cout << r << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
long long int c, r = 0;
string s[100005];
cin >> n;
for (i = 0; i < n; i++) {
cin >> s[i];
}
for (i = 0; i < n; i++) {
sort(s[i].begin(), s[i].end());
}
sort(s, s + n);
for (i = 1, c = 0; i < n; i++) {
if (s[i] == s[i - 1]) {
c++;
} else {
r = r + (c * (c + 1) / 2);
c = 0;
}
}
if (c > 0) {
r = r + (c * (c + 1) / 2);
}
cout << r << endl;
return 0;
} | [
"variable_declaration.remove",
"variable_declaration.add"
] | 749,078 | 749,079 | u926389420 | cpp |
p02947 | #include <algorithm>
#include <iostream>
#include <map>
#include <string>
using namespace std;
int nCr(int n, int r) {
int num = 1;
for (int i = 1; i <= r; i++) {
num = num * (n - i + 1) / i;
}
return num;
}
int main() {
int N;
cin >> N;
map<string, int> mp;
for (int i = 0; i < N; i++) {
string str;
cin >> str;
sort(str.begin(), str.end());
auto itr = mp.find(str);
if (itr != mp.end()) {
int n = mp[str];
n++;
mp[str] = n;
} else {
mp[str] = 1;
}
}
long long int cnt = 0;
for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
if (itr->second > 1) {
cnt += nCr(itr->second, 2);
}
}
cout << cnt << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <string>
using namespace std;
long long int nCr(int n, int r) {
long long int num = 1;
for (int i = 1; i <= r; i++) {
num = num * (n - i + 1) / i;
}
return num;
}
int main() {
int N;
cin >> N;
map<string, int> mp;
for (int i = 0; i < N; i++) {
string str;
cin >> str;
sort(str.begin(), str.end());
auto itr = mp.find(str);
if (itr != mp.end()) {
int n = mp[str];
n++;
mp[str] = n;
} else {
mp[str] = 1;
}
}
long long int cnt = 0;
for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
if (itr->second > 1) {
cnt += nCr(itr->second, 2);
}
}
cout << cnt << endl;
return 0;
}
| [
"variable_declaration.type.widen.change"
] | 749,080 | 749,081 | u474377871 | 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.at(i);
sort(s.at(i).begin(), s.at(i).end());
}
sort(s.begin(), s.end());
/* for (int i = 0; i < N; i++) {
cout << s.at(i) << endl;
}
*/
long ans = 0;
int count = 1;
string pres = s.at(0);
for (int i = 1; i < N; i++) {
// cout << "i pres count ans = " << i << pres << count << ans << endl;
if (pres == s.at(i)) {
count++;
} else {
ans += ((count * (count - 1)) / 2);
count = 1;
}
pres = s.at(i);
}
ans += ((count * (count - 1)) / 2);
cout << ans;
} | #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.at(i);
sort(s.at(i).begin(), s.at(i).end());
}
sort(s.begin(), s.end());
/* for (int i = 0; i < N; i++) {
cout << s.at(i) << endl;
}
*/
long ans = 0;
long count = 1;
string pres = s.at(0);
for (int i = 1; i < N; i++) {
// cout << "i pres count ans = " << i << pres << count << ans << endl;
if (pres == s.at(i)) {
count++;
} else {
ans += ((count * (count - 1)) / 2);
count = 1;
}
pres = s.at(i);
}
ans += ((count * (count - 1)) / 2);
cout << ans;
} | [
"variable_declaration.type.primitive.change"
] | 749,086 | 749,087 | u042802884 | 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.at(i);
sort(s.at(i).begin(), s.at(i).end());
}
sort(s.begin(), s.end());
/* for (int i = 0; i < N; i++) {
cout << s.at(i) << endl;
}
*/
int ans = 0;
int count = 1;
string pres = s.at(0);
for (int i = 1; i < N; i++) {
// cout << "i pres count ans = " << i << pres << count << ans << endl;
if (pres == s.at(i)) {
count++;
} else {
ans += ((count * (count - 1)) / 2);
count = 1;
}
pres = s.at(i);
}
ans += ((count * (count - 1)) / 2);
cout << ans;
} | #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.at(i);
sort(s.at(i).begin(), s.at(i).end());
}
sort(s.begin(), s.end());
/* for (int i = 0; i < N; i++) {
cout << s.at(i) << endl;
}
*/
long ans = 0;
long count = 1;
string pres = s.at(0);
for (int i = 1; i < N; i++) {
// cout << "i pres count ans = " << i << pres << count << ans << endl;
if (pres == s.at(i)) {
count++;
} else {
ans += ((count * (count - 1)) / 2);
count = 1;
}
pres = s.at(i);
}
ans += ((count * (count - 1)) / 2);
cout << ans;
} | [
"variable_declaration.type.primitive.change"
] | 749,088 | 749,087 | u042802884 | cpp |
p02947 | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <limits.h>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
#define LP(i, n) for (int i = 0; i < n; i++)
#define LPIN(n, a) \
for (int i = 0; i < n; i++) \
cin >> a[i]
using namespace std;
int main() {
int n;
cin >> n;
long long int a[n] = {};
long long int cnt = 0;
LP(i, n) {
string temp;
cin >> temp;
sort(temp.begin(), temp.end());
for (int j = 0; j < temp.size(); j++) {
a[i] += temp[j] - 'a' + 1;
a[i] *= 30;
}
}
sort(a, a + n);
int b = 0;
for (int i = 1; i < n; i++) {
if (a[i] == a[i - 1]) {
b++;
} else {
if (b != 0)
cnt += (b + 1) * b / 2;
b = 0;
}
}
if (b != 0)
cnt += (b + 1) * b / 2;
// LP(i,n)cout << a[i] << endl;
cout << cnt << endl;
return 0;
}
| #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <limits.h>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
#define LP(i, n) for (int i = 0; i < n; i++)
#define LPIN(n, a) \
for (int i = 0; i < n; i++) \
cin >> a[i]
using namespace std;
int main() {
int n;
cin >> n;
long long int a[n] = {};
long long int cnt = 0;
LP(i, n) {
string temp;
cin >> temp;
sort(temp.begin(), temp.end());
for (int j = 0; j < temp.size(); j++) {
a[i] += temp[j] - 'a' + 1;
a[i] *= 30;
}
}
sort(a, a + n);
long long int b = 0;
for (int i = 1; i < n; i++) {
if (a[i] == a[i - 1]) {
b++;
} else {
if (b != 0)
cnt += (b + 1) * b / 2;
b = 0;
}
}
if (b != 0)
cnt += (b + 1) * b / 2;
// LP(i,n)cout << a[i] << endl;
cout << cnt << endl;
return 0;
}
| [
"variable_declaration.type.widen.change"
] | 749,091 | 749,092 | u271153916 | cpp |
p02947 | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <limits.h>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
#define LP(i, n) for (int i = 0; i < n; i++)
#define LPIN(n, a) \
for (int i = 0; i < n; i++) \
cin >> a[i]
using namespace std;
int main() {
int n;
cin >> n;
long long int a[n] = {};
long long int cnt = 0;
LP(i, n) {
string temp;
cin >> temp;
sort(temp.begin(), temp.end());
for (int j = 0; j < temp.size(); j++) {
a[i] += temp[j] - 'a' + 1;
a[i] *= 10;
}
}
sort(a, a + n);
int b = 0;
for (int i = 1; i < n; i++) {
if (a[i] == a[i - 1]) {
b++;
} else {
if (b != 0)
cnt += (b + 1) * b / 2;
b = 0;
}
}
if (b != 0)
cnt += (b + 1) * b / 2;
// LP(i,n)cout << a[i] << endl;
cout << cnt << endl;
return 0;
}
| #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <limits.h>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
#define LP(i, n) for (int i = 0; i < n; i++)
#define LPIN(n, a) \
for (int i = 0; i < n; i++) \
cin >> a[i]
using namespace std;
int main() {
int n;
cin >> n;
long long int a[n] = {};
long long int cnt = 0;
LP(i, n) {
string temp;
cin >> temp;
sort(temp.begin(), temp.end());
for (int j = 0; j < temp.size(); j++) {
a[i] += temp[j] - 'a' + 1;
a[i] *= 30;
}
}
sort(a, a + n);
long long int b = 0;
for (int i = 1; i < n; i++) {
if (a[i] == a[i - 1]) {
b++;
} else {
if (b != 0)
cnt += (b + 1) * b / 2;
b = 0;
}
}
if (b != 0)
cnt += (b + 1) * b / 2;
// LP(i,n)cout << a[i] << endl;
cout << cnt << endl;
return 0;
}
| [
"literal.number.change",
"assignment.value.change"
] | 749,093 | 749,092 | u271153916 | cpp |
p02947 | #include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
int n, m, i, j, k, x, t;
while (cin >> n) {
string s;
map<string, int> mp;
map<string, int>::iterator it;
for (i = 0; i < n; i++) {
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
ll ans = 0;
for (it = mp.begin(); it != mp.end(); it++) {
ans += (it->second * (it->second - 1)) / 2;
}
cout << ans << endl;
}
return 0;
}
| #include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
ll n, m, i, j, k, x, t;
while (cin >> n) {
string s;
map<string, ll> mp;
map<string, ll>::iterator it;
for (i = 0; i < n; i++) {
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
ll ans = 0;
for (it = mp.begin(); it != mp.end(); it++) {
ans += (it->second * (it->second - 1)) / 2;
}
cout << ans << endl;
}
return 0;
}
| [
"variable_declaration.type.change"
] | 749,097 | 749,098 | u586712352 | cpp |
p02947 | #include <algorithm>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i, a, b) for (ll i = a; i <= b; ++i)
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep3(i, a, b) for (ll i = a; i >= b; i--)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pq priority_queue<int>
#define pqg priority_queue<int, vector<int>, greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c), end(c)
using namespace std;
int in() {
int x;
scanf("%d", &x);
return x;
}
ll lin() {
ll x;
scanf("%lld", &x);
return x;
}
#define LLINF 1e18 + 7
#define N 250000
ll MOD = 1e9 + 7;
template <typename T> struct edge {
int src, to;
T cost;
edge(int to, T cost) : src(-1), to(to), cost(cost) {}
edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
edge &operator=(const int &x) {
to = x;
return *this;
}
operator int() const { return to; }
};
int n;
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;
template <typename T> vector<T> bellman_ford(Edges<T> &edges, int V, int s) {
const auto INF = numeric_limits<T>::max();
vector<T> dist(V, INF);
dist[s] = 0;
for (int i = 0; i < V - 1; i++) {
for (auto &e : edges) {
if (dist[e.src] == INF)
continue;
dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
}
}
for (auto &e : edges) {
if (dist[e.src] == INF)
continue;
if (dist[e.src] + e.cost < dist[e.to] && e.to == n)
return vector<T>();
}
return dist;
}
main() {
int n;
cin >> n;
vector<vector<char>> v;
rep(i, n) {
string s;
cin >> s;
vector<char> c;
rep(j, s.size()) { c.pb(s[j]); }
sort(all(c));
v.pb(c);
}
sort(all(v));
int now = 0;
ll ans = 0;
while (now < n) {
int pre = now;
while (v[pre] == v[now])
now++;
ans += (now - pre) * (now - pre - 1) / 2;
}
cout << ans;
}
| #include <algorithm>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i, a, b) for (ll i = a; i <= b; ++i)
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep3(i, a, b) for (ll i = a; i >= b; i--)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pq priority_queue<int>
#define pqg priority_queue<int, vector<int>, greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c), end(c)
using namespace std;
int in() {
int x;
scanf("%d", &x);
return x;
}
ll lin() {
ll x;
scanf("%lld", &x);
return x;
}
#define LLINF 1e18 + 7
#define N 250000
ll MOD = 1e9 + 7;
template <typename T> struct edge {
int src, to;
T cost;
edge(int to, T cost) : src(-1), to(to), cost(cost) {}
edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
edge &operator=(const int &x) {
to = x;
return *this;
}
operator int() const { return to; }
};
int n;
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;
template <typename T> vector<T> bellman_ford(Edges<T> &edges, int V, int s) {
const auto INF = numeric_limits<T>::max();
vector<T> dist(V, INF);
dist[s] = 0;
for (int i = 0; i < V - 1; i++) {
for (auto &e : edges) {
if (dist[e.src] == INF)
continue;
dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
}
}
for (auto &e : edges) {
if (dist[e.src] == INF)
continue;
if (dist[e.src] + e.cost < dist[e.to] && e.to == n)
return vector<T>();
}
return dist;
}
main() {
int n;
cin >> n;
vector<vector<char>> v;
rep(i, n) {
string s;
cin >> s;
vector<char> c;
rep(j, s.size()) { c.pb(s[j]); }
sort(all(c));
v.pb(c);
}
sort(all(v));
ll now = 0;
ll ans = 0;
while (now < n) {
int pre = now;
while (v[pre] == v[now])
now++;
ans += (now - pre) * (now - pre - 1) / 2;
}
cout << ans;
}
| [
"variable_declaration.type.change"
] | 749,099 | 749,100 | u495699318 | cpp |
p02947 | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
using namespace std;
typedef long long ll;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int main(void) {
int n;
string s[100000];
scanf("%d", &n);
REP(i, n) {
char cs[11];
scanf("%s", cs);
s[i] = string(cs);
}
REP(i, n) { sort(s[i].begin(), s[i].end()); }
sort(s, s + n);
/* std::vector<std::vector<long long>> v(n + 1,
std::vector<long long>(n + 1, 0));
for(int i = 0; i < v.size(); i++) {
v[i][0] = 1;
v[i][i] = 1;
}
for(int j = 1; j < v.size(); j++) {
for(int k = 1; k < j; k++) {
v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
}
}*/
ll result = 0;
int c = 0;
REP(i, n - 1) {
if (s[i] == s[i + 1]) {
c++;
} else {
result += c * (c + 1) / 2;
c = 0;
}
}
result += c * (c + 1) / 2;
printf("%lld\n", result);
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
using namespace std;
typedef long long ll;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int main(void) {
int n;
string s[100000];
scanf("%d", &n);
REP(i, n) {
char cs[11];
scanf("%s", cs);
s[i] = string(cs);
}
REP(i, n) { sort(s[i].begin(), s[i].end()); }
sort(s, s + n);
ll result = 0;
ll c = 0;
REP(i, n - 1) {
if (s[i] == s[i + 1]) {
c++;
} else {
result += c * (c + 1) / 2;
c = 0;
}
}
result += c * (c + 1) / 2;
printf("%lld\n", result);
return 0;
} | [
"variable_declaration.type.change"
] | 749,101 | 749,102 | u684901760 | cpp |
p02947 | #include <algorithm>
#include <iostream>
#include <unordered_map>
using namespace std;
int main() {
int N;
cin >> N;
string str;
unordered_map<string, int> hash;
int count = 0;
for (int i = 0; i < N; i++) {
cin >> str;
sort(str.begin(), str.end());
if (hash[str] != 0) {
count = count + hash[str];
} else {
count = count;
}
hash[str]++;
}
cout << count << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <unordered_map>
using namespace std;
int main() {
int N;
cin >> N;
string str;
unordered_map<string, int> hash;
long count = 0;
for (int i = 0; i < N; i++) {
cin >> str;
sort(str.begin(), str.end());
if (hash[str] != 0) {
count = count + hash[str];
} else {
count = count;
}
hash[str]++;
}
cout << count << endl;
return 0;
} | [
"variable_declaration.type.primitive.change"
] | 749,103 | 749,104 | u711816529 | cpp |
p02947 | #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
map<string, int> s;
Rep(i, N) {
string S;
cin >> S;
sort(S.begin(), S.end());
s[S]++;
}
ll ans = 0;
for (auto e : s) {
ans += e.second * (e.second - 1) / 2;
}
cout << ans << endl;
} | #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
map<string, ll> s;
Rep(i, N) {
string S;
cin >> S;
sort(S.begin(), S.end());
s[S]++;
}
ll ans = 0;
for (auto e : s) {
// cout << e.first << " " << e.second << "\n";
ans += e.second * (e.second - 1) / 2;
}
cout << ans << endl;
} | [] | 749,105 | 749,106 | u017271745 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n;
cin >> n;
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 p : m) {
int x = p.second;
ans += x * (x - 1) / 2;
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n;
cin >> n;
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 p : m) {
ll x = p.second;
ans += x * (x - 1) / 2;
}
cout << ans << endl;
return 0;
} | [
"variable_declaration.type.change",
"control_flow.loop.for.initializer.change"
] | 749,107 | 749,108 | u355724718 | cpp |
p02947 | #include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define all(i, n) (i), (i + n)
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, -1, 0, 1};
int dx8[8] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6 + 1;
const ll mod = 1000000007;
// --------------------------------------
int n;
unordered_map<string, int> mp;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n;
REP(i, n) {
string s;
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
ll ans = 0;
for (auto it = mp.begin(); it != mp.end(); it++) {
int count = it->second;
ans += count * (count - 1) / 2;
}
cout << ans << endl;
}
| #include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define all(i, n) (i), (i + n)
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, -1, 0, 1};
int dx8[8] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6 + 1;
const ll mod = 1000000007;
// --------------------------------------
int n;
map<string, int> mp;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n;
REP(i, n) {
string s;
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
ll ans = 0;
for (auto it = mp.begin(); it != mp.end(); it++) {
ll count = it->second;
ans += count * (count - 1) / 2;
}
cout << ans << endl;
}
| [
"variable_declaration.type.change"
] | 749,116 | 749,117 | u494070244 | cpp |
p02947 | #include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define all(i, n) (i), (i + n)
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, -1, 0, 1};
int dx8[8] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6 + 1;
const ll mod = 1000000007;
// --------------------------------------
int n;
unordered_map<string, int> mp;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n;
REP(i, n) {
string s;
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
ll ans = 0;
for (auto it = mp.begin(); it != mp.end(); it++) {
int count = it->second;
ans += count * (count - 1) / 2;
}
cout << ans << endl;
}
| #include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define all(i, n) (i), (i + n)
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, -1, 0, 1};
int dx8[8] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6 + 1;
const ll mod = 1000000007;
// --------------------------------------
int n;
unordered_map<string, int> mp;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n;
REP(i, n) {
string s;
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
ll ans = 0;
for (auto it = mp.begin(); it != mp.end(); it++) {
ll count = it->second;
ans += count * (count - 1) / 2;
}
cout << ans << endl;
}
| [
"variable_declaration.type.change"
] | 749,116 | 749,118 | u494070244 | cpp |
p02947 | // 3_abc137_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector> // C++
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<vector<char>> s(n, vector<char>(10));
vector<string> s2(n);
rep(i, n) {
rep(j, 10) { cin >> s[i][j]; }
sort(s[i].begin(), s[i].end());
string tmp(s[i].begin(), s[i].end());
s2[i] = tmp;
}
sort(s2.begin(), s2.end());
ll ans = 0;
string cmp = s2[0];
int cnt = 1;
for (int i = 1; i < n; i++) {
if (cmp == s2[i])
cnt++;
else {
ans += cnt * (cnt - 1) / 2;
cnt = 1;
cmp = s2[i];
}
}
ans += cnt * (cnt - 1) / 2;
cout << ans << endl;
return 0;
}
| // 3_abc137_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector> // C++
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<vector<char>> s(n, vector<char>(10));
vector<string> s2(n);
rep(i, n) {
rep(j, 10) { cin >> s[i][j]; }
sort(s[i].begin(), s[i].end());
string tmp(s[i].begin(), s[i].end());
s2[i] = tmp;
}
sort(s2.begin(), s2.end());
ll ans = 0;
string cmp = s2[0];
ll cnt = 1;
for (int i = 1; i < n; i++) {
if (cmp == s2[i])
cnt++;
else {
ans += cnt * (cnt - 1) / 2;
cnt = 1;
cmp = s2[i];
}
}
ans += cnt * (cnt - 1) / 2;
cout << ans << endl;
return 0;
} | [
"variable_declaration.type.change"
] | 749,119 | 749,120 | u811561461 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
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]++;
}
long long ans = 0;
for (auto it = mp.begin(); it != mp.end(); it++) {
int count = it->second;
ans += count * (count - 1) / 2;
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
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]++;
}
long long ans = 0;
for (auto it = mp.begin(); it != mp.end(); it++) {
long long count = it->second;
ans += count * (count - 1) / 2;
}
cout << ans << endl;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 749,123 | 749,124 | u372299304 | cpp |
p02947 | #include <iostream>
#include <string>
#include <unordered_map>
typedef long long ll;
using namespace std;
string insertion_sort(string str) {
for (int i = 1; i < 10; i++) {
int j = i;
while (j > 0 && str[j - 1] > str[j]) {
char tmp = str[j - 1];
str[j - 1] = str[j];
str[j] = tmp;
j--;
}
}
return str;
}
int main() {
int n;
cin >> n;
string s[n];
unordered_map<string, int> scores;
for (int i = 0; i < n; i++) {
cin >> s[i];
s[i] = insertion_sort(s[i]);
if (scores.find(s[i]) == scores.end())
scores[s[i]] = 1;
else
scores[s[i]]++;
}
ll cnt = 0;
// for(auto itr=scores.begin(); itr!=scores.end(); itr++)
for (auto x : scores) {
cnt += x.second * (x.second - 1) / 2;
}
cout << cnt << endl;
return 0;
}
| #include <iostream>
#include <string>
#include <unordered_map>
typedef long long ll;
using namespace std;
string insertion_sort(string str) {
for (int i = 1; i < 10; i++) {
int j = i;
while (j > 0 && str[j - 1] > str[j]) {
char tmp = str[j - 1];
str[j - 1] = str[j];
str[j] = tmp;
j--;
}
}
return str;
}
int main() {
int n;
cin >> n;
string s[n];
unordered_map<string, ll> scores;
for (int i = 0; i < n; i++) {
cin >> s[i];
s[i] = insertion_sort(s[i]);
if (scores.find(s[i]) == scores.end())
scores[s[i]] = 1;
else
scores[s[i]]++;
}
ll cnt = 0;
// for(auto itr=scores.begin(); itr!=scores.end(); itr++)
for (auto x : scores) {
cnt += x.second * (x.second - 1) / 2;
}
cout << cnt << endl;
return 0;
}
| [] | 749,125 | 749,126 | u069877747 | cpp |
p02947 | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define INF (int)1e9
#define MOD (int)1e9 + 7
using namespace std;
typedef long long llong;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> pii;
int main() {
int n;
cin >> n;
vector<string> s(n);
REP(i, n) {
cin >> s[i];
sort(ALL(s[i]));
}
map<string, int> mp;
REP(i, n) { mp[s[i]]++; }
int ans = 0;
for (auto elem : mp) {
int tmp = elem.second;
ans += (tmp * (tmp - 1)) / 2;
}
cout << ans << endl;
} //解答解説参考. | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define INF (int)1e9
#define MOD (int)1e9 + 7
using namespace std;
typedef long long llong;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> pii;
int main() {
int n;
cin >> n;
vector<string> s(n);
REP(i, n) {
cin >> s[i];
sort(ALL(s[i]));
}
map<string, int> mp;
REP(i, n) { mp[s[i]]++; }
llong ans = 0;
for (auto elem : mp) {
llong tmp = elem.second;
ans += (tmp * (tmp - 1)) / 2;
}
cout << ans << endl;
} //解答解説参考. | [
"variable_declaration.type.change"
] | 749,127 | 749,128 | u209767598 | cpp |
p02947 | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define pii pair<int, int>
#define INF (int)1e9
#define MOD (int)1e9 + 7
typedef long long llong;
using namespace std;
int main() {
int n;
cin >> n;
vector<string> s(n);
vector<char> c(10);
REP(i, n) {
REP(j, 10) cin >> c[j];
sort(ALL(c));
s[i] = "";
REP(j, 10) s[i] += "" + c[j];
}
sort(ALL(s));
llong ans = 0;
llong cnt = 1;
for (int i = 1; i < n; ++i) {
if (s[i - 1] == s[i])
cnt++;
else {
if (cnt >= 2)
ans += (cnt * (cnt - 1)) / 2;
cnt = 1;
}
}
if (cnt >= 2)
ans += (cnt * (cnt - 1)) / 2;
cout << ans << endl;
} | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define pii pair<int, int>
#define INF (int)1e9
#define MOD (int)1e9 + 7
typedef long long llong;
using namespace std;
int main() {
int n;
cin >> n;
vector<string> s(n);
vector<char> c(10);
REP(i, n) {
REP(j, 10) cin >> c[j];
sort(ALL(c));
s[i] = "";
REP(j, 10) s[i] += c[j];
}
sort(ALL(s));
llong ans = 0;
llong cnt = 1;
for (int i = 1; i < n; ++i) {
if (s[i - 1] == s[i])
cnt++;
else {
if (cnt >= 2)
ans += (cnt * (cnt - 1)) / 2;
cnt = 1;
}
}
if (cnt >= 2)
ans += (cnt * (cnt - 1)) / 2;
cout << ans << endl;
} | [
"expression.operation.binary.remove"
] | 749,129 | 749,130 | u209767598 | cpp |
p02947 | #include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
string str[maxn];
ll n;
int main() {
scanf("%lld", &n);
ll ans = 0;
map<string, int> m;
map<string, int>::iterator to;
for (int i = 0; i < n; i++) {
cin >> str[i];
sort(str[i].begin(), str[i].end());
m[str[i]]++;
}
for (to = m.begin(); to != m.end(); to++) {
ans += (to->second) * (to->second - 1) / 2;
}
printf("%lld\n", ans);
return 0;
} | #include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
string str[maxn];
ll n;
int main() {
scanf("%lld", &n);
ll ans = 0;
map<string, ll> m;
map<string, ll>::iterator to;
for (int i = 0; i < n; i++) {
cin >> str[i];
sort(str[i].begin(), str[i].end());
m[str[i]]++;
}
for (to = m.begin(); to != m.end(); to++) {
ans += (to->second) * (to->second - 1) / 2;
}
printf("%lld\n", ans);
return 0;
} | [] | 749,133 | 749,134 | u787202065 | cpp |
p02947 | #include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
string str[maxn];
int n;
int main() {
scanf("%d", &n);
ll ans = 0;
map<string, int> m;
map<string, int>::iterator to;
for (int i = 0; i < n; i++) {
cin >> str[i];
sort(str[i].begin(), str[i].end());
m[str[i]]++;
}
for (to = m.begin(); to != m.end(); to++) {
ans += (to->second) * (to->second - 1) / 2;
}
printf("%lld\n", ans);
return 0;
}
| #include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
string str[maxn];
ll n;
int main() {
scanf("%lld", &n);
ll ans = 0;
map<string, ll> m;
map<string, ll>::iterator to;
for (int i = 0; i < n; i++) {
cin >> str[i];
sort(str[i].begin(), str[i].end());
m[str[i]]++;
}
for (to = m.begin(); to != m.end(); to++) {
ans += (to->second) * (to->second - 1) / 2;
}
printf("%lld\n", ans);
return 0;
} | [
"variable_declaration.type.change",
"literal.string.change",
"call.arguments.change"
] | 749,135 | 749,134 | u787202065 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for (int i = 0; i < (a); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define fst first
#define snd second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
unordered_map<string, int> mp;
int ans = 0;
rep(i, n) {
string s;
cin >> s;
sort(all(s));
if (mp.find(s) != mp.end()) {
ans += mp[s];
mp[s] += 1;
} else
mp[s] = 1;
}
out(ans);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for (int i = 0; i < (a); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define fst first
#define snd second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
unordered_map<string, int> mp;
ll ans = 0;
rep(i, n) {
string s;
cin >> s;
sort(all(s));
if (mp.find(s) != mp.end()) {
ans += mp[s];
mp[s] += 1;
} else
mp[s] = 1;
}
out(ans);
return 0;
}
| [
"variable_declaration.type.change"
] | 749,138 | 749,139 | u019780057 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define FOR(i, m, n) for (long long i = (m); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SPEED \
cin.tie(0); \
ios::sync_with_stdio(false);
template <class T> using V = vector<T>;
template <class T, class U> using P = pair<T, U>;
template <class T> using PQ = priority_queue<T>;
template <class T> using PQR = priority_queue<T, vector<T>, greater<T>>;
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
template <class T> vector<T> make_v(size_t N, T init) {
return vector<T>(N, init);
}
template <class... T> auto make_v(size_t N, T... t) {
return vector<decltype(make_v(t...))>(N, make_v(t...));
}
template <class T> void corner(bool flg, T hoge) {
if (flg) {
cout << hoge << endl;
exit(0);
}
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U> &obj) {
o << "{";
for (auto &x : obj)
o << " {" << x.first << " : " << x.second << "}"
<< ",";
o << " }";
return o;
}
template <class T> ostream &operator<<(ostream &o, const set<T> &obj) {
o << "{";
for (auto itr = obj.begin(); itr != obj.end(); ++itr)
o << (itr != obj.begin() ? ", " : "") << *itr;
o << "}";
return o;
}
template <class T> ostream &operator<<(ostream &o, const multiset<T> &obj) {
o << "{";
for (auto itr = obj.begin(); itr != obj.end(); ++itr)
o << (itr != obj.begin() ? ", " : "") << *itr;
o << "}";
return o;
}
template <class T> ostream &operator<<(ostream &o, const vector<T> &obj) {
o << "{";
for (int i = 0; i < (int)obj.size(); ++i)
o << (i > 0 ? ", " : "") << obj[i];
o << "}";
return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &obj) {
o << "{" << obj.first << ", " << obj.second << "}";
return o;
}
template <template <class tmp> class T, class U>
ostream &operator<<(ostream &o, const T<U> &obj) {
o << "{";
for (auto itr = obj.begin(); itr != obj.end(); ++itr)
o << (itr != obj.begin() ? ", " : "") << *itr;
o << "}";
return o;
}
void print(void) { cout << endl; }
template <class Head> void print(Head &&head) {
cout << head;
print();
}
template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) {
cout << head << " ";
print(forward<Tail>(tail)...);
}
template <class T> void chmax(T &a, const T b) { a = max(a, b); }
template <class T> void chmin(T &a, const T b) { a = min(a, b); }
void YN(bool flg) { cout << (flg ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << (flg ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << (flg ? "yes" : "no") << endl; }
int main() {
int N;
cin >> N;
map<string, ll> mp;
for (int i = 0; i < N; ++i) {
string S;
cin >> S;
sort(ALL(S));
print(S);
mp[S]++;
}
ll ans = 0;
for (auto &e : mp) {
ll f = e.second;
ans += f * (f - 1) / 2;
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define FOR(i, m, n) for (long long i = (m); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SPEED \
cin.tie(0); \
ios::sync_with_stdio(false);
template <class T> using V = vector<T>;
template <class T, class U> using P = pair<T, U>;
template <class T> using PQ = priority_queue<T>;
template <class T> using PQR = priority_queue<T, vector<T>, greater<T>>;
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
template <class T> vector<T> make_v(size_t N, T init) {
return vector<T>(N, init);
}
template <class... T> auto make_v(size_t N, T... t) {
return vector<decltype(make_v(t...))>(N, make_v(t...));
}
template <class T> void corner(bool flg, T hoge) {
if (flg) {
cout << hoge << endl;
exit(0);
}
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U> &obj) {
o << "{";
for (auto &x : obj)
o << " {" << x.first << " : " << x.second << "}"
<< ",";
o << " }";
return o;
}
template <class T> ostream &operator<<(ostream &o, const set<T> &obj) {
o << "{";
for (auto itr = obj.begin(); itr != obj.end(); ++itr)
o << (itr != obj.begin() ? ", " : "") << *itr;
o << "}";
return o;
}
template <class T> ostream &operator<<(ostream &o, const multiset<T> &obj) {
o << "{";
for (auto itr = obj.begin(); itr != obj.end(); ++itr)
o << (itr != obj.begin() ? ", " : "") << *itr;
o << "}";
return o;
}
template <class T> ostream &operator<<(ostream &o, const vector<T> &obj) {
o << "{";
for (int i = 0; i < (int)obj.size(); ++i)
o << (i > 0 ? ", " : "") << obj[i];
o << "}";
return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &obj) {
o << "{" << obj.first << ", " << obj.second << "}";
return o;
}
template <template <class tmp> class T, class U>
ostream &operator<<(ostream &o, const T<U> &obj) {
o << "{";
for (auto itr = obj.begin(); itr != obj.end(); ++itr)
o << (itr != obj.begin() ? ", " : "") << *itr;
o << "}";
return o;
}
void print(void) { cout << endl; }
template <class Head> void print(Head &&head) {
cout << head;
print();
}
template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) {
cout << head << " ";
print(forward<Tail>(tail)...);
}
template <class T> void chmax(T &a, const T b) { a = max(a, b); }
template <class T> void chmin(T &a, const T b) { a = min(a, b); }
void YN(bool flg) { cout << (flg ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << (flg ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << (flg ? "yes" : "no") << endl; }
int main() {
int N;
cin >> N;
map<string, ll> mp;
for (int i = 0; i < N; ++i) {
string S;
cin >> S;
sort(ALL(S));
mp[S]++;
}
ll ans = 0;
for (auto &e : mp) {
ll f = e.second;
ans += f * (f - 1) / 2;
}
cout << ans << endl;
return 0;
}
| [
"call.remove"
] | 749,145 | 749,146 | u898651494 | cpp |
p02947 | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <cmath>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int, int>> qu2;
priority_queue<int> pq;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
#define mp make_pair
/*int P[10010];
void init(int n){
for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
if(P[a]==a)return a;
return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
P[root(a)]=root(b);
}//対set,グラフ?
//セグメント木??
*/
double dot_product(xy_t a, xy_t b) { return (conj(a) * b).real(); } //内積
double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); } //外積
xy_t projection(xy_t p, xy_t b) {
return b * dot_product(p, b) / norm(b);
} //投影
//対図形
#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく
ll pw(ll x, ll y){//euclidの互除法より
ll a= 1;
while(y){
if(y&1){//奇数なら
a = a*x%mod;
}
x = x*x%mod;
y /= 2;
}
return a;
}
ll modinv(ll x){//逆元を求める
return pw(x, mod - 2 );
}
ll comb(int n,int r){
if(n<r){
return 0;
}
return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/
struct BIT {
vector<int> dat;
int sz;
BIT(int n) {
for (sz = 1; sz < n; sz *= 2)
;
dat.resize(++sz);
}
int q(int n) {
int ret = 0;
for (int i = n; i > 0; i -= i & -i)
ret += dat[i]; //和の計算 iから最後の1のbit(i&-i 多分&はビット積)を減算
for (int i = n; i < sz; i += i & -i)
dat[i]++; //値の加算 iから最後mの1のbitを加算
return ret;
}
};
string s;
int main() {
int n;
map<string, int> m;
cin >> n;
int ans = 0;
rep(i, n) {
cin >> s;
sort(s.begin(), s.end());
auto ite = m.find(
s); // find()について等価なキーが見つかった場合は、見つかった要素のイテレータを返す。そうでない場合end()を返す。
// map内部ではキーと値はpairになっているので mapの要素の型宣言はautoを用いる
if (ite == m.end()) { // end()について 最後の要素の次を参照するイテレータ
m.insert(mp(s, 1));
} else {
ans += m[s];
++m[s];
}
}
cout << ans << endl;
return 0;
} | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <cmath>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int, int>> qu2;
priority_queue<int> pq;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
#define mp make_pair
/*int P[10010];
void init(int n){
for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
if(P[a]==a)return a;
return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
P[root(a)]=root(b);
}//対set,グラフ?
//セグメント木??
*/
double dot_product(xy_t a, xy_t b) { return (conj(a) * b).real(); } //内積
double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); } //外積
xy_t projection(xy_t p, xy_t b) {
return b * dot_product(p, b) / norm(b);
} //投影
//対図形
#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく
ll pw(ll x, ll y){//euclidの互除法より
ll a= 1;
while(y){
if(y&1){//奇数なら
a = a*x%mod;
}
x = x*x%mod;
y /= 2;
}
return a;
}
ll modinv(ll x){//逆元を求める
return pw(x, mod - 2 );
}
ll comb(int n,int r){
if(n<r){
return 0;
}
return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/
struct BIT {
vector<int> dat;
int sz;
BIT(int n) {
for (sz = 1; sz < n; sz *= 2)
;
dat.resize(++sz);
}
int q(int n) {
int ret = 0;
for (int i = n; i > 0; i -= i & -i)
ret += dat[i]; //和の計算 iから最後の1のbit(i&-i 多分&はビット積)を減算
for (int i = n; i < sz; i += i & -i)
dat[i]++; //値の加算 iから最後mの1のbitを加算
return ret;
}
};
string s;
int main() {
int n;
map<string, ll> m;
cin >> n;
ll ans = 0;
rep(i, n) {
cin >> s;
sort(s.begin(), s.end());
auto ite = m.find(
s); // find()について等価なキーが見つかった場合は、見つかった要素のイテレータを返す。そうでない場合end()を返す。
// map内部ではキーと値はpairになっているので mapの要素の型宣言はautoを用いる
if (ite == m.end()) { // end()について 最後の要素の次を参照するイテレータ
m.insert(mp(s, 1));
} else {
ans += m[s];
++m[s];
}
}
cout << ans << endl;
return 0;
} | [
"variable_declaration.type.change"
] | 749,149 | 749,150 | u300866293 | cpp |
p02947 | #include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
ll INF = 9999999999999999;
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 max(ll a, ll b) {
if (a > b)
return a;
else
return b;
}
ll min(ll a, ll b) {
if (a < b)
return a;
else
return b;
}
int main(void) {
int N;
cin >> N;
vector<string> s(N);
for (int i = 0; i < N; i++)
cin >> s[i];
// vector<string> s_sort(N);
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 (auto itr : mp) {
if (itr.second > 1)
ans += (itr.second * (itr.second - 1)) / 2;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
ll INF = 9999999999999999;
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 max(ll a, ll b) {
if (a > b)
return a;
else
return b;
}
ll min(ll a, ll b) {
if (a < b)
return a;
else
return b;
}
int main(void) {
int N;
cin >> N;
vector<string> s(N);
for (int i = 0; i < N; i++)
cin >> s[i];
// vector<string> s_sort(N);
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 (auto itr : mp) {
if (itr.second > 1)
ans += (itr.second * (itr.second - 1)) / 2;
}
cout << ans << endl;
}
| [] | 749,151 | 749,152 | u720721463 | cpp |
p02947 | #include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
ll INF = 9999999999999999;
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 max(ll a, ll b) {
if (a > b)
return a;
else
return b;
}
ll min(ll a, ll b) {
if (a < b)
return a;
else
return b;
}
int main(void) {
int N;
cin >> N;
vector<string> s(N);
for (int i = 0; i < N; i++)
cin >> s[i];
// vector<string> s_sort(N);
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 (auto itr : mp) {
if (itr.second > 1) {
if (itr.second % 2 == 0)
ans += (ll)((itr.second / 2) * (itr.second - 1));
else
ans += (ll)(((itr.second - 1) / 2) * itr.second);
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
ll INF = 9999999999999999;
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 max(ll a, ll b) {
if (a > b)
return a;
else
return b;
}
ll min(ll a, ll b) {
if (a < b)
return a;
else
return b;
}
int main(void) {
int N;
cin >> N;
vector<string> s(N);
for (int i = 0; i < N; i++)
cin >> s[i];
// vector<string> s_sort(N);
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 (auto itr : mp) {
if (itr.second > 1) {
if (itr.second % 2 == 0)
ans += ((ll)(itr.second / 2) * (itr.second - 1));
else
ans += ((ll)((itr.second - 1) / 2) * itr.second);
}
}
cout << ans << endl;
} | [
"call.arguments.change"
] | 749,153 | 749,154 | u720721463 | cpp |
p02947 | #include <bits/stdc++.h>
#define debug(x)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sq(x) ((x) * (x))
#define PRECISION 30
using namespace std;
template <class T> int check_mod(T a, T b) { return (a % b) ? 1 : 0; }
void sieve(vector<char> &prime, int range) {
prime.resize(range + 1, 1);
prime[0] = prime[1] = 0;
for (int i = 2; i * i <= range; i++)
if (prime[i])
for (int j = (i << 1); j <= range; j += i)
prime[j] = 0;
return;
}
void sieve(vector<char> &prime, vector<int> &prime_list, int range) {
prime.resize(range + 1, 1);
prime[0] = prime[1] = 0;
for (int i = 2; i * i <= range; i++)
if (prime[i]) {
prime_list.push_back(i);
for (int j = (i << 1); j <= range; j += i)
prime[j] = 0;
}
return;
}
void sieve(vector<char> &prime, vector<ll> &prime_list, int range) {
prime.resize(range + 1, 1);
prime[0] = prime[1] = 0;
for (ll i = 2; i * i <= range; i++)
if (prime[i]) {
prime_list.push_back(i);
for (ll j = (i << 1); j <= (ll)range; j += i)
prime[j] = 0;
}
return;
}
bool is_letter(char a) {
if (('a' <= a && a <= 'z') || ('A' <= a && a <= 'Z'))
return true;
return false;
}
bool is_vowel(char a) {
string vowels = "aeiouyAEIOUY";
for (char c : vowels)
if (c == a)
return true;
return false;
}
bool is_valid(int i, int j, int N, int M) {
return 0 <= i && i < N && 0 <= j && j < M;
}
bool all_adjacents_valid(int i, int j, int N, int M) {
for (int di = -1; di <= 1; di++)
for (int dj = -1; dj <= 1; dj++)
if (sq(di) + sq(dj) == 1 && !is_valid(i + di, j + dj, N, M))
return false;
return true;
}
bool is_prime(int a) {
if (a == 2)
return true;
if (!(a & 1))
return false;
for (int i = 3; i * i <= a; i += 2)
if (!(a % i))
return false;
return true;
}
bool is_prime(ll a) {
if (a == 2)
return true;
if (!(a & 1))
return false;
for (ll i = 3; i * i <= a; i += 2)
if (!(a % i))
return false;
return true;
}
bool is_palindrome(string s) {
int len = (int)s.length();
int mid = len >> 1;
for (int i = 0; i < mid; i++)
if (s[i] != s[len - i - 1])
return false;
return true;
}
bool is_palindrome(vector<char> s) {
int len = (int)s.size();
int mid = len >> 1;
for (int i = 0; i < mid; i++)
if (s[i] != s[len - i - 1])
return false;
return true;
}
int gcd(int a, int b) {
while (b) {
int mod = a % b;
a = b;
b = mod;
}
return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int binpow(int a, int b) {
int res = 1;
while (b) {
if (b & 1)
res *= a;
a *= a;
b >>= 1;
}
return res;
}
int binpow(int a, int b, int MODULO) {
int res = 1;
while (b) {
if (b & 1) {
res *= a;
res %= MODULO;
}
a *= a;
a %= MODULO;
b >>= 1;
}
return res;
}
ll gcd(ll a, ll b) {
while (b) {
ll mod = a % b;
a = b;
b = mod;
}
return a;
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll binpow(ll a, ll b) {
ll res = 1;
while (b) {
if (b & 1)
res *= a;
a *= a;
b >>= 1;
}
return res;
}
ll binpow(ll a, ll b, ll MODULO) {
ll res = 1;
while (b) {
if (b & 1) {
res *= a;
res %= MODULO;
}
a *= a;
a %= MODULO;
b >>= 1;
}
return res;
}
double distance(int X1, int Y1, int X2, int Y2) {
return sqrt(sq(X1 - X2) + sq(Y1 - Y2));
}
double distance(ll X1, ll Y1, ll X2, ll Y2) {
return sqrt(sq(X1 - X2) + sq(Y1 - Y2));
}
double distance(double X1, double Y1, double X2, double Y2) {
return sqrt(sq(X1 - X2) + sq(Y1 - Y2));
}
string binary(int N) {
if (!N)
return "0";
string bin = "";
while (N) {
bin += '0' + (N & 1);
N >>= 1;
}
reverse(all(bin));
return bin;
}
string binary(ll N) {
if (!N)
return "0";
string bin = "";
while (N) {
bin += '0' + (N & 1);
N >>= 1;
}
reverse(all(bin));
return bin;
}
vector<char> binary_v(int N) {
if (!N)
return {'0'};
vector<char> bin;
while (N) {
bin.push_back('0' + (N & 1));
N >>= 1;
}
reverse(all(bin));
return bin;
}
vector<char> binary_v(ll N) {
if (!N)
return {'0'};
vector<char> bin;
while (N) {
bin.push_back('0' + (N & 1));
N >>= 1;
}
reverse(all(bin));
return bin;
}
const int INF = 2147483547; // Max int value - 100 so it will not overflow
const int MODULO = 1000000007;
const int _MODULO = 998244353;
const ll INF64 =
9223372036854775707; // Max long long value - 100 so it will not overflow
const ll MODULO64 = 1000000007;
const ll _MODULO64 = 998244353;
const double epsilon = 10e-6;
const double PI = acos(-1);
int main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
auto t1 = chrono::high_resolution_clock::now();
#define debug(x) cerr << #x << " = " << x << "\n";
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
map<string, int> mp;
int N;
cin >> N;
for (int i = 0; i < N; i++) {
string s;
cin >> s;
sort(all(s));
mp[s]++;
}
ll ans = 0;
for (auto c : mp)
ans += c.second * (c.second - 1) / 2;
cout << ans << '\n';
#ifdef LOCAL
auto t2 = chrono::high_resolution_clock::now();
cerr << "Running time "
<< chrono::duration_cast<chrono::nanoseconds>(t2 - t1).count()
<< " nanoseconds" << endl;
#endif
return 0;
} | #include <bits/stdc++.h>
#define debug(x)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sq(x) ((x) * (x))
#define PRECISION 30
using namespace std;
template <class T> int check_mod(T a, T b) { return (a % b) ? 1 : 0; }
void sieve(vector<char> &prime, int range) {
prime.resize(range + 1, 1);
prime[0] = prime[1] = 0;
for (int i = 2; i * i <= range; i++)
if (prime[i])
for (int j = (i << 1); j <= range; j += i)
prime[j] = 0;
return;
}
void sieve(vector<char> &prime, vector<int> &prime_list, int range) {
prime.resize(range + 1, 1);
prime[0] = prime[1] = 0;
for (int i = 2; i * i <= range; i++)
if (prime[i]) {
prime_list.push_back(i);
for (int j = (i << 1); j <= range; j += i)
prime[j] = 0;
}
return;
}
void sieve(vector<char> &prime, vector<ll> &prime_list, int range) {
prime.resize(range + 1, 1);
prime[0] = prime[1] = 0;
for (ll i = 2; i * i <= range; i++)
if (prime[i]) {
prime_list.push_back(i);
for (ll j = (i << 1); j <= (ll)range; j += i)
prime[j] = 0;
}
return;
}
bool is_letter(char a) {
if (('a' <= a && a <= 'z') || ('A' <= a && a <= 'Z'))
return true;
return false;
}
bool is_vowel(char a) {
string vowels = "aeiouyAEIOUY";
for (char c : vowels)
if (c == a)
return true;
return false;
}
bool is_valid(int i, int j, int N, int M) {
return 0 <= i && i < N && 0 <= j && j < M;
}
bool all_adjacents_valid(int i, int j, int N, int M) {
for (int di = -1; di <= 1; di++)
for (int dj = -1; dj <= 1; dj++)
if (sq(di) + sq(dj) == 1 && !is_valid(i + di, j + dj, N, M))
return false;
return true;
}
bool is_prime(int a) {
if (a == 2)
return true;
if (!(a & 1))
return false;
for (int i = 3; i * i <= a; i += 2)
if (!(a % i))
return false;
return true;
}
bool is_prime(ll a) {
if (a == 2)
return true;
if (!(a & 1))
return false;
for (ll i = 3; i * i <= a; i += 2)
if (!(a % i))
return false;
return true;
}
bool is_palindrome(string s) {
int len = (int)s.length();
int mid = len >> 1;
for (int i = 0; i < mid; i++)
if (s[i] != s[len - i - 1])
return false;
return true;
}
bool is_palindrome(vector<char> s) {
int len = (int)s.size();
int mid = len >> 1;
for (int i = 0; i < mid; i++)
if (s[i] != s[len - i - 1])
return false;
return true;
}
int gcd(int a, int b) {
while (b) {
int mod = a % b;
a = b;
b = mod;
}
return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int binpow(int a, int b) {
int res = 1;
while (b) {
if (b & 1)
res *= a;
a *= a;
b >>= 1;
}
return res;
}
int binpow(int a, int b, int MODULO) {
int res = 1;
while (b) {
if (b & 1) {
res *= a;
res %= MODULO;
}
a *= a;
a %= MODULO;
b >>= 1;
}
return res;
}
ll gcd(ll a, ll b) {
while (b) {
ll mod = a % b;
a = b;
b = mod;
}
return a;
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll binpow(ll a, ll b) {
ll res = 1;
while (b) {
if (b & 1)
res *= a;
a *= a;
b >>= 1;
}
return res;
}
ll binpow(ll a, ll b, ll MODULO) {
ll res = 1;
while (b) {
if (b & 1) {
res *= a;
res %= MODULO;
}
a *= a;
a %= MODULO;
b >>= 1;
}
return res;
}
double distance(int X1, int Y1, int X2, int Y2) {
return sqrt(sq(X1 - X2) + sq(Y1 - Y2));
}
double distance(ll X1, ll Y1, ll X2, ll Y2) {
return sqrt(sq(X1 - X2) + sq(Y1 - Y2));
}
double distance(double X1, double Y1, double X2, double Y2) {
return sqrt(sq(X1 - X2) + sq(Y1 - Y2));
}
string binary(int N) {
if (!N)
return "0";
string bin = "";
while (N) {
bin += '0' + (N & 1);
N >>= 1;
}
reverse(all(bin));
return bin;
}
string binary(ll N) {
if (!N)
return "0";
string bin = "";
while (N) {
bin += '0' + (N & 1);
N >>= 1;
}
reverse(all(bin));
return bin;
}
vector<char> binary_v(int N) {
if (!N)
return {'0'};
vector<char> bin;
while (N) {
bin.push_back('0' + (N & 1));
N >>= 1;
}
reverse(all(bin));
return bin;
}
vector<char> binary_v(ll N) {
if (!N)
return {'0'};
vector<char> bin;
while (N) {
bin.push_back('0' + (N & 1));
N >>= 1;
}
reverse(all(bin));
return bin;
}
const int INF = 2147483547; // Max int value - 100 so it will not overflow
const int MODULO = 1000000007;
const int _MODULO = 998244353;
const ll INF64 =
9223372036854775707; // Max long long value - 100 so it will not overflow
const ll MODULO64 = 1000000007;
const ll _MODULO64 = 998244353;
const double epsilon = 10e-6;
const double PI = acos(-1);
int main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
auto t1 = chrono::high_resolution_clock::now();
#define debug(x) cerr << #x << " = " << x << "\n";
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
map<string, ll> mp;
int N;
cin >> N;
for (int i = 0; i < N; i++) {
string s;
cin >> s;
sort(all(s));
mp[s]++;
}
ll ans = 0;
for (auto c : mp)
ans += c.second * (c.second - 1) / 2;
cout << ans << '\n';
#ifdef LOCAL
auto t2 = chrono::high_resolution_clock::now();
cerr << "Running time "
<< chrono::duration_cast<chrono::nanoseconds>(t2 - t1).count()
<< " nanoseconds" << endl;
#endif
return 0;
} | [] | 749,160 | 749,161 | u464939155 | cpp |
p02947 | #include <algorithm>
#include <deque>
#include <iostream>
#include <math.h>
#include <queue>
#include <stdlib.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
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;
}
// INT_MAX 2,147,483,647 = 2*1.0e9
int main() {
int N;
cin >> N;
vector<string> S(N);
rep(i, N) cin >> S[i];
vector<vector<int>> S_int(N, vector<int>(10));
for (int i = 0; i < N; i++) {
for (int j = 0; j < 10; j++) {
S_int[i][j] = int(S[i][j] - 'a');
}
}
for (int i = 0; i < N; i++) {
sort(S_int[i].begin(), S_int[i].end());
}
sort(S_int.begin(), S_int.end());
ll ans = 0;
int pos = 0;
while (pos < N - 1) {
int cnt = 1;
int endI;
bool flag = true;
for (int j = pos + 1; j < N; j++) {
for (int k = 0; k < 10; k++) {
if (S_int[pos][k] != S_int[j][k]) {
flag = false;
break;
}
}
if (flag)
cnt++;
else {
endI = j;
break;
}
if (j == N - 1)
endI = N;
}
pos = endI;
ans += cnt * (cnt - 1) / 2;
}
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <deque>
#include <iostream>
#include <math.h>
#include <queue>
#include <stdlib.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
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;
}
// INT_MAX 2,147,483,647 = 2*1.0e9
int main() {
int N;
cin >> N;
vector<string> S(N);
rep(i, N) cin >> S[i];
vector<vector<int>> S_int(N, vector<int>(10));
for (int i = 0; i < N; i++) {
for (int j = 0; j < 10; j++) {
S_int[i][j] = int(S[i][j] - 'a');
}
}
for (int i = 0; i < N; i++) {
sort(S_int[i].begin(), S_int[i].end());
}
sort(S_int.begin(), S_int.end());
ll ans = 0;
int pos = 0;
while (pos < N - 1) {
ll cnt = 1;
int endI;
bool flag = true;
for (int j = pos + 1; j < N; j++) {
for (int k = 0; k < 10; k++) {
if (S_int[pos][k] != S_int[j][k]) {
flag = false;
break;
}
}
if (flag)
cnt++;
else {
endI = j;
break;
}
if (j == N - 1)
endI = N;
}
pos = endI;
ans += cnt * (cnt - 1) / 2;
}
cout << ans << endl;
return 0;
}
| [
"variable_declaration.type.change"
] | 749,162 | 749,163 | u561443723 | cpp |
p02947 | #include <bits/stdc++.h>
#define endl "\n"
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;
map<string, int> m;
string s;
int n, tmp;
ll ans;
int main() {
IOS cin >> n;
for (int i = 0; i < n; ++i) {
cin >> s;
sort(s.begin(), s.end());
m[s]++;
}
for (auto p : m) {
tmp = p.second;
ans += (tmp * (tmp - 1)) >> 1;
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#define endl "\n"
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;
map<string, ll> m;
string s;
int n;
ll ans, tmp;
int main() {
IOS cin >> n;
for (int i = 0; i < n; ++i) {
cin >> s;
sort(s.begin(), s.end());
m[s]++;
}
for (auto p : m) {
tmp = p.second;
ans += (tmp * (tmp - 1)) >> 1;
}
cout << ans << endl;
return 0;
}
| [
"variable_declaration.add",
"variable_declaration.remove"
] | 749,164 | 749,165 | u398135166 | cpp |
p02947 | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
int n, count = 0;
cin >> n;
map<string, int> mp;
for (int i = 0; i < n; i++) {
string str;
cin >> str;
sort(str.begin(), str.end());
mp[str]++;
}
for (auto x : mp) {
int a = x.second;
count += ((a * (a - 1)) / 2);
}
cout << count;
return 0;
}
| #include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
long long n, count = 0;
cin >> n;
map<string, long long> mp;
for (int i = 0; i < n; i++) {
string str;
cin >> str;
sort(str.begin(), str.end());
mp[str]++;
}
for (auto x : mp) {
long long a = x.second;
count += ((a * (a - 1)) / 2);
}
cout << count;
return 0;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 749,166 | 749,167 | u055711678 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF 1000000000
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef long double ld;
//ある値がvector内の要素に含まれているか否か判定する
int vector_finder(std::vector<int> vec, int number) {
auto itr = std::find(vec.begin(), vec.end(), number);
size_t index = std::distance(vec.begin(), itr);
if (index != vec.size()) { // 発見できたとき
return 1;
} else { // 発見できなかったとき
return 0;
}
}
struct edge_t {
int dest;
int weight;
};
struct vertex_t {
vector<edge_t> edges;
vector<int> weight;
// for dijkstra
bool done; // confirm or not
int cost; // now cost
int from;
bool operator<(const vertex_t &another) const { // priority --> min
return another.cost < cost; // order(cost)
}
bool operator>(const vertex_t &another) const { // priority --> min
return another.cost > cost; // order(cost)
}
bool operator==(const vertex_t &another) const {
return another.cost == cost; // order(cost)
}
vertex_t() {
cost = INF;
done = false;
}
};
int bellman_ford(vector<vertex_t> &graph, int size, int start) {
int i, j, k, count = 0;
bool flag = false;
graph[start].cost = 0;
REP(i, size) {
REP(j, size) {
vertex_t cur = graph[j];
for (edge_t edge : cur.edges) {
if (cur.cost + edge.weight < graph[edge.dest].cost) {
if (i == size - 1)
flag = true;
graph[edge.dest].cost = cur.cost + edge.weight;
}
}
}
}
if (flag) {
return 1;
} else {
return 0;
}
}
class tree_t {
public:
bool is_leaf;
tree_t *right;
tree_t *left;
tree_t() {
is_leaf = false;
right = NULL;
left = NULL;
}
};
vector<string> splitstr(const string &s, char delim) {
vector<string> elems;
string item;
for (char ch : s) {
if (ch == delim) {
if (!item.empty())
elems.push_back(item);
item.clear();
} else {
item += ch;
}
}
if (!item.empty())
elems.push_back(item);
return elems;
}
unsigned getDigitNum(unsigned num) {
unsigned digit = 0;
while (num != 0) {
num /= 10;
digit++;
}
return digit;
}
////////////////////////// let's code! /////////////////////////////
// REP(i, N) -> i = (0..N-1)
// for(int i=0; i < N; i++) -> 最終的にiはN
///// memo /////
int i, j, k;
///// variables frequent to use /////
long permutation(int n, int min) {
if (n == min) {
return n;
} else {
return n * permutation(n - 1, min);
}
}
long combination(int n, int r) {
if (n < r)
return 0;
else
return (long)(permutation(n, r + 1) / permutation(r, 1));
}
int main() {
int N;
cin >> N;
vector<string> S(N);
REP(i, N) cin >> S[i];
REP(i, N) {
REP(j, 10) {
REP(k, 10) {
if (S[i][j] < S[i][k]) {
char tmp = S[i][j];
S[i][j] = S[i][k];
S[i][k] = tmp;
}
}
}
}
sort(S.begin(), S.end());
long ans = 0;
vector<pair<string, int>> runlength;
string s;
int count;
REP(i, N) {
if (i == 0) {
count = 1, s = S[i];
} else if (s == S[i]) {
count++;
} else {
runlength.push_back(make_pair(s, count));
s = S[i];
count = 1;
}
if (i == N - 1)
runlength.push_back(make_pair(s, count));
}
REP(i, runlength.size()) ans += combination(runlength[i].second, 2);
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF 1000000000
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef long double ld;
//ある値がvector内の要素に含まれているか否か判定する
int vector_finder(std::vector<int> vec, int number) {
auto itr = std::find(vec.begin(), vec.end(), number);
size_t index = std::distance(vec.begin(), itr);
if (index != vec.size()) { // 発見できたとき
return 1;
} else { // 発見できなかったとき
return 0;
}
}
struct edge_t {
int dest;
int weight;
};
struct vertex_t {
vector<edge_t> edges;
vector<int> weight;
// for dijkstra
bool done; // confirm or not
int cost; // now cost
int from;
bool operator<(const vertex_t &another) const { // priority --> min
return another.cost < cost; // order(cost)
}
bool operator>(const vertex_t &another) const { // priority --> min
return another.cost > cost; // order(cost)
}
bool operator==(const vertex_t &another) const {
return another.cost == cost; // order(cost)
}
vertex_t() {
cost = INF;
done = false;
}
};
int bellman_ford(vector<vertex_t> &graph, int size, int start) {
int i, j, k, count = 0;
bool flag = false;
graph[start].cost = 0;
REP(i, size) {
REP(j, size) {
vertex_t cur = graph[j];
for (edge_t edge : cur.edges) {
if (cur.cost + edge.weight < graph[edge.dest].cost) {
if (i == size - 1)
flag = true;
graph[edge.dest].cost = cur.cost + edge.weight;
}
}
}
}
if (flag) {
return 1;
} else {
return 0;
}
}
class tree_t {
public:
bool is_leaf;
tree_t *right;
tree_t *left;
tree_t() {
is_leaf = false;
right = NULL;
left = NULL;
}
};
vector<string> splitstr(const string &s, char delim) {
vector<string> elems;
string item;
for (char ch : s) {
if (ch == delim) {
if (!item.empty())
elems.push_back(item);
item.clear();
} else {
item += ch;
}
}
if (!item.empty())
elems.push_back(item);
return elems;
}
unsigned getDigitNum(unsigned num) {
unsigned digit = 0;
while (num != 0) {
num /= 10;
digit++;
}
return digit;
}
////////////////////////// let's code! /////////////////////////////
// REP(i, N) -> i = (0..N-1)
// for(int i=0; i < N; i++) -> 最終的にiはN
///// memo /////
int i, j, k;
///// variables frequent to use /////
long permutation(int n, int min) {
if (n == min) {
return n;
} else {
return n * permutation(n - 1, min);
}
}
long combination(int n, int r) {
if (n < r)
return 0;
else
return (long)(permutation(n, n - r + 1) / permutation(r, 1));
}
int main() {
int N;
cin >> N;
vector<string> S(N);
REP(i, N) cin >> S[i];
REP(i, N) {
REP(j, 10) {
REP(k, 10) {
if (S[i][j] < S[i][k]) {
char tmp = S[i][j];
S[i][j] = S[i][k];
S[i][k] = tmp;
}
}
}
}
sort(S.begin(), S.end());
long ans = 0;
vector<pair<string, int>> runlength;
string s;
int count;
REP(i, N) {
if (i == 0) {
count = 1, s = S[i];
} else if (s == S[i]) {
count++;
} else {
runlength.push_back(make_pair(s, count));
s = S[i];
count = 1;
}
if (i == N - 1)
runlength.push_back(make_pair(s, count));
}
REP(i, runlength.size()) ans += combination(runlength[i].second, 2);
cout << ans << endl;
}
| [
"expression.operation.binary.add"
] | 749,168 | 749,169 | u518242261 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF 1000000000
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef long double ld;
//ある値がvector内の要素に含まれているか否か判定する
int vector_finder(std::vector<int> vec, int number) {
auto itr = std::find(vec.begin(), vec.end(), number);
size_t index = std::distance(vec.begin(), itr);
if (index != vec.size()) { // 発見できたとき
return 1;
} else { // 発見できなかったとき
return 0;
}
}
struct edge_t {
int dest;
int weight;
};
struct vertex_t {
vector<edge_t> edges;
vector<int> weight;
// for dijkstra
bool done; // confirm or not
int cost; // now cost
int from;
bool operator<(const vertex_t &another) const { // priority --> min
return another.cost < cost; // order(cost)
}
bool operator>(const vertex_t &another) const { // priority --> min
return another.cost > cost; // order(cost)
}
bool operator==(const vertex_t &another) const {
return another.cost == cost; // order(cost)
}
vertex_t() {
cost = INF;
done = false;
}
};
int bellman_ford(vector<vertex_t> &graph, int size, int start) {
int i, j, k, count = 0;
bool flag = false;
graph[start].cost = 0;
REP(i, size) {
REP(j, size) {
vertex_t cur = graph[j];
for (edge_t edge : cur.edges) {
if (cur.cost + edge.weight < graph[edge.dest].cost) {
if (i == size - 1)
flag = true;
graph[edge.dest].cost = cur.cost + edge.weight;
}
}
}
}
if (flag) {
return 1;
} else {
return 0;
}
}
class tree_t {
public:
bool is_leaf;
tree_t *right;
tree_t *left;
tree_t() {
is_leaf = false;
right = NULL;
left = NULL;
}
};
vector<string> splitstr(const string &s, char delim) {
vector<string> elems;
string item;
for (char ch : s) {
if (ch == delim) {
if (!item.empty())
elems.push_back(item);
item.clear();
} else {
item += ch;
}
}
if (!item.empty())
elems.push_back(item);
return elems;
}
unsigned getDigitNum(unsigned num) {
unsigned digit = 0;
while (num != 0) {
num /= 10;
digit++;
}
return digit;
}
////////////////////////// let's code! /////////////////////////////
// REP(i, N) -> i = (0..N-1)
// for(int i=0; i < N; i++) -> 最終的にiはN
///// memo /////
int i, j, k;
///// variables frequent to use /////
long permutation(int n, int min) {
if (n == min) {
return n;
} else {
return n * permutation(n - 1, min);
}
}
long combination(int n, int r) {
if (n < r)
return 0;
else
return (long)(permutation(n, r) / permutation(r, 1));
}
int main() {
int N;
cin >> N;
vector<string> S(N);
REP(i, N) cin >> S[i];
REP(i, N) {
REP(j, 10) {
REP(k, 10) {
if (S[i][j] < S[i][k]) {
char tmp = S[i][j];
S[i][j] = S[i][k];
S[i][k] = tmp;
}
}
}
}
sort(S.begin(), S.end());
long ans = 0;
vector<pair<string, int>> runlength;
string s;
int count;
REP(i, N) {
if (i == 0) {
count = 1, s = S[i];
} else if (s == S[i]) {
count++;
} else {
runlength.push_back(make_pair(s, count));
s = S[i];
count = 1;
}
if (i == N - 1)
runlength.push_back(make_pair(s, count));
}
REP(i, runlength.size()) ans += combination(runlength[i].second, 2);
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF 1000000000
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef long double ld;
//ある値がvector内の要素に含まれているか否か判定する
int vector_finder(std::vector<int> vec, int number) {
auto itr = std::find(vec.begin(), vec.end(), number);
size_t index = std::distance(vec.begin(), itr);
if (index != vec.size()) { // 発見できたとき
return 1;
} else { // 発見できなかったとき
return 0;
}
}
struct edge_t {
int dest;
int weight;
};
struct vertex_t {
vector<edge_t> edges;
vector<int> weight;
// for dijkstra
bool done; // confirm or not
int cost; // now cost
int from;
bool operator<(const vertex_t &another) const { // priority --> min
return another.cost < cost; // order(cost)
}
bool operator>(const vertex_t &another) const { // priority --> min
return another.cost > cost; // order(cost)
}
bool operator==(const vertex_t &another) const {
return another.cost == cost; // order(cost)
}
vertex_t() {
cost = INF;
done = false;
}
};
int bellman_ford(vector<vertex_t> &graph, int size, int start) {
int i, j, k, count = 0;
bool flag = false;
graph[start].cost = 0;
REP(i, size) {
REP(j, size) {
vertex_t cur = graph[j];
for (edge_t edge : cur.edges) {
if (cur.cost + edge.weight < graph[edge.dest].cost) {
if (i == size - 1)
flag = true;
graph[edge.dest].cost = cur.cost + edge.weight;
}
}
}
}
if (flag) {
return 1;
} else {
return 0;
}
}
class tree_t {
public:
bool is_leaf;
tree_t *right;
tree_t *left;
tree_t() {
is_leaf = false;
right = NULL;
left = NULL;
}
};
vector<string> splitstr(const string &s, char delim) {
vector<string> elems;
string item;
for (char ch : s) {
if (ch == delim) {
if (!item.empty())
elems.push_back(item);
item.clear();
} else {
item += ch;
}
}
if (!item.empty())
elems.push_back(item);
return elems;
}
unsigned getDigitNum(unsigned num) {
unsigned digit = 0;
while (num != 0) {
num /= 10;
digit++;
}
return digit;
}
////////////////////////// let's code! /////////////////////////////
// REP(i, N) -> i = (0..N-1)
// for(int i=0; i < N; i++) -> 最終的にiはN
///// memo /////
int i, j, k;
///// variables frequent to use /////
long permutation(int n, int min) {
if (n == min) {
return n;
} else {
return n * permutation(n - 1, min);
}
}
long combination(int n, int r) {
if (n < r)
return 0;
else
return (long)(permutation(n, n - r + 1) / permutation(r, 1));
}
int main() {
int N;
cin >> N;
vector<string> S(N);
REP(i, N) cin >> S[i];
REP(i, N) {
REP(j, 10) {
REP(k, 10) {
if (S[i][j] < S[i][k]) {
char tmp = S[i][j];
S[i][j] = S[i][k];
S[i][k] = tmp;
}
}
}
}
sort(S.begin(), S.end());
long ans = 0;
vector<pair<string, int>> runlength;
string s;
int count;
REP(i, N) {
if (i == 0) {
count = 1, s = S[i];
} else if (s == S[i]) {
count++;
} else {
runlength.push_back(make_pair(s, count));
s = S[i];
count = 1;
}
if (i == N - 1)
runlength.push_back(make_pair(s, count));
}
REP(i, runlength.size()) ans += combination(runlength[i].second, 2);
cout << ans << endl;
}
| [
"expression.operation.binary.add"
] | 749,170 | 749,169 | u518242261 | cpp |
p02947 | /*
*Author - Amarjeet Sinha
*/
#include <bits/stdc++.h>
#define ll long long
#define hell 1000000007
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define rep(i, a, b) for (ll int i = a; i < b; i++)
#define pi 3.1415926536
#define Mod 998244353
// #define npos NULL
// char a[2000][2000];
using namespace std;
int sum(ll a) {
int sum = 0;
while (a > 0) {
sum = sum + (a % 10);
a = a / 10;
}
return sum;
}
int count_digit(ll n) {
int count = 0;
while (n > 0) {
n = n / 10;
count++;
// count++;
}
return count;
}
int binarySearch(int x, int y, ll z, ll v[]) {
int low = x;
int high = y;
int mid = x + (y - x) / 2;
while (low <= high) {
if (v[mid] == z)
return mid;
if (v[mid] < z)
return binarySearch(mid + 1, high, z, v);
if (v[mid] > z)
return binarySearch(low, mid - 1, z, v);
}
return -1;
}
ll modularExponentiation(ll x, ll n, ll M) {
if (n == 0)
return 1;
else if (n % 2 == 0) // n is even
return modularExponentiation((x * x) % M, n / 2, M);
else // n is odd
return (x * modularExponentiation((x * x) % M, (n - 1) / 2, M)) % M;
}
ll binaryExponentiation(ll x, ll n) {
if (n == 0)
return 1;
else if (n % 2 == 0) // n is even
return binaryExponentiation(x * x, n / 2);
else // n is odd
return x * binaryExponentiation(x * x, (n - 1) / 2);
}
set<ll> s;
// vector<ll> v;
void genrate(ll n, int len, int max) {
if (len > max)
return;
s.insert(n);
genrate(n * 10 + 1, len + 1, max);
genrate(n * 10 + 0, len + 1, max);
}
bool visited[200005];
vector<ll> v[200005];
bool recur[200005];
int c = 0;
int res;
// memset(level,0,sizeof(level));
/*void topological_sort(int x)
{
visited[x] = 1;
// sort(all(v[x]));
for(int i =0;i<v[x].size();i++)
{
if(visited[v[x][i]]!=1){
//level[v[x][i]] = level[x]+1;
topological_sort(v[x][i]);
}
}
ans.pb(x);
}*/
// char a2001][2001];
///**************** Cycle using DSU *********************///
int findPivot(ll a[], int low, int high) {
int mid = (low + high) / 2;
if (high < low)
return -1;
if (low == high)
return low;
if (a[mid] >= a[mid + 1] && mid < high)
return mid;
if (a[mid - 1] >= a[mid] && mid > low)
return mid - 1;
if (a[mid] >= a[low])
return findPivot(a, mid + 1, high);
if (a[mid] <= a[low])
return findPivot(a, low, mid - 1);
}
int check(int m) {
cout << 1 << " " << m - 1 << " " << 1 << " ";
for (int i = 2; i <= m; i++)
cout << i << " ";
cout << endl;
fflush(stdout);
int res;
cin >> res;
return res;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// std::setprecision(20);
int tests = 1;
// freopen("input.txt", "r", stdin);
cin >> tests;
map<string, int> m;
while (tests--) {
string s;
cin >> s;
sort(all(s));
m[s]++;
}
int ans = 0;
for (auto it = m.begin(); it != m.end(); it++) {
ans = ans + (it->S) * (it->S - 1) / 2;
}
cout << ans;
}
| /*
*Author - Amarjeet Sinha
*/
#include <bits/stdc++.h>
#define ll long long
#define hell 1000000007
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define rep(i, a, b) for (ll int i = a; i < b; i++)
#define pi 3.1415926536
#define Mod 998244353
// #define npos NULL
// char a[2000][2000];
using namespace std;
int sum(ll a) {
int sum = 0;
while (a > 0) {
sum = sum + (a % 10);
a = a / 10;
}
return sum;
}
int count_digit(ll n) {
int count = 0;
while (n > 0) {
n = n / 10;
count++;
// count++;
}
return count;
}
int binarySearch(int x, int y, ll z, ll v[]) {
int low = x;
int high = y;
int mid = x + (y - x) / 2;
while (low <= high) {
if (v[mid] == z)
return mid;
if (v[mid] < z)
return binarySearch(mid + 1, high, z, v);
if (v[mid] > z)
return binarySearch(low, mid - 1, z, v);
}
return -1;
}
ll modularExponentiation(ll x, ll n, ll M) {
if (n == 0)
return 1;
else if (n % 2 == 0) // n is even
return modularExponentiation((x * x) % M, n / 2, M);
else // n is odd
return (x * modularExponentiation((x * x) % M, (n - 1) / 2, M)) % M;
}
ll binaryExponentiation(ll x, ll n) {
if (n == 0)
return 1;
else if (n % 2 == 0) // n is even
return binaryExponentiation(x * x, n / 2);
else // n is odd
return x * binaryExponentiation(x * x, (n - 1) / 2);
}
set<ll> s;
// vector<ll> v;
void genrate(ll n, int len, int max) {
if (len > max)
return;
s.insert(n);
genrate(n * 10 + 1, len + 1, max);
genrate(n * 10 + 0, len + 1, max);
}
bool visited[200005];
vector<ll> v[200005];
bool recur[200005];
int c = 0;
int res;
// memset(level,0,sizeof(level));
/*void topological_sort(int x)
{
visited[x] = 1;
// sort(all(v[x]));
for(int i =0;i<v[x].size();i++)
{
if(visited[v[x][i]]!=1){
//level[v[x][i]] = level[x]+1;
topological_sort(v[x][i]);
}
}
ans.pb(x);
}*/
// char a2001][2001];
///**************** Cycle using DSU *********************///
int findPivot(ll a[], int low, int high) {
int mid = (low + high) / 2;
if (high < low)
return -1;
if (low == high)
return low;
if (a[mid] >= a[mid + 1] && mid < high)
return mid;
if (a[mid - 1] >= a[mid] && mid > low)
return mid - 1;
if (a[mid] >= a[low])
return findPivot(a, mid + 1, high);
if (a[mid] <= a[low])
return findPivot(a, low, mid - 1);
}
int check(int m) {
cout << 1 << " " << m - 1 << " " << 1 << " ";
for (int i = 2; i <= m; i++)
cout << i << " ";
cout << endl;
fflush(stdout);
int res;
cin >> res;
return res;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// std::setprecision(20);
int tests = 1;
// freopen("input.txt", "r", stdin);
cin >> tests;
map<string, ll> m;
while (tests--) {
string s;
cin >> s;
sort(all(s));
m[s]++;
}
ll ans = 0;
for (auto it = m.begin(); it != m.end(); it++) {
ans = ans + (it->S) * (it->S - 1) / 2;
}
cout << ans;
}
| [
"variable_declaration.type.change"
] | 749,171 | 749,172 | u069325246 | cpp |
p02947 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
int main() {
int n;
cin >> n;
vector<string> data;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
sort(s.begin(), s.end());
data.push_back(s);
}
sort(data.begin(), data.end());
data.push_back("0");
int temp = 0;
ll ans = 0;
rep(i, n) {
temp++;
if (data[i] != data[i + 1]) {
ans += temp * (temp - 1) / 2;
temp = 0;
}
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
int main() {
int n;
cin >> n;
vector<string> data;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
sort(s.begin(), s.end());
data.push_back(s);
}
sort(data.begin(), data.end());
data.push_back("0");
int temp = 0;
ll ans = 0;
rep(i, n) {
temp++;
if (data[i] != data[i + 1]) {
ans += (ll)temp * (temp - 1) / 2;
temp = 0;
}
}
cout << ans << endl;
return 0;
}
| [
"type_conversion.add"
] | 749,173 | 749,174 | u639032323 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<string> anagrams;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
sort(s.begin(), s.end());
anagrams.push_back(s);
}
sort(anagrams.begin(), anagrams.end());
int power = 0;
int ans = 0;
for (int i = 0; i < anagrams.size() - 1; i++) {
if (anagrams[i] == anagrams[i + 1]) {
power++;
} else {
power = 0;
}
ans += power;
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<string> anagrams;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
sort(s.begin(), s.end());
anagrams.push_back(s);
}
sort(anagrams.begin(), anagrams.end());
long long int power = 0;
long long int ans = 0;
for (int i = 0; i < anagrams.size() - 1; i++) {
if (anagrams[i] == anagrams[i + 1]) {
power++;
} else {
power = 0;
}
ans += power;
}
cout << ans << endl;
}
| [
"variable_declaration.type.widen.change"
] | 749,175 | 749,176 | u240010800 | cpp |
p02947 | #include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
int N;
long long int result = 0;
cin >> N;
array<string, 100001> s;
for (int i = 0; i < N; ++i) {
cin >> s[i];
sort(s[i].begin(), s[i].end());
}
sort(s.begin(), s.begin() + N);
s[N] = "----------";
int k = 0;
for (int i = 0; i < N; ++i) {
if (s[i] == s[i + 1]) {
++k;
} else if (k != 0) {
result += k * (k + 1) / 2;
k = 0;
}
}
printf("%lld", result);
return 0;
}
| #include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
int N;
long long int result = 0;
cin >> N;
array<string, 100001> s;
for (int i = 0; i < N; ++i) {
cin >> s[i];
sort(s[i].begin(), s[i].end());
}
sort(s.begin(), s.begin() + N);
s[N] = "----------";
long long int k = 0;
for (int i = 0; i < N; ++i) {
if (s[i] == s[i + 1]) {
++k;
} else if (k != 0) {
result += k * (k + 1) / 2;
k = 0;
}
}
printf("%lld", result);
return 0;
}
| [
"variable_declaration.type.widen.change"
] | 749,177 | 749,178 | u643747754 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
int main() {
int n;
cin >> n;
unordered_map<string, int> m;
while (n--) {
string s;
cin >> s;
sort(s.begin(), s.end());
m[s]++;
}
long ans = 0;
for (auto p : m) {
int x = p.second - 1;
ans += (x + 1) * x / 2;
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
int main() {
int n;
cin >> n;
unordered_map<string, int> m;
while (n--) {
string s;
cin >> s;
sort(s.begin(), s.end());
m[s]++;
}
long ans = 0;
for (auto p : m) {
ll x = (ll)p.second - 1;
ans += (x + 1) * x / 2;
}
cout << ans << endl;
}
| [
"variable_declaration.type.change"
] | 749,183 | 749,184 | u874723578 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
int main() {
int n;
cin >> n;
unordered_map<string, int> m;
while (n--) {
string s;
cin >> s;
sort(s.begin(), s.end());
m[s]++;
}
ll ans = 0;
for (auto p : m) {
int x = p.second;
ans += x * (x - 1) / 2; // nC2
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
int main() {
int n;
cin >> n;
unordered_map<string, int> m;
while (n--) {
string s;
cin >> s;
sort(s.begin(), s.end());
m[s]++;
}
ll ans = 0;
for (auto p : m) {
ll x = (ll)p.second;
ans += x * (x - 1) / 2; // nC2
}
cout << ans << endl;
}
| [
"variable_declaration.type.change"
] | 749,185 | 749,186 | u874723578 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
int main() {
int n;
cin >> n;
unordered_map<string, int> m;
while (n--) {
string s;
cin >> s;
sort(s.begin(), s.end());
m[s]++;
}
long ans = 0;
for (auto p : m) {
int x = p.second;
ans += x * (x - 1) / 2; // nC2
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
int main() {
int n;
cin >> n;
unordered_map<string, int> m;
while (n--) {
string s;
cin >> s;
sort(s.begin(), s.end());
m[s]++;
}
ll ans = 0;
for (auto p : m) {
ll x = (ll)p.second;
ans += x * (x - 1) / 2; // nC2
}
cout << ans << endl;
}
| [
"variable_declaration.type.change"
] | 749,187 | 749,186 | u874723578 | cpp |
p02947 | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) // for文マクロ
#define all(obj) obj.begin(), obj.end()
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
constexpr ll bigNum = 1000000007;
signed main() {
fast;
//ここから本体
int n;
cin >> n;
vector<string> a(n);
for (int i = 0; i < n; i++) {
string x;
cin >> x;
sort(all(x));
a[i] = x;
}
sort(all(a));
ll ans = 0;
int c = 1;
for (int i = 0; i < n - 1; i++) {
if (a[i] == a[i + 1])
c++;
else {
ans += (c * (c - 1)) / 2;
c = 1;
}
}
ans += (c * (c - 1)) / 2;
cout << ans << endl;
} | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) // for文マクロ
#define all(obj) obj.begin(), obj.end()
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
constexpr ll bigNum = 1000000007;
signed main() {
fast;
//ここから本体
int n;
cin >> n;
vector<string> a(n);
for (int i = 0; i < n; i++) {
string x;
cin >> x;
sort(all(x));
a[i] = x;
}
sort(all(a));
ll ans = 0;
ll c = 1;
for (int i = 0; i < n - 1; i++) {
if (a[i] == a[i + 1])
c++;
else {
ans += (c * (c - 1)) / 2;
c = 1;
}
}
ans += (c * (c - 1)) / 2;
cout << ans << endl;
} | [
"variable_declaration.type.change"
] | 749,188 | 749,189 | u369980487 | cpp |
p02947 | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) // for文マクロ
#define all(obj) obj.begin(), obj.end()
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
constexpr ll bigNum = 1000000007;
signed main() {
fast;
//ここから本体
int n;
cin >> n;
vector<string> a(n);
for (int i = 0; i < n; i++) {
string x;
cin >> x;
sort(all(x));
a[i] = x;
}
sort(all(a));
ll ans = 0;
int c = 1;
for (int i = 0; i < n - 1; i++) {
if (a[i] == a[i + 1])
c++;
else {
ans += (c * (c - 1)) / 2;
c = 1;
}
}
ans += (c * (c - 1)) / 2;
cout << ans << endl;
} | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) // for文マクロ
#define all(obj) obj.begin(), obj.end()
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
constexpr ll bigNum = 1000000007;
signed main() {
fast;
//ここから本体
ll n;
cin >> n;
vector<string> a(n);
for (int i = 0; i < n; i++) {
string x;
cin >> x;
sort(all(x));
a[i] = x;
}
sort(all(a));
ll ans = 0;
ll c = 1;
for (int i = 0; i < n - 1; i++) {
if (a[i] == a[i + 1])
c++;
else {
ans += (c * (c - 1)) / 2;
c = 1;
}
}
ans += (c * (c - 1)) / 2;
cout << ans << endl;
} | [
"variable_declaration.type.change"
] | 749,188 | 749,192 | u369980487 | cpp |
p02947 | #include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
unordered_map<string, int> c;
int n;
for (cin >> n; n--;) {
string s;
cin >> s;
sort(begin(s), end(s));
c[s]++;
}
int r = 0;
for (auto const &x : c) {
r += x.second * (x.second - 1) / 2;
}
cout << r << '\n';
return 0;
}
| #include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
unordered_map<string, int> c;
int n;
for (cin >> n; n--;) {
string s;
cin >> s;
sort(begin(s), end(s));
c[s]++;
}
long long r = 0;
for (auto const &x : c) {
r += (long long)x.second * (x.second - 1) / 2;
}
cout << r << '\n';
return 0;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 749,202 | 749,203 | u021019433 | cpp |
p02947 | #include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
using namespace std;
using vi = vector<int>;
using pii = pair<int, int>;
using ull = unsigned long long;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
map<string, int> freq;
int n;
cin >> n;
int ans = 0;
while (n--) {
string s;
cin >> s;
sort(s.begin(), s.end());
ans += freq[s]++;
}
cout << ans << "\n";
return 0;
}
| #include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
using namespace std;
using vi = vector<int>;
using pii = pair<int, int>;
using ull = unsigned long long;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
map<string, int> freq;
int n;
cin >> n;
ull ans = 0;
while (n--) {
string s;
cin >> s;
sort(s.begin(), s.end());
ans += freq[s]++;
}
cout << ans << "\n";
return 0;
}
| [
"variable_declaration.type.change"
] | 749,207 | 749,208 | u263351103 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
typedef long int32;
typedef unsigned long uint32;
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vi> graph;
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(), (x).end()
#define debug(x, n) \
FOR(i, 0, n) cout << x[i] << " "; \
cout << endl
#define PI 3.14159265359
// Custom global variable
// ----------------------
auto main() -> int {
#ifdef DEBUG
freopen("input.txt", "r", stdin);
// freopen("output.txt","w",stdout);
#endif
// Fast I/O
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// Code starts here ----
map<string, int> E;
int n;
cin >> n;
FOR(i, 0, n) {
string s;
cin >> s;
sort(all(s));
E[s]++;
}
int64 res = 0;
for (auto it = E.begin(); it != E.end(); it++) {
if (it->nd > 1) {
res += (it->nd * (it->nd - 1)) / 2;
}
}
cout << res;
// ---------------------
#ifdef DEBUG
cerr << endl
<< "Time:" << double(clock()) / CLOCKS_PER_SEC << " secs" << endl;
#endif
}
| #include <bits/stdc++.h>
using namespace std;
typedef long int32;
typedef unsigned long uint32;
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vi> graph;
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(), (x).end()
#define debug(x, n) \
FOR(i, 0, n) cout << x[i] << " "; \
cout << endl
#define PI 3.14159265359
// Custom global variable
// ----------------------
auto main() -> int {
#ifdef DEBUG
freopen("input.txt", "r", stdin);
// freopen("output.txt","w",stdout);
#endif
// Fast I/O
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// Code starts here ----
map<string, int64> E;
int n;
cin >> n;
FOR(i, 0, n) {
string s;
cin >> s;
sort(all(s));
E[s]++;
}
int64 res = 0;
for (auto it = E.begin(); it != E.end(); it++) {
if (it->nd > 1) {
res += (it->nd * (it->nd - 1)) / 2;
}
}
cout << res;
// ---------------------
#ifdef DEBUG
cerr << endl
<< "Time:" << double(clock()) / CLOCKS_PER_SEC << " secs" << endl;
#endif
}
| [] | 749,209 | 749,210 | u384539725 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define UN unsigned int
#define mod 1000000007
#define F first
#define S second
#define mk make_pair
#define B(v) v.begin(), v.end()
#define BS binary_search
int main() {
int n;
cin >> n;
vector<string> v[n + 10];
for (int i = 0; i < n; i++) {
string s;
cin >> s;
v[i].pb(s);
}
map<string, int> mp;
for (int i = 0; i < n; i++) {
sort(v[i][0].begin(), v[i][0].end());
mp[v[i][0]]++;
}
int re = 0;
for (auto it : mp) {
re += (it.S * (it.S - 1)) / 2;
}
cout << re << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define UN unsigned int
#define mod 1000000007
#define F first
#define S second
#define mk make_pair
#define B(v) v.begin(), v.end()
#define BS binary_search
#define int ll
main() {
int n;
cin >> n;
vector<string> v[n + 10];
for (int i = 0; i < n; i++) {
string s;
cin >> s;
v[i].pb(s);
}
map<string, int> mp;
for (int i = 0; i < n; i++) {
sort(v[i][0].begin(), v[i][0].end());
mp[v[i][0]]++;
}
int re = 0;
for (auto it : mp) {
re += (it.S * (it.S - 1)) / 2;
}
cout << re << endl;
} | [] | 749,211 | 749,212 | u003209891 | cpp |
p02947 | #pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
unordered_map<string, int> p;
vector<string> k;
int main() {
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
ios_base::sync_with_stdio(0);
int N;
cin >> N;
for (int i = 0; i < N; i++) {
string a;
cin >> a;
sort(a.begin(), a.end());
k.push_back(a);
p[a]++;
}
sort(k.begin(), k.end());
k.resize(unique(k.begin(), k.end()) - k.begin());
int tot = 0;
for (int i = 0; i < k.size(); i++) {
string o = k[i];
tot += p[o] * (p[o] - 1) / 2;
}
cout << tot;
return 0;
}
| #pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
unordered_map<string, ll> p;
vector<string> k;
int main() {
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
ios_base::sync_with_stdio(0);
int N;
cin >> N;
for (int i = 0; i < N; i++) {
string a;
cin >> a;
sort(a.begin(), a.end());
k.push_back(a);
p[a]++;
}
sort(k.begin(), k.end());
k.resize(unique(k.begin(), k.end()) - k.begin());
ll tot = 0;
for (int i = 0; i < k.size(); i++) {
string o = k[i];
tot += p[o] * (p[o] - 1) / 2;
}
cout << tot;
return 0;
}
| [
"variable_declaration.type.change"
] | 749,216 | 749,217 | u854904794 | cpp |
p02947 | #include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
string a[10001];
int n;
int main() {
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++) {
// char b[12];
sort(a[i].begin(), a[i].end());
}
sort(a + 1, a + n + 1);
long long ans = 0;
long long length = 1;
/*for(int i=1;i<=n;i++)
cout<<a[i]<<endl;*/
for (int i = 1; i <= n; i++) {
while (a[i] == a[i + 1]) {
length++;
i++;
}
// cout<<length<<endl;
ans += length * (length - 1) / 2;
length = 1;
}
cout << ans;
} | #include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
string a[500001];
int n;
int main() {
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++) {
sort(a[i].begin(), a[i].end());
}
sort(a + 1, a + n + 1);
long long ans = 0;
long long length = 1;
/*for(int i=1;i<=n;i++)
cout<<a[i]<<endl;*/
for (int i = 1; i <= n; i++) {
while (a[i] == a[i + 1]) {
length++;
i++;
}
ans += length * (length - 1) / 2;
length = 1;
}
cout << ans;
} | [
"literal.number.change",
"variable_declaration.array_dimensions.change"
] | 749,220 | 749,219 | u289216945 | cpp |
p02947 | #include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vc vector<char>
#define vt vector<string>
#define si set<int>
#define sc set<char>
#define st set<string>
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back;
using namespace std;
map<string, int> mp;
int main() {
ll n;
cin >> n;
for (int i = 1; i <= n; i++) {
string s;
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
ll ans = 0;
for (auto e : mp)
if (e.se > 1)
ans += (e.se * (e.se - 1)) / 2;
cout << ans;
return 0;
}
| #include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vc vector<char>
#define vt vector<string>
#define si set<int>
#define sc set<char>
#define st set<string>
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back;
using namespace std;
map<string, ll> mp;
int main() {
ll n;
cin >> n;
for (int i = 1; i <= n; i++) {
string s;
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
ll ans = 0;
for (auto e : mp)
if (e.se > 1)
ans += (e.se * (e.se - 1)) / 2;
cout << ans;
return 0;
}
| [] | 749,221 | 749,222 | u453071216 | cpp |
p02947 | #include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vc vector<char>
#define vt vector<string>
#define si set<int>
#define sc set<char>
#define st set<string>
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back;
using namespace std;
map<string, int> mp;
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
string s;
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
int ans = 0;
for (auto e : mp)
if (e.se > 1)
ans += (e.se * (e.se - 1)) / 2;
cout << ans;
return 0;
}
| #include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vc vector<char>
#define vt vector<string>
#define si set<int>
#define sc set<char>
#define st set<string>
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back;
using namespace std;
map<string, ll> mp;
int main() {
ll n;
cin >> n;
for (int i = 1; i <= n; i++) {
string s;
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
ll ans = 0;
for (auto e : mp)
if (e.se > 1)
ans += (e.se * (e.se - 1)) / 2;
cout << ans;
return 0;
}
| [
"variable_declaration.type.change"
] | 749,223 | 749,222 | u453071216 | cpp |
p02947 | #include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vc vector<char>
#define vt vector<string>
#define si set<int>
#define sc set<char>
#define st set<string>
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back;
using namespace std;
map<string, int> mp;
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
string s;
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
int ans = 0;
for (auto e : mp)
if (e.se > 1)
ans += e.se * (e.se - 1) / 2;
cout << ans;
return 0;
}
| #include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vc vector<char>
#define vt vector<string>
#define si set<int>
#define sc set<char>
#define st set<string>
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back;
using namespace std;
map<string, ll> mp;
int main() {
ll n;
cin >> n;
for (int i = 1; i <= n; i++) {
string s;
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
ll ans = 0;
for (auto e : mp)
if (e.se > 1)
ans += (e.se * (e.se - 1)) / 2;
cout << ans;
return 0;
}
| [
"variable_declaration.type.change"
] | 749,224 | 749,222 | u453071216 | cpp |
p02947 | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) \
for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int> a(n)
#define PQ(a) priority_queue<int> a
#define PQmin(a) priority_queue<int, : vector<int>, greater<int>> a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
return l.first<r.first || (l.first==r.first && l.second > r.second);
});
*/
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int main() {
int n;
cin >> n;
vector<string> a(n);
for (int i = 0; i < n; i++) {
string s;
cin >> s;
sort(s.begin(), s.end());
a.at(i) = s;
}
sort(a.begin(), a.end());
a.push_back("ZZZZZZZZZZZZ");
int ans = 0;
for (int i = 0; i < n + 1; i++) {
for (int j = i + 1; j < n + 1; j++) {
if (a.at(i) != a.at(j)) {
ans = ans + (j - i - 1) * (j - i) / 2;
i = j - 1;
break;
}
// cout<<"i"<<i<<" j"<<j<<endl;
}
// cout<<"i"<<i<<endl;
}
// cout<<a.at(0)<<endl;
// cout<<a.at(1)<<endl;
// cout<<a.at(2)<<endl;
// cout<<"---------"<<endl;
// for(int i=0;i<n;i++){
// cout<<a.at(i)<<endl;
// }
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) \
for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int> a(n)
#define PQ(a) priority_queue<int> a
#define PQmin(a) priority_queue<int, : vector<int>, greater<int>> a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
return l.first<r.first || (l.first==r.first && l.second > r.second);
});
*/
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int main() {
int n;
cin >> n;
vector<string> a(n);
for (int i = 0; i < n; i++) {
string s;
cin >> s;
sort(s.begin(), s.end());
a.at(i) = s;
}
sort(a.begin(), a.end());
a.push_back("ZZZZZZZZZZZZ");
ll ans = 0;
for (ll i = 0; i < n + 1; i++) {
for (ll j = i + 1; j < n + 1; j++) {
if (a.at(i) != a.at(j)) {
ans = ans + (j - i - 1) * (j - i) / 2;
i = j - 1;
break;
}
// cout<<"i"<<i<<" j"<<j<<endl;
}
// cout<<"i"<<i<<endl;
}
// cout<<a.at(0)<<endl;
// cout<<a.at(1)<<endl;
// cout<<a.at(2)<<endl;
// cout<<"---------"<<endl;
// for(int i=0;i<n;i++){
// cout<<a.at(i)<<endl;
// }
cout << ans << endl;
return 0;
}
| [
"variable_declaration.type.change",
"control_flow.loop.for.initializer.change"
] | 749,232 | 749,233 | u275934251 | cpp |
p02947 | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
ll n, c = 0;
// c is count of pairs before taking new input
// map second value is occurence of that string previously
cin >> n;
unordered_map<string, int> m;
string s;
for (int i = 0; i < n; i++) {
cin >> s;
sort(s.begin(), s.end());
m[s]++;
}
for (auto x : m)
c += x.second * (x.second - 1) / 2;
cout << c << endl;
} | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
ll n, c = 0;
// c is count of pairs before taking new input
// map second value is occurence of that string previously
cin >> n;
unordered_map<string, ll> m;
string s;
for (int i = 0; i < n; i++) {
cin >> s;
sort(s.begin(), s.end());
m[s]++;
}
for (auto x : m)
c += x.second * (x.second - 1) / 2;
cout << c << endl;
} | [] | 749,234 | 749,235 | u758145613 | cpp |
p02947 | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
ll n, c = 0;
// c is count of pairs before taking new input
// map second value is occurence of that string previously
cin >> n;
unordered_map<string, int> m;
string s;
for (int i = 0; i < n; i++) {
cin >> s;
sort(s.begin(), s.end());
m[s]++;
}
for (auto x : m)
c += x.second * (x.second - 1) / 2;
cout << c;
} | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
ll n, c = 0;
// c is count of pairs before taking new input
// map second value is occurence of that string previously
cin >> n;
unordered_map<string, ll> m;
string s;
for (int i = 0; i < n; i++) {
cin >> s;
sort(s.begin(), s.end());
m[s]++;
}
for (auto x : m)
c += x.second * (x.second - 1) / 2;
cout << c << endl;
} | [
"io.output.newline.add"
] | 749,236 | 749,235 | u758145613 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
map<string, int> mp;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
sort(s.begin(), s.end());
mp.at(s)++;
}
long long ans = 0;
for (auto p : mp) {
long long s = p.second;
ans += s * (s + 1) / 2;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
map<string, int> mp;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
long long ans = 0;
for (auto p : mp) {
long long s = p.second;
ans += s * (s - 1) / 2;
}
cout << ans << endl;
}
| [
"call.remove",
"call.arguments.change",
"misc.opposites",
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 749,238 | 749,239 | u522993719 | cpp |
p02947 | #include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
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]++;
}
long long result = 0;
for (auto &e : mp) {
int v = e.second;
result += (long long)(v * (v - 1) / 2);
}
cout << result << "\n";
return 0;
} | #include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
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]++;
}
long long result = 0;
for (auto &e : mp) {
int v = e.second;
result += (long long)v * (v - 1) / 2;
}
cout << result << "\n";
return 0;
}
| [] | 749,242 | 749,241 | u295651044 | cpp |
p02947 | #include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
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]++;
}
long long result = 0;
for (auto &e : mp) {
int v = e.second;
result += (long long)(v * (v - 1) / 2);
}
cout << result << "\n";
return 0;
}
| #include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
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]++;
}
long long result = 0;
for (auto &e : mp) {
int v = e.second;
result += (long long)v * (v - 1) / 2;
}
cout << result << "\n";
return 0;
}
| [] | 749,243 | 749,241 | u295651044 | cpp |
p02947 | #include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<string> vec;
for (int i = 0; i < n; i++) {
string tmp;
cin >> tmp;
vector<char> chars;
for (int i = 0; i < tmp.length(); i++) {
chars.push_back(tmp[i]);
}
sort(chars.begin(), chars.end());
string str(chars.begin(), chars.end());
vec.push_back(str);
}
unordered_map<string, int> mp;
int sum = 0;
for (string s : vec) {
auto it = mp.find(s);
if (it != mp.end()) {
sum += mp[s];
mp[s] = mp[s] + 1;
} else {
mp[s] = 1;
}
}
cout << sum << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<string> vec;
for (int i = 0; i < n; i++) {
string tmp;
cin >> tmp;
vector<char> chars;
for (int i = 0; i < tmp.length(); i++) {
chars.push_back(tmp[i]);
}
sort(chars.begin(), chars.end());
string str(chars.begin(), chars.end());
vec.push_back(str);
}
unordered_map<string, int> mp;
long sum = 0;
for (string s : vec) {
auto it = mp.find(s);
if (it != mp.end()) {
sum += mp[s];
mp[s] = mp[s] + 1;
} else {
mp[s] = 1;
}
}
cout << sum << endl;
return 0;
}
| [
"variable_declaration.type.primitive.change"
] | 749,246 | 749,247 | u275316733 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
string sortString(string s) {
// 文字列s をソートして返す
int len = s.size();
vector<char> v(len);
for (int i = 0; i < len; ++i) {
v[i] = s[i];
}
sort(v.begin(), v.end());
string ret = "";
for (int i = 0; i < len; ++i) {
ret += v[i];
}
return ret;
}
int main() {
int N;
cin >> N;
map<string, int> count;
for (int i = 0; i < N; ++i) {
string s;
cin >> s;
s = sortString(s);
count[s] += 1;
}
long long ans = 0; // 答えは 32bit 整数型(int)に収まらない
// 可能性があるので, long long を使う
for (auto it = count.begin(); it != count.end(); it++) {
int n = it->second;
ans += n * (n - 1) / 2;
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
string sortString(string s) {
// 文字列s をソートして返す
int len = s.size();
vector<char> v(len);
for (int i = 0; i < len; ++i) {
v[i] = s[i];
}
sort(v.begin(), v.end());
string ret = "";
for (int i = 0; i < len; ++i) {
ret += v[i];
}
return ret;
}
int main() {
int N;
cin >> N;
map<string, long long> count;
// 答えは 32bit 整数型(int)に収まらない
// 可能性があるので, long long を使う
for (int i = 0; i < N; ++i) {
string s;
cin >> s;
s = sortString(s);
count[s] += 1;
}
long long ans = 0;
for (auto it = count.begin(); it != count.end(); it++) {
long long n = it->second;
ans += n * (n - 1) / 2;
}
cout << ans << endl;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 749,250 | 749,251 | u960524878 | cpp |
p02947 | #include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
typedef __int128_t int128_t;
std::istream &
operator>>(std::istream &input,
int128_t &value) { // int128_tの入力。入力が64bitに収まる前提。
long long tmp;
input >> tmp;
value = tmp;
return input;
}
std::ostream &
operator<<(std::ostream &output,
const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
output << (long long)value;
return output;
}
// 文字列Sに各文字が何回出現するかカウント。始まりの文字がcで、文字種類数がk
// 例えばSに含まれる文字が'a-z'であれば、c='a', k=26とする。
std::vector<int> count_char(const std::string &S, const char c, const int k) {
std::vector<int> ret;
ret.resize(k, 0);
for (int i = 0; i < S.size(); i++) {
assert(S[i] - c < k);
ret[S[i] - c]++;
}
return ret;
}
#define rep(i, begin, end) for (int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for (int64_t i = (begin); (end) <= i; i--)
void printvec(const std::vector<int> &vec) {
for (int i = 0; i < vec.size(); i++) {
std::cout << vec[i] << " ";
}
std::cout << std::endl;
}
const int MAX_N = 12;
int N;
std::string S[MAX_N];
std::map<std::string, int128_t> mp;
int main(int argc, char **argv) {
std::cin >> N;
rep(i, 1, N) {
std::cin >> S[i];
std::sort(S[i].begin(), S[i].end());
mp[S[i]]++;
}
int128_t ret = 0;
for (auto p : mp) {
ret += (p.second * (p.second - 1)) / 2;
}
std::cout << ret << std::endl;
return 0;
} | #include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
typedef __int128_t int128_t;
std::istream &
operator>>(std::istream &input,
int128_t &value) { // int128_tの入力。入力が64bitに収まる前提。
long long tmp;
input >> tmp;
value = tmp;
return input;
}
std::ostream &
operator<<(std::ostream &output,
const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
output << (long long)value;
return output;
}
// 文字列Sに各文字が何回出現するかカウント。始まりの文字がcで、文字種類数がk
// 例えばSに含まれる文字が'a-z'であれば、c='a', k=26とする。
std::vector<int> count_char(const std::string &S, const char c, const int k) {
std::vector<int> ret;
ret.resize(k, 0);
for (int i = 0; i < S.size(); i++) {
assert(S[i] - c < k);
ret[S[i] - c]++;
}
return ret;
}
#define rep(i, begin, end) for (int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for (int64_t i = (begin); (end) <= i; i--)
void printvec(const std::vector<int> &vec) {
for (int i = 0; i < vec.size(); i++) {
std::cout << vec[i] << " ";
}
std::cout << std::endl;
}
const int MAX_N = 1e5 + 10;
int N;
std::string S[MAX_N];
std::map<std::string, int128_t> mp;
int main(int argc, char **argv) {
std::cin >> N;
rep(i, 1, N) {
std::cin >> S[i];
std::sort(S[i].begin(), S[i].end());
mp[S[i]]++;
}
int128_t ret = 0;
for (auto p : mp) {
ret += (p.second * (p.second - 1)) / 2;
}
std::cout << ret << std::endl;
return 0;
} | [
"literal.number.change"
] | 749,254 | 749,255 | u370768058 | cpp |
p02947 | #include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <string>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
int n;
cin >> n;
unordered_map<string, int> mp;
rep(i, n) {
string s;
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
ll ans = 0;
for (auto &p : mp) {
int s = p.second;
ans += (ll)((s * (s - 1)) / 2);
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <string>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
int n;
cin >> n;
unordered_map<string, ll> mp;
rep(i, n) {
string s;
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
ll ans = 0;
for (auto &p : mp) {
ll s = p.second;
ans += (ll)((s * (s - 1)) / 2);
}
cout << ans << endl;
return 0;
} | [
"variable_declaration.type.change"
] | 749,256 | 749,257 | u292106243 | cpp |
p02947 | #include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <string>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
int n;
cin >> n;
unordered_map<string, int> mp;
rep(i, n) {
string s;
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
ll ans = 0;
for (auto &p : mp) {
int s = p.second;
ans += (ll)(s * (s - 1)) / 2;
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <string>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
int n;
cin >> n;
unordered_map<string, ll> mp;
rep(i, n) {
string s;
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
ll ans = 0;
for (auto &p : mp) {
ll s = p.second;
ans += (ll)((s * (s - 1)) / 2);
}
cout << ans << endl;
return 0;
} | [
"variable_declaration.type.change",
"call.arguments.change"
] | 749,258 | 749,257 | u292106243 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<string> s(n);
int count = 0;
unordered_map<string, int> hash;
for (int i = 0; i < n; i++) {
cin >> s[i];
sort(s[i].begin(), s[i].end());
if (hash[s[i]] != NULL) {
count += hash[s[i]];
hash[s[i]]++;
} else
hash[s[i]] = 1;
}
cout << count << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<string> s(n);
long long int count = 0;
unordered_map<string, int> hash;
for (int i = 0; i < n; i++) {
cin >> s[i];
sort(s[i].begin(), s[i].end());
if (hash[s[i]] != NULL) {
count += hash[s[i]];
hash[s[i]]++;
} else
hash[s[i]] = 1;
}
cout << count << endl;
}
| [
"variable_declaration.type.widen.change"
] | 749,259 | 749,260 | u321094662 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<string> s(n);
int count = 0;
unordered_map<string, int> hash;
for (int i = 0; i < n; i++) {
cin >> s[i];
sort(s[i].begin(), s[i].end());
if (hash[s[i]] > 0) {
count += hash[s[i]];
hash[s[i]]++;
} else
hash[s[i]] = 1;
}
cout << count << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<string> s(n);
long long int count = 0;
unordered_map<string, int> hash;
for (int i = 0; i < n; i++) {
cin >> s[i];
sort(s[i].begin(), s[i].end());
if (hash[s[i]] != NULL) {
count += hash[s[i]];
hash[s[i]]++;
} else
hash[s[i]] = 1;
}
cout << count << endl;
}
| [
"control_flow.loop.for.condition.change"
] | 749,261 | 749,260 | u321094662 | cpp |
p02947 | #include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int n;
int co;
string V[100005];
map<string, long long> m;
void input() {
cin >> n;
string t;
for (int i = 0; i < n; i++) {
cin >> V[i];
sort(V[i].begin(), V[i].end());
m[V[i]]++;
}
for (auto res : m) {
if (res.second >= 2) {
co += int(res.second * (res.second - 1) / 2);
}
}
cout << co;
}
int main() {
input();
return 0;
} | #include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int n;
long long co = 0;
string V[100005];
map<string, long long> m;
void input() {
cin >> n;
string t;
for (int i = 0; i < n; i++) {
cin >> V[i];
sort(V[i].begin(), V[i].end());
m[V[i]]++;
}
for (auto res : m) {
if (res.second >= 2) {
co += (res.second * (res.second - 1) / 2);
}
}
cout << co;
}
int main() {
input();
return 0;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change",
"variable_declaration.value.change"
] | 749,266 | 749,267 | u588044503 | cpp |
p02947 | #include <algorithm>
#include <iostream>
#include <unordered_map>
using namespace std;
const int MAX_N = 100001;
int N;
string s[MAX_N];
unordered_map<string, int> dic;
void solve() {
int ans = 0;
for (int i = 0; i < N; i++) {
sort(s[i].begin(), s[i].end());
dic[s[i]] += 1;
if (dic[s[i]] >= 2) {
ans += dic[s[i]] - 1;
}
}
cout << ans << endl;
}
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
cin >> s[i];
}
solve();
} | #include <algorithm>
#include <iostream>
#include <unordered_map>
using namespace std;
const int MAX_N = 100001;
int N;
string s[MAX_N];
unordered_map<string, int> dic;
void solve() {
long ans = 0;
for (int i = 0; i < N; i++) {
sort(s[i].begin(), s[i].end());
dic[s[i]] += 1;
if (dic[s[i]] >= 2) {
ans += dic[s[i]] - 1;
}
}
cout << ans << endl;
}
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
cin >> s[i];
}
solve();
} | [
"variable_declaration.type.primitive.change"
] | 749,268 | 749,269 | u036744414 | cpp |
p02947 | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(void) {
int n;
cin >> n;
map<string, int> m;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
sort(begin(s), end(s));
if (m.count(s) != 0)
m[s] += 1;
else
m[s] = 1;
}
long long int ans = 0;
for (auto it = m.begin(); it != m.end(); it++) {
long long int sum = 0;
for (int i = 1; i <= it->second; i++)
sum += i - 1;
ans += sum;
}
printf("%d\n", ans);
return 0;
}
| #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(void) {
int n;
cin >> n;
map<string, int> m;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
sort(begin(s), end(s));
if (m.count(s) != 0)
m[s] += 1;
else
m[s] = 1;
}
long long int ans = 0;
for (auto it = m.begin(); it != m.end(); it++) {
long long int sum = 0;
for (int i = 2; i <= it->second; i++)
sum += i - 1;
ans += sum;
}
printf("%lld\n", ans);
return 0;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 749,270 | 749,271 | u520409849 | cpp |
p02947 | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(void) {
int n;
cin >> n;
map<string, int> m;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
sort(begin(s), end(s));
if (m.count(s) != 0)
m[s] += 1;
else
m[s] = 1;
}
int ans = 0;
for (auto it = m.begin(); it != m.end(); it++) {
int sum = 0;
for (int i = 1; i <= it->second; i++)
sum += i - 1;
ans += sum;
}
printf("%d\n", ans);
return 0;
}
| #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(void) {
int n;
cin >> n;
map<string, int> m;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
sort(begin(s), end(s));
if (m.count(s) != 0)
m[s] += 1;
else
m[s] = 1;
}
long long int ans = 0;
for (auto it = m.begin(); it != m.end(); it++) {
long long int sum = 0;
for (int i = 2; i <= it->second; i++)
sum += i - 1;
ans += sum;
}
printf("%lld\n", ans);
return 0;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 749,272 | 749,271 | u520409849 | cpp |
p02947 | #include <algorithm>
#include <array>
#include <climits>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define pb push_back
#define pii pair<int, int>
vector<string> all;
void func(string s) {
vector<char> x;
int len = s.size();
for (int i = 0; i < len; i++)
x.pb(s[i]);
sort(x.begin(), x.end());
string tmp(x.begin(), x.end());
all.pb(tmp);
}
int main() {
int n;
cin >> n;
string tmp;
for (int i = 0; i < n; i++) {
cin >> tmp;
func(tmp);
}
sort(all.begin(), all.end());
long long ans = 0;
int len = all.size();
int temp = 1;
// cout << len << endl;
for (int i = 1; i < len; i++) {
if (all[i - 1].compare(all[i]) == 0) {
temp++;
// cout << i << ' ' << temp << endl;
} else {
ans += (temp * (temp - 1)) / 2;
// cout << i << ' ' << ans << endl;
temp = 1;
}
}
if (temp != 1) {
ans += (temp * (temp - 1)) / 2;
}
cout << ans;
return 0;
} | #include <algorithm>
#include <array>
#include <climits>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define pb push_back
#define pii pair<int, int>
vector<string> all;
void func(string s) {
vector<char> x;
int len = s.size();
for (int i = 0; i < len; i++)
x.pb(s[i]);
sort(x.begin(), x.end());
string tmp(x.begin(), x.end());
all.pb(tmp);
}
int main() {
int n;
cin >> n;
string tmp;
for (int i = 0; i < n; i++) {
cin >> tmp;
func(tmp);
}
sort(all.begin(), all.end());
long long ans = 0;
int len = all.size();
long long temp = 1;
// cout << len << endl;
for (int i = 1; i < len; i++) {
if (all[i - 1].compare(all[i]) == 0) {
temp++;
// cout << i << ' ' << temp << endl;
} else {
ans = ans + (temp * (temp - 1)) / 2;
// cout << i << ' ' << ans << endl;
temp = 1;
}
}
if (temp != 1) {
ans += (temp * (temp - 1)) / 2;
}
cout << ans;
return 0;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change",
"assignment.value.change",
"assignment.change"
] | 749,279 | 749,280 | u894836225 | cpp |
p02947 | #include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
#define N (1000000000 + 7)
#define INF (ll)1e16
typedef pair<int, int> P;
typedef long long ll;
ll kaijo[100010] = {0};
int main(void) {
string s;
int n;
cin >> n;
map<string, ll> m;
kaijo[0] = 0;
kaijo[1] = 0;
kaijo[2] = 1;
for (int i = 3; i <= 100000; i++)
kaijo[i] = kaijo[i - 1] + i - 1;
for (int i = 0; i < n; i++) {
cin >> s;
sort(s.begin(), s.end());
m[s]++;
}
int ans = 0;
for (auto itr = m.begin(); itr != m.end(); ++itr) {
ans += kaijo[itr->second];
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
#define N (1000000000 + 7)
#define INF (ll)1e16
typedef pair<int, int> P;
typedef long long ll;
ll kaijo[100010] = {0};
int main(void) {
string s;
int n;
cin >> n;
map<string, ll> m;
kaijo[0] = 0;
kaijo[1] = 0;
kaijo[2] = 1;
for (int i = 3; i <= 100000; i++)
kaijo[i] = kaijo[i - 1] + i - 1;
for (int i = 0; i < n; i++) {
cin >> s;
sort(s.begin(), s.end());
m[s]++;
}
ll ans = 0;
for (auto itr = m.begin(); itr != m.end(); ++itr) {
ans += kaijo[itr->second];
}
cout << ans << endl;
return 0;
} | [
"variable_declaration.type.change"
] | 749,281 | 749,282 | u744305661 | cpp |
p02947 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
/* main */
int main() {
ll n, ans = 0;
map<string, int> mp;
cin >> n;
string s;
rep(i, n) {
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
for (auto &p : mp) {
int s = p.second;
ans += s * (s - 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;
/* main */
int main() {
ll n, ans = 0;
map<string, int> mp;
cin >> n;
string s;
rep(i, n) {
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
for (auto &p : mp) {
int s = p.second;
ans += (ll)s * (s - 1) / 2;
}
cout << ans << endl;
} | [
"type_conversion.add"
] | 749,283 | 749,284 | u855016901 | 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 s;
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
long long int ans = 0;
for (auto &p : mp) {
int k = p.second;
ans += (long long int)(k * (k - 1) / 2);
}
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
int N;
cin >> N;
map<string, long long int> mp;
for (int i = 0; i < N; i++) {
string s;
cin >> s;
sort(s.begin(), s.end());
mp[s]++;
}
long long int ans = 0;
for (auto &p : mp) {
long long int k = p.second;
ans += (long long int)(k * (k - 1) / 2);
}
cout << ans << endl;
return 0;
}
| [
"variable_declaration.type.widen.change"
] | 749,287 | 749,288 | u523303964 | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.