Serial print refresh time

are there any other ways to reduce the program size

Yes. Write it in assembly instead of C++.

But seriously, some tips:

  1. Avoid float / double - the floating point library adds loads of bulk.
  2. Don't use variables bigger than you need. The processor is 8-bit. Anything bigger than a BYTE or CHAR uses extra instructions to emulate a larger value.
  3. Think about the flow of your program. Write it tight, and the resultant program will be tight.