fork download
  1. #include <bits/stdc++.h>
  2. #define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
  3. #define fi first
  4. #define se second
  5. #define el "\n"
  6. #define pb push_back
  7. #define sz(a) (int)a.size()
  8. #define FILL(a, x) memset(a, x, sizeof(a))
  9.  
  10. using namespace std;
  11. typedef long long ll;
  12. typedef pair<string, string> ii;
  13. const int N = (int)1e6+3;
  14. ii a[60];
  15. int n;
  16. ll ans;
  17.  
  18. int main()
  19. {
  20. ios_base::sync_with_stdio(false);
  21. cin.tie(NULL); cout.tie(NULL);
  22. freopen("bff.inp", "r", stdin);
  23. freopen("bff.out", "w", stdout);
  24. cin >> n;
  25. FOR(i, 1, n) cin >> a[i].fi >> a[i].se;
  26. FOR(i, 1, n)
  27. FOR(j, 1, n)
  28. if (i != j && a[i].fi == a[j].se) ++ans;
  29. cout << ans;
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0.01s 5336KB
stdin
Standard input is empty
stdout
Standard output is empty