title: Count Subarrays Equal Number 1S 0S
signature: def countSubarraysEqualNumber1S0S(arr: List[Int], n: Int) = {
source_py: def count_subarrays_equal_number_1s_0s(arr, n):
      um = dict()
      curr_sum = 0
      for i in range(n):
          curr_sum += ((- 1) if (arr[i] == 0) else arr[i])
          if um.get(curr_sum):
              um[curr_sum] += 1
          else:
              um[curr_sum] = 1
      count = 0
      for itr in um:
          if (um[itr] > 1):
              count += ((um[itr] * int((um[itr] - 1))) / 2)
      if um.get(0):
          count += um[0]
      return int(count)
source_cpp: int count_subarrays_equal_number_1s_0s(vector<int> arr, int n) {
    unordered_map < int, int > um;
    int curr_sum = 0;
    for ( int i = 0;
    i < n;
    i ++ ) {
      curr_sum += ( arr [ i ] == 0 ) ? - 1 : arr [ i ];
      um [ curr_sum ] ++;
    }
    int count = 0;
    for ( auto itr = um . begin ( );
    itr != um . end ( );
    itr ++ ) {
      if ( itr -> second > 1 ) count += ( ( itr -> second * ( itr -> second - 1 ) ) / 2 );
    }
    if ( um . find ( 0 ) != um . end ( ) ) count += um [ 0 ];
    return count;
  }