Algorithms and Data Structures for OJ