comefrom: <doocs>0874.Walking Robot Simulation_1.py
code: def robotSim( commands: List[int], obstacles: List[List[int]]) -> int:
      dirs = [[-1, 0], [0, 1], [1, 0], [0, -1]]
      s = {(x, y) for x, y in obstacles}
      ans, p = 0, 1
      x = y = 0
      for v in commands:
          if v == -2:
              p = (p + 3) % 4
          elif v == -1:
              p = (p + 1) % 4
          else:
              for _ in range(v):
                  nx, ny = x + dirs[p][0], y + dirs[p][1]
                  if (nx, ny) in s:
                      break
                  x, y = nx, ny
                  ans = max(ans, x * x + y * y)
      return ans
masked: def sample_funcname ( var_0 : List [ int ] , var_3 : List [ List [ int ] ] ) -> int :
      var_6 = [ [ - 1 , 0 ] , [ 0 , 1 ] , [ 1 , 0 ] , [ 0 , - 1 ] ]
      var_9 = { ( var_7 , var_8 ) for var_7 , var_8 in var_3 }
      var_10 , var_11 = 0 , 1
      var_7 = var_8 = 0
      for var_12 in var_0 :
          if var_12 == - 2 :
              var_11 = ( var_11 + 3 ) % 4
          elif var_12 == - 1 :
              var_11 = ( var_11 + 1 ) % 4
          else :
              for var_17 in range ( var_12 ) :
                  var_18 , var_19 = var_7 + var_6 [ var_11 ] [ 0 ] , var_8 + var_6 [ var_11 ] [ 1 ]
                  if ( var_18 , var_19 ) in var_9 :
                      break
                  var_7 , var_8 = var_18 , var_19
                  var_10 = max ( var_10 , var_7 * var_7 + var_8 * var_8 )
      return var_10
  