comefrom: <gouthampradhan>heap_Candy_1.java
code: public int candy(int[] ratings) {
      if (ratings.length == 1) return 1;
      PriorityQueue<Integer> pq =
          new PriorityQueue<>((o1, o2) -> Integer.compare(ratings[o1], ratings[o2]));
      for (int i = 0; i < ratings.length; i++) {
        pq.offer(i);
      }
      int[] count = new int[ratings.length];
      while (!pq.isEmpty()) {
        int index = pq.poll();
        if (index - 1 < 0) {
          if (ratings[index + 1] == ratings[index]) {
            count[index] = 1;
          } else {
            count[index] = count[index + 1] + 1;
          }
        } else if (index + 1 >= ratings.length) {
          if (ratings[index - 1] == ratings[index]) {
            count[index] = 1;
          } else {
            count[index] = count[index - 1] + 1;
          }
        } else {
          if ((ratings[index - 1] == ratings[index]) && (ratings[index + 1] == ratings[index])) {
            count[index] = 1;
          } else {
            if (((ratings[index - 1] == ratings[index]) && (ratings[index + 1] > ratings[index]))
                || ((ratings[index + 1] == ratings[index])
                    && (ratings[index - 1] > ratings[index]))) {
              count[index] = 1;
            } else if (((ratings[index - 1] == ratings[index])
                && (ratings[index + 1] < ratings[index]))) {
              count[index] = count[index + 1] + 1;
            } else if (((ratings[index + 1] == ratings[index])
                && (ratings[index - 1] < ratings[index]))) {
              count[index] = count[index - 1] + 1;
            } else {
              if (count[index - 1] > count[index + 1]) {
                count[index] = count[index - 1] + 1;
              } else {
                count[index] = count[index + 1] + 1;
              }
            }
          }
        }
      }
      int result = 0;
      for (int c : count) {
        result += c;
      }
      return result;
    }
masked: public int sample_funcname ( int [ ] var_0 ) {
    if ( var_0 . length == 1 ) return 1 ;
    PriorityQueue < Integer > var_8 = new PriorityQueue < > ( ( var_5 , var_6 ) -> Integer . compare ( var_0 [ var_5 ] , var_0 [ var_6 ] ) ) ;
    for ( int var_10 = 0 ;
    var_10 < var_0 . length ;
    var_10 ++ ) {
      var_8 . offer ( var_10 ) ;
    }
    int [ ] var_12 = new int [ var_0 . length ] ;
    while ( ! var_8 . isEmpty ( ) ) {
      int var_15 = var_8 . poll ( ) ;
      if ( var_15 - 1 < 0 ) {
        if ( var_0 [ var_15 + 1 ] == var_0 [ var_15 ] ) {
          var_12 [ var_15 ] = 1 ;
        }
        else {
          var_12 [ var_15 ] = var_12 [ var_15 + 1 ] + 1 ;
        }
      }
      else if ( var_15 + 1 >= var_0 . length ) {
        if ( var_0 [ var_15 - 1 ] == var_0 [ var_15 ] ) {
          var_12 [ var_15 ] = 1 ;
        }
        else {
          var_12 [ var_15 ] = var_12 [ var_15 - 1 ] + 1 ;
        }
      }
      else {
        if ( ( var_0 [ var_15 - 1 ] == var_0 [ var_15 ] ) && ( var_0 [ var_15 + 1 ] == var_0 [ var_15 ] ) ) {
          var_12 [ var_15 ] = 1 ;
        }
        else {
          if ( ( ( var_0 [ var_15 - 1 ] == var_0 [ var_15 ] ) && ( var_0 [ var_15 + 1 ] > var_0 [ var_15 ] ) ) || ( ( var_0 [ var_15 + 1 ] == var_0 [ var_15 ] ) && ( var_0 [ var_15 - 1 ] > var_0 [ var_15 ] ) ) ) {
            var_12 [ var_15 ] = 1 ;
          }
          else if ( ( ( var_0 [ var_15 - 1 ] == var_0 [ var_15 ] ) && ( var_0 [ var_15 + 1 ] < var_0 [ var_15 ] ) ) ) {
            var_12 [ var_15 ] = var_12 [ var_15 + 1 ] + 1 ;
          }
          else if ( ( ( var_0 [ var_15 + 1 ] == var_0 [ var_15 ] ) && ( var_0 [ var_15 - 1 ] < var_0 [ var_15 ] ) ) ) {
            var_12 [ var_15 ] = var_12 [ var_15 - 1 ] + 1 ;
          }
          else {
            if ( var_12 [ var_15 - 1 ] > var_12 [ var_15 + 1 ] ) {
              var_12 [ var_15 ] = var_12 [ var_15 - 1 ] + 1 ;
            }
            else {
              var_12 [ var_15 ] = var_12 [ var_15 + 1 ] + 1 ;
            }
          }
        }
      }
    }
    int var_16 = 0 ;
    for ( int var_17 : var_12 ) {
      var_16 += var_17 ;
    }
    return var_16 ;
  }
  