comefrom: <doocs>0798.Smallest Rotation with Highest Score_1.py
code: def bestRotation( nums: List[int]) -> int:
      n = len(nums)
      mx, ans = -1, n
      d = [0] * n
      for i, v in enumerate(nums):
          l, r = (i + 1) % n, (n + i + 1 - v) % n
          d[l] += 1
          d[r] -= 1
      s = 0
      for k, t in enumerate(d):
          s += t
          if s > mx:
              mx = s
              ans = k
      return ans
masked: def sample_funcname ( var_0 : List [ int ] ) -> int :
      var_4 = len ( var_0 )
      var_6 , var_7 = - 1 , var_4
      var_9 = [ 0 ] * var_4
      for var_11 , var_12 in enumerate ( var_0 ) :
          var_13 , var_14 = ( var_11 + 1 ) % var_4 , ( var_4 + var_11 + 1 - var_12 ) % var_4
          var_9 [ var_13 ] += 1
          var_9 [ var_14 ] -= 1
      var_15 = 0
      for var_16 , var_17 in enumerate ( var_9 ) :
          var_15 += var_17
          if var_15 > var_6 :
              var_6 = var_15
              var_7 = var_16
      return var_7
  