fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int n;
  7. cin>>n;
  8. int h[n],a[n];
  9. for(int i=0;i<n;i++)
  10. {
  11. cin>>h[i]>>a[i];
  12. }
  13. int q=0;
  14. for(int i=0;i<n;i++)
  15. {
  16. for(int j=0;j<n;j++)
  17. {
  18. if(i!=j)
  19. {
  20. if(h[i]==a[j]) q++;
  21. }
  22. }
  23. }
  24. cout<<q;
  25. return 0;
  26. }
Success #stdin #stdout 0s 4564KB
stdin
4
100 42
42 100
5 42
100 5
stdout
5