title: Count Pairs Whose Products Exist In Array 1
signature: def count_pairs_whose_products_exist_in_array_1(arr, n):
source_py: def count_pairs_whose_products_exist_in_array_1(arr, n):
      result = 0
      Hash = set()
      for i in range(n):
          Hash.add(arr[i])
      for i in range(n):
          for j in range((i + 1), n):
              product = (arr[i] * arr[j])
              if (product in Hash):
                  result += 1
      return result
source_cpp: int count_pairs_whose_products_exist_in_array_1(vector<int> arr, int n) {
    int result = 0;
    set < int > Hash;
    for ( int i = 0;
    i < n;
    i ++ ) Hash . insert ( arr [ i ] );
    for ( int i = 0;
    i < n;
    i ++ ) {
      for ( int j = i + 1;
      j < n;
      j ++ ) {
        int product = arr [ i ] * arr [ j ];
        if ( Hash . find ( product ) != Hash . end ( ) ) result ++;
      }
    }
    return result;
  }
question_info.test_code: import array
  import bisect
  import collections
  import datetime
  import functools
  import heapq
  import itertools
  import math
  import queue
  import re
  import string
  import sys
  from typing import Any, Dict, List, Optional, Set
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  def validate_solution(actual, expected):
      return actual == expected
  
  def driver(arr, n, expected):
      try:
          if validate_solution(PLACEHOLDER_FN_NAME(
              arr, n),
              expected
          ):
              return "PASSED"
          return "FAILED"
      except Exception as exception_obj:
          return type(exception_obj).__name__
      
  if __name__ == "__main__":
      result = driver([7, 10, 17, 17, 18, 20, 27, 28, 29, 29, 31, 32, 41, 43, 45, 46, 63, 66, 69, 69, 70, 75, 87, 95], 17, 0)
      print(f"TEST-0...{result}")
  
      result = driver([-60], 0, 0)
      print(f"TEST-1...{result}")
  
      result = driver([0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 9, 36)
      print(f"TEST-2...{result}")
  
      result = driver([52, 83, 36, 57, 93, 11, 32, 91, 52], 8, 0)
      print(f"TEST-3...{result}")
  
      result = driver([-98, -94, -90, -88, -76, -76, -64, -62, -60, -50, -46, -32, -24, -22, -20, -16, -4, -2, 6, 10, 20, 28, 30, 32, 34, 38, 40, 42, 54, 64, 72, 76, 82, 82, 86, 92, 92, 98, 98], 22, 2)
      print(f"TEST-4...{result}")
  
      result = driver([0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0], 42, 861)
      print(f"TEST-5...{result}")
  
      result = driver([2, 3, 10, 12, 15, 23, 26, 28, 29, 30, 31, 31, 33, 33, 35, 41, 45, 48, 50, 50, 53, 53, 56, 65, 66, 67, 68, 68, 72, 72, 75, 76, 79, 82, 90, 94, 94, 95, 97, 99], 35, 9)
      print(f"TEST-6...{result}")
  
      result = driver([14, 36, -54, -54], 3, 0)
      print(f"TEST-7...{result}")
  
      result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], 12, 66)
      print(f"TEST-8...{result}")
  
      result = driver([5, 69, 37, 80, 21, 98, 70, 70, 74, 95, 6, 67, 44, 55, 52, 89, 84, 99, 65, 52], 12, 0)
      print(f"TEST-9...{result}")
  
      sys.exit(0)
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
question_info.entry_fn_name: count_pairs_whose_products_exist_in_array_1
question_info.test_list: [{"idx": 0, "outputs": 0, "inputs": {"arr": [7, 10, 17, 17, 18, 20, 27, 28, 29, 29, 31, 32, 41, 43, 45, 46, 63, 66, 69, 69, 70, 75, 87, 95], "n": 17}}, {"idx": 1, "outputs": 0, "inputs": {"arr": [-60], "n": 0}}, {"idx": 2, "outputs": 36, "inputs": {"arr": [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 9}}, {"idx": 3, "outputs": 0, "inputs": {"arr": [52, 83, 36, 57, 93, 11, 32, 91, 52], "n": 8}}, {"idx": 4, "outputs": 2, "inputs": {"arr": [-98, -94, -90, -88, -76, -76, -64, -62, -60, -50, -46, -32, -24, -22, -20, -16, -4, -2, 6, 10, 20, 28, 30, 32, 34, 38, 40, 42, 54, 64, 72, 76, 82, 82, 86, 92, 92, 98, 98], "n": 22}}, {"idx": 5, "outputs": 861, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0], "n": 42}}, {"idx": 6, "outputs": 9, "inputs": {"arr": [2, 3, 10, 12, 15, 23, 26, 28, 29, 30, 31, 31, 33, 33, 35, 41, 45, 48, 50, 50, 53, 53, 56, 65, 66, 67, 68, 68, 72, 72, 75, 76, 79, 82, 90, 94, 94, 95, 97, 99], "n": 35}}, {"idx": 7, "outputs": 0, "inputs": {"arr": [14, 36, -54, -54], "n": 3}}, {"idx": 8, "outputs": 66, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], "n": 12}}, {"idx": 9, "outputs": 0, "inputs": {"arr": [5, 69, 37, 80, 21, 98, 70, 70, 74, 95, 6, 67, 44, 55, 52, 89, 84, 99, 65, 52], "n": 12}}]
question_info.entry_cls_name: Solution