USACO calfflac. Using <cstdio> instead of <iostream> and <cstring> instead of <string>, the code could be much faster.