Subtract the A [ i - M ] and add the A [ i ] in the map
if A [ i - M ] in m : NEW_LINE INDENT m [ A [ i - M ] ] -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT m [ A [ i - M ] ] = 0 NEW_LINE DEDENT if A [ i ] in m : NEW_LINE INDENT m [ A [ i ] ] += 1 NEW_LINE DEDENT val = 0 NEW_LINE