title: Count Index Pairs Equal Elements Array
signature: class Solution {
  
      public int CountIndexPairsEqualElementsArray(List<int> arr, int n) {
test_code: using System;
  using System.Numerics;
  using System.Diagnostics;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Security.Cryptography;
  using System.Web.UI;
  using System.Web.Script.Serialization;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  namespace EvaluatePrediction {
      class TestRunner {
          public bool ValidateSolution(int actual, int expected){
              return new JavaScriptSerializer().Serialize(actual) == new JavaScriptSerializer().Serialize(expected);
          }
  
          public string driver(List<int> arr, int n, int expected){
              try{
                PLACEHOLDER_CLS_NAME solution_cls = new PLACEHOLDER_CLS_NAME();
                int pred_result = solution_cls.PLACEHOLDER_FN_NAME(arr, n); 
                if (ValidateSolution(
                      pred_result,
                      expected)){
                  return "PASSED";
                }
                return "FAILED";
              } 
              catch (Exception exception_obj)
              {
                return exception_obj.GetType().FullName;
              }
          }
          static void Main(string[] args) {
              TestRunner runner = new TestRunner();
              String result;
              result = runner.driver(
                  new List<int>{4, 6, 9, 16, 16, 21, 36, 41, 58, 60, 62, 73, 77, 81, 95}, 12, 
                  1
              );
              Console.WriteLine(string.Format(
                  "TEST-0...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{-86, -72, -26, -34, 18, -62, -66}, 3, 
                  0
              );
              Console.WriteLine(string.Format(
                  "TEST-1...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{1}, 0, 
                  0
              );
              Console.WriteLine(string.Format(
                  "TEST-2...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{16}, 0, 
                  0
              );
              Console.WriteLine(string.Format(
                  "TEST-3...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{-88, -80, -72, -68, -64, -26, 4, 14, 16, 22, 30, 32, 60, 74, 82}, 11, 
                  0
              );
              Console.WriteLine(string.Format(
                  "TEST-4...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1}, 9, 
                  16
              );
              Console.WriteLine(string.Format(
                  "TEST-5...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{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
              );
              Console.WriteLine(string.Format(
                  "TEST-6...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{68, -40, -46, -20, -64, 90}, 5, 
                  0
              );
              Console.WriteLine(string.Format(
                  "TEST-7...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{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
              );
              Console.WriteLine(string.Format(
                  "TEST-8...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{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
              );
              Console.WriteLine(string.Format(
                  "TEST-9...{0}",
                  result)
              );
          }
      }
  }
  
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;
  }