problem link:NEAR Problem - CodeChef
solution link: CodeChef: Practical coding for everyone
First and foremost you need to modify the array declarations.
p[1003], ca[1003][5], cu[1003][5];