Update max_match.c

tested for multiple cases, fixed some +1/-1 errors