Hint: focus on limits (specified in problem statement)
Waste memory when it makes your life easier (if you can get away with it)
Don't delete your extra debugging output, comment it out
Optimize progressively, and only as much as needed
Keep all working versions!
Code to debug:
whitespace is good,
use meaningful variable names,
don't reuse variables,
stepwise refinement,
COMMENT BEFORE CODE.
Avoid pointers if you can
Avoid dynamic memory like the plague: statically allocate everything.
Try not to use floating point; if you have to, put tolerances in everywhere (never test equality)
Comments on comments:
Not long prose, just brief notes
Explain high-level functionality: ++i; /* increase the value of i by */ is worse than useless
Explain code trickery
Delimit & document functional sections
As if to someone intelligent who knows the problem, but not the code
Anything you had to think about
Anything you looked at even once saying, "now what does that do again?"
Always comment order of array indices
Keep a log of your performance in each contest: successes, mistakes, and what you could have done better; use this to rewrite and improve your game plan!