MOJ: Submitting solutions (languages and input/output) — MOJ docs

MOJ: Submitting solutions (languages and input/output)

Translation note. This manual is a translation of the Portuguese original. The command-line tools (moj, moj-contest, moj-comp) print their messages in Portuguese, and the command examples below are identical to the original.

This manual is now a page of MOJ itself:

📖 /treino/ajuda/

On the site: use the "📖 How to submit" link, next to the language selector, when you submit the solution. It also works inside a contest: it is the only page outside /contest/ that contest-guard lets you open on the contest subdomain (there it uses the contest top bar and follows the contest LOCALE). The reason is that the competitor needs it on the isolated LAN.

The page teaches the same content that this file taught. The content now lives there:

  1. Input and output: the program reads from stdin, writes to stdout and never opens a file.
  2. The extension is the language: in the editor, the menu decides (the code becomes solution.<ext>). With a file, the file extension decides and MOJ ignores the menu. C++ accepts .cpp, .cc, .cxx and .c++. MOJ records the canonical language (cpp) and keeps the name of your file.
  3. Language table, with the id (which is the extension) and the note for each language.
  4. Code template for each language: the skeleton that the editor gives you and a complete solution, with a copy button.
  5. Warnings: the public class in Java, .pl that is Prolog and not Perl, Python that is pypy3, and the 128 MB stack.
  6. What MOJ refuses on receipt: an extension that the platform does not run (.exe, .pdf, .zip…) comes back with 400 lang_not_allowed and the list of what that problem accepts. An empty language list means the platform languages (PLATFORM_LANGS, the mirror of mojtools/lang/), never "any extension". A source file larger than 1 MB comes back with 413 source_too_large. These two checks came from the incident of 2026-08-19. In that incident, a compiled binary entered the queue and stayed pending forever.

Why it became a page and not a .md file

The content is web/treino/ajuda/ (the page) and web/treino/ajuda/exemplos.js (the complete solutions). To add a language to the table, change web/shared/languages.js. To add an example solution, run the code first and then add it to exemplos.js.

Where to go now