Judge Environment


Language Compilers

Language Version Flags/Notes Max Memory Limit
Bash gnu bash v5.0.17 Time Limit: 0.5X 256 MB
C gcc 10.3 Time Limit: X
Flags: -std=gnu99 -w -O2 -fomit-frame-pointer -lm
256 MB
C++ 14 g++ 10.3 Time Limit: X
Flags: -std=c++14 -w -O2 -fomit-frame-pointer -lm
256 MB
C++ 17 g++ 10.3 Time Limit: X
Flags: -std=c++17 -w -O2 -fomit-frame-pointer -lm
256 MB
C# mcs 6.12 Time Limit: 2X
Flags: -unsafe+ -warn:0
256 MB
Clojure clojure 1.10.1 Time Limit: 4X 256 MB
D dmd 2.097.0 Time Limit: 1.5X 256 MB
Erlang erts 12.0.2 Time Limit: 6X 256 MB
F# fsharp 5.0 Time Limit: 2X 256 MB
Go go 1.16.6 Time Limit: 2X 256 MB
Groovy groovy 2.4.21 Time Limit: 2.5X 256 MB
Haskell ghc 9.0.1 Time Limit: 3X 256 MB
Java 8 openjdk 1.8.0_241 Time Limit: 2X 256 MB
Java 17 openjdk 17 Time Limit: 2X 256 MB
JavaScript (Node.js) Node.js v18.15 Time Limit: 5X 256 MB
Julia julia 1.6.2 Time Limit: 5X 256 MB
Kotlin kotlinc 1.5.21 Time Limit: 2X 256 MB
Lisp (SBCL) sbcl 2.1.6 Time Limit: 6X 256 MB
Lua lua 5.4.3 Time Limit: 6X 256 MB
Objective-C clang 12.0.1 Time Limit: X
Flags: -std=gnu99 -w -O2 -fomit-frame-pointer -Wno-import -lobjc -lm
256 MB
OCaml ocaml 4.12.0 Time Limit: 1.5X 256 MB
Octave gnu octave 5.2 Time Limit: 2.5X 256 MB
Pascal fpc 3.2.2 Time Limit: X 256 MB
Perl perl 5.30.0 Time Limit: 5X 256 MB
PHP php 7.4.3 Time Limit: 5X 256 MB
Python python 2.7.18 Time Limit: 5X 256 MB
Python 3 python 3.10 Time Limit: 5X 256 MB
Python 3.8 python 3.8.10 Time Limit: 5X 256 MB
R (Rscript) R 4.1.0 Time Limit: 1.5X 256 MB
Racket racket 8.1 Time Limit: 5X 256 MB
Ruby ruby 3.0.1 Time Limit: 5X 256 MB
Rust rustic 1.68.0 Time Limit: 2.5X
Flags: -O
256 MB
Scala scalac 2.12.14 Time Limit: 3.5X 256 MB
Swift swift 5.4.2 (Note: We run and evaluate in Linux environment) Time Limit: X 256 MB
TypeScript (Node) typescript v4.9.5 Time Limit: 5X 256 MB
Visual Basic mono 6.12, vbnc 0.0.0.5943 Time Limit: 2.5X 256 MB
  • X - Time Limit mentioned in the problem statement.

Legends

Legend Explanation Icons
NZEC Non Zero Exit Code
SIGSEGV Segmentation Fault
SIGFPE Floating Point Error
SIGABRT Fatal Error
SIGXFSZ Output is too large
TLE Time Limit Exceeded

MLE Memory Limit Exceeded

RE Runtime Error
CE Compilation Error

How does online judge determines whether the solution is correct?

Your code is tested by a code-checker automatically, not by a human being, and you have to write your code accordingly. For each problem, there will be one or more input files, each according to the specifications mentioned in the problem statement, and corresponding correct output files. Your program is run on each of those input files. The output generated by your program must match the correct output exactly in order to be judged correct.

If your program starts by printing 'Enter the number' and the problem does not tell you to do so, then since this is not part of the correct output, you will be never be judged correct regardless of what the rest of your program does. As all that matters is that the output files match, it makes no difference at all at what point in your program's execution that this output is written.

So there is no need to read all of the input before starting output; it is much more common to just print out each result as you are reading through the input. If you use any method other than using the standard input and output streams - for example, using command line arguments, reading from a file, opening up some sort of dialog box, or otherwise - you will never be judged correct.

How do I test my program on local machine?

Testing your program in exactly the same way that online judge does. Create an input file and then run your program from the command line, using < and > to redirect the streams. For example:
./a.out < input > output
Your program will read input from the input file and print output in the output file. You can check if the output format is correct in the output file. It should exactly match the output format give in the problem statment.

How does the time limit work?

Your program must read, process, and output the result for all input files within the specified time limit. The input file will be of the format mentioned in the problem.
This means, if each of the input file contains multiple test cases, your code must complete all of these within that time limit. If the time limit is 1 second, and there may be 100 test cases and multiple input files, your program shouldn't be taking 1 second per test case - it needs to run all 100 in under 1 seconds. Some programming languages are slower than others, and are thus given more time. Also all the input files are processed, irrespective of whether the first input file passed or not.

How does the total execution time work?

Your code is tested multiple times with different input files. The execution time displayed is the total of the time spent for each input file. But your program is terminated if it exceeds the time limit mentioned in the problem while processing any input file. Hence, Total execution time <= (Time Limit * Number of input files)

How does the total memory consumed work?

Total memory consumed by the program is sum of the memory consumed by program in stack, data, heap, and bss. See this image or this explanation to understand the address space of a program and the memory consumed.

Note that for languages like Java, Scala, JavaScript, etc. where runtime environment is initialized before the program could be executed, the total memory displayed could be much higher. Hence the memory limit is usually not considered for these languages, except in extreme cases where the program is consuming too much of memory.

Why my program doesn't compile?

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 the online judge. For the starter, remove conio.h includes in your code.
Java
We support multiple classes and inner static classes. Your code may throw errors if inner classes are not static. Please note that we will remove this constraint very soon. We will update you when this happens.

In case of other languages, see the compilation error you receive. This should give you ample idea of what might be the reason. If you still think compilation error is weird, contact me.

TLE means my code is correct but slow, right?

No, Time Limit Exceeded or TLE means that your solution exceeded the amount of time which was determined for the problem or for that particular test case. Your solution never finished running in time, it was stopped in between. So, there is definite way to say if the code was correct or not.

At times, this means that your code contains an infinite loop, and your program will never stop executing. In other cases, it may mean that your program will terminate, but not within the time limit indicated.

For example, if the time limit of a code is 2 seconds, and your code terminates on 2.001 seconds, it does NOT mean that it exceeded the limit by 0.001 seconds, it simply means that the judge stopped evaluating your code after 2 seconds.

Why do I get Time Limit Exceeded (TLE)?

The most common reason that you would get a Time Limit Exceeded is because your program is too slow. If a problem tells you that N <= 999999, and your program has nested loops each which go up to N, your program will never be fast enough. Read the bounds in the input carefully before writing your program, and try to figure out which inputs will cause your program to run the slowest.

The second most common cause of TLE is that your method of reading input and writing output is too slow. In Java, do not use a Scanner; use a BufferedReader instead. In C++, do not use cin/cout - use scanf and printf instead. In C++, you can also avoid using STL, which can be a little slow sometimes.

Also note that our judge might be slower than your machine, but the time limit is always achievable. It is common for a program to take 2-3 times as long on the judge as it does on your computer. You need to come up with faster algorithms to achieve the execution with time limit.

Also in case of TLE, it is not guaranteed that whether the solution was correct or not. There is also no way of knowing how many more seconds it could have taken to finish.

TLE IN JAVA
If you keep receiving time limit in Java, the first thing to check is if your solution is using optimized methods of input and output. As test cases can be large in some of the problems, using Scanner and System.out might result in "Time Limit Exceeded", even though there exists a time limit multiplier (x2) times for JAVA, i.e., JAVA is assigned twice the normal time limit of the question.

What is wrong answer?

Your program ran successfully, but gave an incorrect answer. Most probably your program contains a bug, or you are not interpreting the problem text correctly. If your code shows that it has passed the sample input correctly, then remember that there are multiple input and output cases for which your code is supposed to be evaluated, which is why in spite of passing the sample input cases, you\u2019re still getting a wrong answer.

I keep getting various types of runtime errors, I\u2019m sick of them. What am I missing?

A runtime error means that the program was compiled successfully, but it exited with a runtime error or crashed. You will receive an additional error message, which is most commonly one of the following:

SIGSEGV
This is the most common error, i.e., a "segmentation fault". This may be caused e.g. by an out-of-scope array index causing a buffer overflow, an incorrectly initialized pointer, etc. This signal is generated when a program tries to read or write outside the memory that is allocated for it, or to write memory that can only be read. For example, you\u2019re accessing a[-1] in a language which does not support negative indices for an array.

SIGXFSZ
"output limit exceeded". Your program has printed too much data to output.

SIGFPE
"floating point error". This usually occurs when you\u2019re trying to divide a number by 0, or trying to take the square root of a negative number.

SIGABRT
These are raised by the program itself. This happens when the judge aborts your program in the middle of execution. Due to insufficient memory, this can be raised.

NZEC
(non-zero exit code) - this message means that the program exited returning a value different from 0 to the shell. For languages such as C/C++, this probably means you forgot to add "return 0" at the end of the program. It could happen if your program threw an exception which was not caught. Trying to allocate too much memory in a vector.

For interpreted languages like Python, NZEC will usually mean that your program either crashed or raised an uncaught exception. Some of the reasons being in such cases would be: the above mentioned runtime errors. Or, for instance usage of an external library which is causing some error, or not being used by the judge.

MLE (Memory Limit Exceeded)
This error means that your program tried to allocate memory beyond the memory limit indicated. This can occur if you declare a very large array, or if a data structure in your program becomes too large.

OTHER
This type of error is sometimes generated if you use too much memory. Check for arrays that are too large, or other elements that could grow to a size too large to fit in memory. It can also be sometimes be generated for similar reasons to the SIGSEGV error.

Some ways to avoid runtime errors: - Make sure you aren't using variables that haven't been initialized. These may be set to 0 on your computer, but aren't guaranteed to be on the judge. - Check every single occurrence of accessing an array element and see if it could possibly be out of bounds. - Make sure you aren't declaring too much memory. 64 MB is guaranteed, but having an array of size [100000][100000] will never work. - Make sure you aren't declaring too much stack memory. Any large arrays should be declared globally, outside of any functions - putting an array of 100000 ints inside a function probably won't work.

Can I view other's solutions?

No, you can't. Similarly, no one can view your solution.

Why is my submission queued?

There might be many submissions by many users right now. So it will take some time in processing all of them. But you will get the result of your submission in real-time as soon as that gets processed.

Sometimes our code-checker servers or webservers might be under maintenance. As soon as that gets over, your submissions will be judged automatically.

The submissions are not getting evaluated, what should I do?

There might be an issue with the submission or the website, contact the support team asap in such cases. Send an email to support@hackerearth.com.

Comments:

If you think that some problem has an incorrect test data, its specification isn't clear or in your opinion something in the problem needs clarification, post a comment on the bottom of the problem's page. While posting comments, please keep the following things in mind: - Do NOT spam. - Don't post any source code. Be it your wrong solution, or an accepted solution. - Admins / Moderators are allowed to delete the comments.

If all this still doesn't answer your question, drop us an email at support@hackerearth.com.

Notifications
View All Notifications

?