There are a few reasons why your code may compile on your computer but not on Codechef. In all cases, you can see the compile error by clicking on the Compile Error icon after submitting your code.
Java:
Your class containing the main method must be a public class called Main. It may not be called anything else. Do not use packages.
C/C++:
Make sure you are using a compiler that complies with the standards. Turbo C++ is not such a compiler, and often code which compiles in Turbo C++ will not compile on CodeChef.
Make sure you are using standard headers. Do not use conio.h in C; this is not part of the C standard library. Do not use iostream.h; this is a deprecated header file and again is not a standard library. (You should just be using iostream instead).
The flags used for C++ are: g++ -pipe -O2 -lm -s -fomit-frame-pointer
Other languages:
As with C/C++, make sure you are using a standard compiler/interpreter. The exact ones that Codechef uses are listed next to the language when submitting the program.
Read the sample solutions page to see an example of code which compiles and correctly solves the TEST program as a starting point.
Read the sample solutions page to see an example of code which compiles and correctly solves the TEST program as a starting point.