title: Array Range Queries Elements Frequency Value
signature: array_range_queries_elements_frequency_value <- function(start, end_arg1, arr) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(start, end_arg1, arr, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(start, end_arg1, arr), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          0L, 31L, list(1L, 2L, 2L, 3L, 3L, 3L, 12L, 13L, 18L, 18L, 26L, 28L, 29L, 36L, 37L, 39L, 40L, 49L, 55L, 57L, 63L, 69L, 69L, 73L, 85L, 86L, 87L, 87L, 89L, 89L, 90L, 91L, 92L, 93L, 93L, 93L, 95L, 99L), 
          3L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          1L, 25L, list(24L, -62L, 2L, 1L, 94L, 56L, -22L, -70L, -22L, -34L, -92L, -18L, 56L, 2L, 60L, 38L, -88L, 16L, -28L, 30L, -30L, 58L, -80L, 94L, 6L, 56L), 
          2L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          3L, 4L, list(0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 
          1L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          10L, 15L, list(84L, 13L, 81L, 40L, 87L, 82L, 50L, 30L, 90L, 80L, 81L, 70L, 14L, 54L, 72L, 93L, 78L, 27L, 61L), 
          0L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          2L, 3L, list(-20L, 20L, 34L, 60L, 90L), 
          0L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          0L, 6L, list(1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), 
          1L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          14L, 18L, list(11L, 18L, 18L, 19L, 25L, 30L, 42L, 42L, 56L, 58L, 63L, 66L, 67L, 68L, 69L, 75L, 78L, 83L, 83L), 
          0L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          29L, 33L, list(-24L, -82L, 24L, -84L, 94L, 2L, -30L, 86L, 58L, -56L, -96L, 60L, -38L, 76L, 94L, 74L, -98L, -84L, -38L, 46L, 4L, -84L, -90L, -28L, -50L, 46L, 16L, 28L, -14L, -82L, -64L, 42L, 64L, -2L, -40L, 96L, 60L, 2L, -86L, 32L, 38L, -66L), 
          0L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          31L, 19L, list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 
          0L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          21L, 32L, list(2L, 91L, 42L, 85L, 97L, 92L, 24L, 39L, 63L, 89L, 31L, 59L, 51L, 89L, 72L, 62L, 26L, 92L, 75L, 4L, 6L, 13L, 20L, 95L, 22L, 30L, 52L, 60L, 37L, 27L, 49L, 15L, 67L, 26L), 
          0L
      )))
  
  }
  
  main()
source_py: def array_range_queries_elements_frequency_value(start, end, arr):
      frequency = dict()
      for i in range(start, (end + 1)):
          if (arr[i] in frequency.keys()):
              frequency[arr[i]] += 1
          else:
              frequency[arr[i]] = 1
      count = 0
      for x in frequency:
          if (x == frequency[x]):
              count += 1
      return count
source_cpp: int array_range_queries_elements_frequency_value(int start, int end, vector<int> arr) {
    unordered_map < int, int > frequency;
    for ( int i = start;
    i <= end;
    i ++ ) frequency [ arr [ i ] ] ++;
    int count = 0;
    for ( auto x : frequency ) if ( x . first == x . second ) count ++;
    return count;
  }