def insort_right(a, x, lo=<NUM_LIT:0>, hi=None):
if lo < <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if hi is None:<EOL><INDENT>hi = len(a)<EOL><DEDENT>while lo < hi:<EOL><INDENT>mid = (lo+hi)//<NUM_LIT:2><EOL>if x < a[mid]: hi = mid<EOL>else: lo = mid+<NUM_LIT:1><EOL><DEDENT>a.insert(lo, x)<EOL>
Insert item x in list a, and keep it sorted assuming a is sorted.

    If x is already in a, insert it to the right of the rightmost x.

    Optional args lo (default 0) and hi (default len(a)) bound the
    slice of a to be searched.