title: Count Index Pairs Equal Elements Array
signature: int countIndexPairsEqualElementsArray(vector<int> arr, int n) {
test_code: #include <algorithm>
  #include <assert.h>
  #include <cstdlib>
  #include <iostream>
  #include <map>
  #include <set>
  #include <string>
  #include <tuple> 
  #include <unordered_map>
  #include <vector>
  #include <math.h>
  #include <cmath>
  #include <bits/stdc++.h>
  #include <numeric>
  #include <functional>
  
  using namespace std;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual == expected;
  }
  
  string driver(vector<int> arr, int n, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(arr, n), expected)){
              return "PASSED";
          }
          return "FAILED";
      }
      catch (const std::overflow_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::runtime_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::exception& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (...)
      {
          return "UNK_ERROR";
      }
  }
  
  int main() {
      string result = "";
  
      result = driver({4, 6, 9, 16, 16, 21, 36, 41, 58, 60, 62, 73, 77, 81, 95}, 12, 1); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      result = driver({-86, -72, -26, -34, 18, -62, -66}, 3, 0); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver({1}, 0, 0); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      result = driver({16}, 0, 0); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver({-88, -80, -72, -68, -64, -26, 4, 14, 16, 22, 30, 32, 60, 74, 82}, 11, 0); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      result = driver({0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1}, 9, 16); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver({3, 9, 10, 12, 17, 23, 27, 29, 42, 44, 59, 61, 71, 76, 78, 82, 84, 84, 89, 90, 93, 93, 97, 97}, 15, 0); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      result = driver({68, -40, -46, -20, -64, 90}, 5, 0); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 15, 61); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      result = driver({99, 17, 94, 43, 97, 17, 11, 58, 75, 94, 37, 22, 54, 31, 41, 4, 55, 69, 92, 80, 45, 97, 16, 33, 36, 17, 43, 82, 81, 64, 22, 65, 85, 44, 47, 14}, 23, 3); 
      cout << "TEST-" << 9 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
source_py: def count_index_pairs_equal_elements_array(arr, n):
      ans = 0
      for i in range(0, n):
          for j in range((i + 1), n):
              if (arr[i] == arr[j]):
                  ans += 1
      return ans
source_cpp: int count_index_pairs_equal_elements_array(vector<int> arr, int n) {
    int ans = 0;
    for ( int i = 0;
    i < n;
    i ++ ) for ( int j = i + 1;
    j < n;
    j ++ ) if ( arr [ i ] == arr [ j ] ) ans ++;
    return ans;
  }