title: Count Index Pairs Equal Elements Array
signature: count_index_pairs_equal_elements_array <- function(arr, n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(arr, n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(arr, n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(4L, 6L, 9L, 16L, 16L, 21L, 36L, 41L, 58L, 60L, 62L, 73L, 77L, 81L, 95L), 12L, 
          1L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(-86L, -72L, -26L, -34L, 18L, -62L, -66L), 3L, 
          0L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(1L), 0L, 
          0L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(16L), 0L, 
          0L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-88L, -80L, -72L, -68L, -64L, -26L, 4L, 14L, 16L, 22L, 30L, 32L, 60L, 74L, 82L), 11L, 
          0L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(0L, 0L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 0L, 1L), 9L, 
          16L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(3L, 9L, 10L, 12L, 17L, 23L, 27L, 29L, 42L, 44L, 59L, 61L, 71L, 76L, 78L, 82L, 84L, 84L, 89L, 90L, 93L, 93L, 97L, 97L), 15L, 
          0L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(68L, -40L, -46L, -20L, -64L, 90L), 5L, 
          0L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 15L, 
          61L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(99L, 17L, 94L, 43L, 97L, 17L, 11L, 58L, 75L, 94L, 37L, 22L, 54L, 31L, 41L, 4L, 55L, 69L, 92L, 80L, 45L, 97L, 16L, 33L, 36L, 17L, 43L, 82L, 81L, 64L, 22L, 65L, 85L, 44L, 47L, 14L), 23L, 
          3L
      )))
  
  }
  
  main()
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;
  }