function for calculating the required sum between two indexes
def sum ( x : int ) -> int : NEW_LINE INDENT s = 0 NEW_LINE a = x NEW_LINE while a : NEW_LINE INDENT s += BIT [ a ] NEW_LINE a -= a & - a NEW_LINE DEDENT return s NEW_LINE DEDENT