<doocs>2120.Execution of All Suffix Instructions Staying in a Grid_1.py
def executeInstructions( n: int, startPos: List[int], s: str) -> List[int]:
    ans = []
    m = len(s)
    mp = {"L": [0, -1], "R": [0, 1], "U": [-1, 0], "D": [1, 0]}
    for i in range(m):
        x, y = startPos
        t = 0
        for j in range(i, m):
            a, b = mp[s[j]]
            if 0 <= x + a < n and 0 <= y + b < n:
                x, y, t = x + a, y + b, t + 1
            else:
                break
        ans.append(t)
    return ans
def sample_funcname ( var_0 : int , var_2 : List [ int ] , var_4 : str ) -> List [ int ] :
    var_6 = [ ]
    var_8 = len ( var_4 )
    var_15 = { "L" : [ 0 , - 1 ] , "R" : [ 0 , 1 ] , "U" : [ - 1 , 0 ] , "D" : [ 1 , 0 ] }
    for var_17 in range ( var_8 ) :
        var_18 , var_19 = var_2
        var_20 = 0
        for var_21 in range ( var_17 , var_8 ) :
            var_22 , var_23 = var_15 [ var_4 [ var_21 ] ]
            if 0 <= var_18 + var_22 < var_0 and 0 <= var_19 + var_23 < var_0 :
                var_18 , var_19 , var_20 = var_18 + var_22 , var_19 + var_23 , var_20 + 1
            else :
                break
        var_6.append ( var_20 )
    return var_6
