Upload testcases and optimize the code