comefrom: <doocs>1124.Longest Well-Performing Interval_1.py
code: def longestWPI( hours: List[int]) -> int:
      ans = s = 0
      seen = {}
      for i, h in enumerate(hours):
          s += 1 if h > 8 else -1
          if s > 0:
              ans = i + 1
          else:
              if s not in seen:
                  seen[s] = i
              if s - 1 in seen:
                  ans = max(ans, i - seen[s - 1])
      return ans
masked: def sample_funcname ( var_0 : List [ int ] ) -> int :
      var_5 = var_3 = 0
      var_6 = { }
      for var_8 , var_9 in enumerate ( var_0 ) :
          var_3 += 1 if var_9 > 8 else - 1
          if var_3 > 0 :
              var_5 = var_8 + 1
          else :
              if var_3 not in var_6 :
                  var_6 [ var_3 ] = var_8
              if var_3 - 1 in var_6 :
                  var_5 = max ( var_5 , var_8 - var_6 [ var_3 - 1 ] )
      return var_5
  