  We address the maximum size of binary codes and binary constant weight codes
with few distances. Previous works established a number of bounds for these
quantities as well as the exact values for a range of small code lengths. As
our main results, we determine the exact size of maximal binary codes with two
distances for all lengths $n\ge 6$ as well as the exact size of maximal binary
constant weight codes with 2,3, and 4 distances for several values of the
weight and for all but small lengths.
