├── dmoj ├── __init__.py ├── tests │ ├── __init__.py │ ├── test_malformed_unicode.py │ ├── test_memory_io.py │ └── test_cpp_demangle.py ├── cptbox │ ├── ptdebug_freebsd_x64.h │ ├── ext_linux.h │ ├── syscalls │ │ └── aliases.list │ ├── ptdebug_x86.h │ ├── ptdebug_arm.h │ ├── ext_freebsd.h │ ├── __init__.py │ ├── handlers.pyi │ ├── handlers.py │ ├── ptdebug_arm64.h │ ├── ptdebug_x64.h │ └── helper.h ├── executors │ ├── java_sandbox.jar │ ├── __main__.py │ ├── PYPY3.py │ ├── F95.py │ ├── BASH.py │ ├── PY2.py │ ├── CPP03.py │ ├── C.py │ ├── PHP.py │ ├── PY3.py │ ├── GASARM.py │ ├── C11.py │ ├── CPP11.py │ ├── CPP14.py │ ├── PERL.py │ ├── CPP17.py │ ├── CPP20.py │ ├── CLANG.py │ ├── PIKE.py │ ├── LUA.py │ ├── CLANGX.py │ ├── TEXT.py │ ├── FORTH.py │ ├── ADA.py │ ├── SED.py │ ├── GAS32.py │ ├── GAS64.py │ ├── PRO.py │ ├── V8JS.py │ ├── AWK.py │ ├── SWIFT.py │ ├── D.py │ ├── NASM64.py │ ├── NASM.py │ ├── JAVA.py │ ├── HASK.py │ ├── MONOCS.py │ ├── PYPY.py │ ├── SCM.py │ ├── LEAN4.py │ ├── NODEJS.py │ ├── JAVA8.py │ ├── PAS.py │ └── MONOFS.py ├── main.py ├── utils │ ├── __init__.py │ ├── pyyaml_patch.py │ ├── glob_ext.py │ ├── normalize.py │ ├── module.py │ ├── error.py │ ├── setbufsize.c │ ├── ansi.py │ ├── unicode.py │ └── builtin_int_patch.py ├── __main__.py ├── checkers │ ├── floatsabs.py │ ├── floatsrel.py │ ├── standard.py │ ├── unordered.py │ ├── easy.py │ ├── __init__.py │ ├── identical.py │ ├── rstripped.py │ ├── __init__.pyi │ ├── sorted.py │ └── linecount.py ├── commands │ ├── quit.py │ ├── help.py │ ├── rejudge.py │ ├── locate.py │ ├── submissions.py │ └── __init__.py ├── graders │ ├── __init__.py │ └── custom.py ├── contrib │ ├── __init__.py │ └── base.py ├── error.py ├── control.py └── sysinfo.py ├── .dockerignore ├── testsuite ├── batched │ ├── a.out │ ├── b.out │ ├── tests │ │ └── py2_wa │ │ │ ├── allone.py │ │ │ └── test.yml │ └── init.yml ├── easy │ ├── 5.in │ ├── 3.in │ ├── 4.in │ ├── out.txt │ ├── 1.in │ ├── 2.in │ ├── tests │ │ └── python_echo │ │ │ ├── echo.py │ │ │ └── test.yml │ └── init.yml ├── helloworld │ ├── helloworld.in │ ├── tests │ │ ├── c_ce │ │ │ ├── fail.c │ │ │ └── test.yml │ │ ├── bf_rte_low │ │ │ ├── fail.b │ │ │ └── test.yml │ │ ├── bf_ce_unclosed │ │ │ ├── fail.b │ │ │ └── test.yml │ │ ├── bf_rte_high │ │ │ ├── fail.b │ │ │ └── test.yml │ │ ├── bf_ce_bad_stack │ │ │ ├── fail.b │ │ │ └── test.yml │ │ ├── py2_ac │ │ │ ├── helloworld.py │ │ │ └── test.yml │ │ ├── py2_wa │ │ │ ├── helloworld.py │ │ │ └── test.yml │ │ ├── py2_tle │ │ │ ├── helloworld.py │ │ │ └── test.yml │ │ ├── py3_grace │ │ │ ├── helloworld.py │ │ │ └── test.yml │ │ ├── pypy3_grace │ │ │ ├── helloworld.py │ │ │ └── test.yml │ │ ├── py2_ir_raise_SyntaxError │ │ │ ├── helloworld.py │ │ │ └── test.yml │ │ ├── c_failinit │ │ │ ├── fail.c │ │ │ └── test.linux.yml │ │ ├── cpp_badalloc │ │ │ ├── badalloc.cpp │ │ │ ├── test.linux.yml │ │ │ └── test.freebsd.yml │ │ ├── python_mle │ │ │ ├── helloworld.py │ │ │ └── test.yml │ │ ├── bf_ac │ │ │ └── test.yml │ │ ├── sandbox_py3_bad_file │ │ │ ├── helloworld.py │ │ │ └── test.yml │ │ ├── c_signal_ir │ │ │ ├── test.yml │ │ │ └── signal.c │ │ ├── cpp_ole │ │ │ ├── test.yml │ │ │ └── hello.cpp │ │ ├── go_low_mem │ │ │ ├── test.yml │ │ │ └── helloworld.go │ │ ├── java8_grace │ │ │ ├── test.yml │ │ │ └── grace.java │ │ ├── java_grace │ │ │ ├── test.yml │ │ │ └── grace.java │ │ ├── cpp_compiler_fmax_errors │ │ │ ├── hello.cpp │ │ │ └── test.yml │ │ ├── go_main_package │ │ │ ├── test.yml │ │ │ └── helloworld.go │ │ ├── go_not_main_package │ │ │ ├── test.yml │ │ │ └── helloworld.go │ │ ├── monocs_ac │ │ │ ├── test.posix.yml │ │ │ └── helloworld.cs │ │ ├── monocs_grace │ │ │ ├── test.posix.yml │ │ │ └── helloworld.cs │ │ ├── sandbox_c_null_path │ │ │ ├── test.yml │ │ │ └── nullpath.c │ │ ├── cpp_wall_clock │ │ │ ├── test.posix.yml │ │ │ └── stall.cpp │ │ ├── java_final_class │ │ │ ├── test.yml │ │ │ └── final_class.java │ │ ├── monocs_mle │ │ │ ├── test.posix.yml │ │ │ └── helloworld.cs │ │ ├── sandbox_c_format_open │ │ │ ├── test.yml │ │ │ └── format_open.c │ │ ├── sandbox_c_nametoolong │ │ │ ├── test.yml │ │ │ └── nametoolong.c │ │ ├── cpp_compile_tle │ │ │ └── test.linux.yml │ │ ├── java8_ce_name_too_long │ │ │ ├── test.yml │ │ │ └── helloworld.java │ │ ├── java8_ce_with_package │ │ │ ├── test.yml │ │ │ └── helloworld.java │ │ ├── java_abstract_class │ │ │ ├── test.yml │ │ │ └── abstract_class.java │ │ ├── java_strictfp_class │ │ │ ├── test.yml │ │ │ └── strictfp_class.java │ │ ├── sandbox_c_bad_unicode_open │ │ │ ├── test.yml │ │ │ └── bad_unicode.c │ │ ├── java_no_public_class │ │ │ ├── test.yml │ │ │ └── no_public_class.java │ │ ├── sandbox_nasm_kill_judge │ │ │ ├── test.linux.yml │ │ │ └── kill_judge.asm │ │ ├── java8_ir_throw_RuntimeException │ │ │ ├── test.yml │ │ │ └── helloworld.java │ │ ├── sandbox_nasm64_kill_judge │ │ │ ├── test.linux.yml │ │ │ └── kill_judge.asm │ │ ├── java_final_strictfp_class │ │ │ ├── test.yml │ │ │ └── final_strictfp_class.java │ │ ├── java_strictfp_abstract_class │ │ │ ├── test.yml │ │ │ └── strictfp_abstract_class.java │ │ ├── cpp_compiler_ole │ │ │ ├── test.yml │ │ │ └── hello.cpp │ │ ├── sandbox_c_null_path_noat │ │ │ ├── test.linux.yml │ │ │ └── nullpath.c │ │ ├── monocs_oom │ │ │ ├── test.posix.yml │ │ │ └── oom.cs │ │ ├── sandbox_c_nametoolong_noat │ │ │ ├── test.linux.yml │ │ │ └── nametoolong.c │ │ ├── sandbox_c_bad_unicode_open_noat │ │ │ ├── test.linux.yml │ │ │ └── bad_unicode.c │ │ ├── java_unsafe │ │ │ └── test.yml │ │ ├── java8_unicode_class │ │ │ ├── helloworld.java │ │ │ └── test.posix.yml │ │ └── java8_ir_no_entry_point │ │ │ ├── helloworld.java │ │ │ └── test.yml │ ├── helloworld.out │ └── init.yml ├── interactive │ ├── 1.in │ ├── 2.in │ ├── tests │ │ ├── py_no_flush │ │ │ ├── no_flush.py │ │ │ └── test.yml │ │ ├── c_ac │ │ │ ├── test.yml │ │ │ └── ac.c │ │ ├── py_ac │ │ │ ├── test.yml │ │ │ └── ac.py │ │ ├── py_wa │ │ │ ├── test.yml │ │ │ └── wa.py │ │ ├── pas_ac │ │ │ ├── test.yml │ │ │ └── ac.pas │ │ ├── c_no_flush │ │ │ ├── test.posix.yml │ │ │ └── ac.c │ │ ├── java_ac │ │ │ ├── test.yml │ │ │ └── ac.java │ │ └── py_not_num │ │ │ ├── not_num.py │ │ │ └── test.yml │ ├── init.yml │ └── interact.py ├── normalize │ ├── in2.txt │ ├── in1.txt │ ├── out.txt │ ├── tests │ │ └── cpp_echo │ │ │ ├── nothing.cpp │ │ │ └── test.yml │ ├── normalize.py │ └── init.yml ├── siggrade │ ├── siggrade.1.in │ ├── siggrade.2.in │ ├── siggrade.2.out │ ├── siggrade.1.out │ ├── tests │ │ ├── cpp_signature_grading │ │ │ ├── sigtest.cpp │ │ │ └── test.yml │ │ └── cpp_macro_test │ │ │ ├── siggrade.cpp │ │ │ └── test.yml │ ├── header.h │ ├── init.yml │ └── handler.c ├── batch_dependencies │ ├── 1.txt │ ├── 2.txt │ ├── 3.txt │ ├── tests │ │ ├── python_pass_one │ │ │ ├── allone.py │ │ │ └── test.yml │ │ ├── python_pass_two │ │ │ ├── alltwo.py │ │ │ └── test.yml │ │ └── python_ac_all │ │ │ ├── echo.py │ │ │ └── test.yml │ └── init.yml ├── batch_short_circuit │ ├── 1.txt │ ├── 2.txt │ ├── tests │ │ ├── python_wa_batch │ │ │ ├── allone.py │ │ │ └── test.yml │ │ └── python_ac_batch │ │ │ ├── echo.py │ │ │ └── test.yml │ └── init.yml ├── mixed_str_int_cases │ ├── 1.in │ ├── 1.out │ ├── dummy.1.in │ ├── dummy.1.out │ ├── dummy.2.in │ ├── dummy.2.out │ ├── tests │ │ └── py_ac │ │ │ ├── ac.py │ │ │ └── test.yml │ ├── cases.zip │ └── init.yml ├── scroll │ ├── tests │ │ ├── py2_wa │ │ │ ├── helloworld.py │ │ │ └── test.yml │ │ ├── py2_ac │ │ │ ├── helloworld.py │ │ │ └── test.yml │ │ ├── c_rte_protection_fault_freebsd │ │ │ ├── test.freebsd.yml │ │ │ └── scroll.c │ │ └── c_rte_protection_fault_linux │ │ │ ├── test.linux.yml │ │ │ └── scroll.c │ ├── init.yml │ └── checker.py ├── sorted │ ├── 3.txt │ ├── 4.txt │ ├── 1.txt │ ├── 2.txt │ ├── tests │ │ └── python_echo │ │ │ ├── echo.py │ │ │ └── test.yml │ └── init.yml ├── generator │ ├── 1.in │ ├── 2.in │ ├── 3.in │ ├── tests │ │ └── cpp_ac │ │ │ ├── test.yml │ │ │ └── aplusb.cpp │ ├── init.yml │ └── generator.cpp ├── testlib_partial │ ├── tests │ │ └── py_ac │ │ │ ├── ac.py │ │ │ └── test.yml │ ├── checker.cpp │ └── init.yml ├── bridged_checker_flags │ ├── tests │ │ └── py_ac │ │ │ ├── ac.py │ │ │ └── test.yml │ ├── checker.c │ └── init.yml ├── coci_partial │ ├── tests │ │ ├── py_empty_ie │ │ │ ├── ie.py │ │ │ └── test.yml │ │ ├── py_ac │ │ │ ├── ac.py │ │ │ └── test.yml │ │ ├── py_neg_ie │ │ │ ├── ie.py │ │ │ └── test.yml │ │ ├── py_no_match_ie │ │ │ ├── ie.py │ │ │ └── test.yml │ │ ├── py_above_one_ie │ │ │ ├── ie.py │ │ │ └── test.yml │ │ ├── py_div_by_zero_ie │ │ │ ├── ie.py │ │ │ └── test.yml │ │ ├── py_lower_bound_ac │ │ │ ├── ac.py │ │ │ └── test.yml │ │ ├── py_upper_bound_ac │ │ │ ├── ac.py │ │ │ └── test.yml │ │ └── py_garbage_ac │ │ │ ├── ac.py │ │ │ └── test.yml │ ├── init.yml │ └── checker.cpp ├── bridged_checker │ ├── tests │ │ ├── py_ac │ │ │ ├── ac.py │ │ │ └── test.yml │ │ ├── py_wa │ │ │ ├── wa.py │ │ │ └── test.yml │ │ └── py_pe │ │ │ ├── pe.py │ │ │ └── test.yml │ ├── init.yml │ └── checker.c ├── bridged_checker_multifile │ ├── tests │ │ └── py_ac │ │ │ ├── ac.py │ │ │ └── test.yml │ ├── header.h │ ├── checker.c │ └── init.yml ├── bridged_checker_peg │ ├── tests │ │ ├── py_ac │ │ │ ├── ac.py │ │ │ └── test.yml │ │ ├── py_wa │ │ │ ├── wa.py │ │ │ └── test.yml │ │ └── py_partial_ac │ │ │ ├── ac.py │ │ │ └── test.yml │ ├── in.txt │ ├── out.txt │ ├── init.yml │ └── check.cpp ├── bridged_interactor_flags │ ├── tests │ │ └── py_ac │ │ │ ├── ac.py │ │ │ └── test.yml │ ├── interactor.c │ └── init.yml ├── floats │ ├── 1.txt │ ├── 3.txt │ ├── 5.txt │ ├── 6.txt │ ├── 8.txt │ ├── 2.txt │ ├── 4.txt │ ├── 7.txt │ ├── tests │ │ └── python_echo │ │ │ ├── echo.py │ │ │ └── test.yml │ └── init.yml ├── generator_custom_limits │ ├── 1.in │ ├── 2.in │ ├── 3.in │ ├── tests │ │ └── cpp_ac │ │ │ ├── test.yml │ │ │ └── aplusb.cpp │ ├── init.yml │ └── generator.cpp ├── rust_bridged │ ├── tests │ │ └── empty │ │ │ ├── empty.rs │ │ │ └── test.yml │ ├── checker.rs │ ├── init.yml │ └── README.md ├── bridged_checker_custom_args │ ├── tests │ │ └── py_ac │ │ │ ├── ac.py │ │ │ └── test.yml │ ├── check.py │ └── init.yml ├── bridged_interactor_custom_args │ ├── tests │ │ └── py_ac │ │ │ ├── ac.py │ │ │ └── test.yml │ ├── interact.py │ └── init.yml ├── bridged_interactor_multifile │ ├── tests │ │ └── py_ac │ │ │ ├── ac.py │ │ │ └── test.yml │ ├── header.h │ ├── init.yml │ └── interactor.c ├── shortest1 │ ├── tests │ │ └── custom_grader_ac │ │ │ ├── forever.py │ │ │ └── test.yml │ ├── init.yml │ └── shortest1.py ├── bridged_checker_not_contrib_module │ ├── tests │ │ └── py_ie │ │ │ ├── ie.py │ │ │ └── test.yml │ ├── check.py │ └── init.yml ├── generator_test_ce │ ├── generator.cpp │ ├── init.yml │ └── tests │ │ └── cpp_ie │ │ ├── test.yml │ │ └── test.c ├── bridged_interactor_not_contrib_module │ ├── tests │ │ └── py_ie │ │ │ ├── ie.py │ │ │ └── test.yml │ ├── interact.py │ └── init.yml ├── bridged_interactor │ ├── tests │ │ ├── py2_tle │ │ │ ├── seed2.py │ │ │ └── test.yml │ │ ├── py2_closes_pipes │ │ │ ├── seed2.py │ │ │ └── test.yml │ │ ├── py2_presentation_error │ │ │ ├── seed2.py │ │ │ └── test.yml │ │ ├── cpp_ac │ │ │ ├── test.yml │ │ │ └── seed2.cpp │ │ ├── tur_ac │ │ │ ├── test.yml │ │ │ └── seed2.tur │ │ ├── java8_grace │ │ │ ├── test.yml │ │ │ └── seed2.java │ │ ├── java_ac │ │ │ ├── test.yml │ │ │ └── seed2.java │ │ └── cpp_no_flush │ │ │ ├── test.posix.yml │ │ │ └── seed2.cpp │ ├── seed2_abridged.zip │ ├── init.yml │ └── interactor.cpp ├── bridged_interactor_noflush │ ├── tests │ │ ├── py2_tle │ │ │ ├── seed2.py │ │ │ └── test.yml │ │ ├── py2_closes_pipes │ │ │ ├── seed2.py │ │ │ └── test.yml │ │ ├── cpp_ac │ │ │ ├── test.yml │ │ │ └── seed2.cpp │ │ └── cpp_no_flush │ │ │ ├── test.posix.yml │ │ │ └── seed2.cpp │ ├── seed2_abridged.zip │ ├── init.yml │ └── interactor.cpp ├── linecount │ ├── tests │ │ └── python_echo │ │ │ ├── echo.py │ │ │ └── test.yml │ ├── 1.txt │ ├── 2.txt │ ├── 3.txt │ └── init.yml ├── check_memory_limit │ ├── tests │ │ ├── c_blank │ │ │ ├── empty.c │ │ │ └── test.yml │ │ └── cpp_too_much_memory │ │ │ ├── test.yml │ │ │ └── bloat.cpp │ ├── init.yml │ └── checker.py ├── generator_multifile │ ├── tests │ │ └── cpp_ac │ │ │ ├── aplusb.py │ │ │ └── test.yml │ ├── gen.cpp │ └── init.yml ├── rust_generator │ ├── tests │ │ └── AC │ │ │ ├── sol.py │ │ │ └── test.yml │ ├── README.md │ ├── init.yml │ └── generator.rs ├── aplusb │ ├── aplusb.zip │ ├── tests │ │ ├── cpp_macro_test │ │ │ ├── cpp_ce.cpp │ │ │ └── test.yml │ │ ├── pas_ac │ │ │ ├── test.yml │ │ │ └── aplusb.pas │ │ ├── java_ac │ │ │ ├── test.yml │ │ │ └── aplusb.java │ │ ├── cpp_io_symlinks │ │ │ ├── test.posix.yml │ │ │ └── aplusb.cpp │ │ ├── java_bigdecimal │ │ │ ├── test.yml │ │ │ └── aplusb.java │ │ └── java_biginteger │ │ │ ├── test.yml │ │ │ └── aplusb.java │ └── init.yml ├── generator_test_sandbox │ ├── init.yml │ ├── tests │ │ └── cpp_ie │ │ │ ├── test.yml │ │ │ └── aplusb.cpp │ └── generator.cpp ├── binary_data │ ├── tests │ │ └── c_echo │ │ │ ├── test.yml │ │ │ └── echo.c │ ├── init.yml │ └── gen.c ├── seed2 │ ├── seed2_abridged.zip │ ├── tests │ │ ├── tur_ac │ │ │ ├── test.yml │ │ │ └── seed2.tur │ │ ├── cpp_ac │ │ │ ├── test.yml │ │ │ └── seed2.cpp │ │ ├── java8_grace │ │ │ ├── test.yml │ │ │ └── seed2.java │ │ ├── java_ac │ │ │ ├── test.yml │ │ │ └── seed2.java │ │ ├── java_grace │ │ │ ├── test.yml │ │ │ └── seed2.java │ │ ├── java_mle │ │ │ ├── test.yml │ │ │ └── seed2.java │ │ ├── cpp_no_flush │ │ │ ├── test.posix.yml │ │ │ └── seed2.cpp │ │ └── java_ir │ │ │ ├── test.yml │ │ │ └── seed2.java │ ├── init.yml │ └── seed2.py ├── generator_python │ ├── tests │ │ └── cpp_ac │ │ │ ├── test.yml │ │ │ └── aplusb.cpp │ ├── gen.py2 │ └── init.yml ├── generator_pass_flags │ ├── tests │ │ └── cpp_ac │ │ │ ├── test.yml │ │ │ └── aplusb.cpp │ ├── init.yml │ └── generator.cpp ├── generator_test_tle │ ├── init.yml │ ├── tests │ │ └── cpp_ie │ │ │ ├── test.yml │ │ │ └── aplusb.cpp │ └── generator.cpp └── generator_test_mle │ ├── init.yml │ ├── generator.cpp │ └── tests │ └── cpp_ie │ ├── test.posix.yml │ └── aplusb.cpp ├── codecov.yml ├── mypy.ini ├── requirements.txt ├── .gitmodules ├── pyproject.toml ├── MANIFEST.in ├── .clang-format ├── contrib ├── README.md └── vm-host-problem-watch │ └── vm-host-problem-watch.sh ├── .coveragerc ├── .docker ├── Makefile ├── entry ├── tier1 │ └── Dockerfile ├── tier2 │ └── Dockerfile └── tier3 │ └── Dockerfile ├── .git-blame-ignore-revs ├── .docker.test.py ├── .gitignore ├── .github └── workflows │ ├── upload-pypi.yml │ └── update-syscalls.yml ├── .flake8 └── .freebsd.test.py /dmoj/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dmoj/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | *.pyc 3 | -------------------------------------------------------------------------------- /testsuite/batched/a.out: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /testsuite/batched/b.out: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /testsuite/easy/5.in: -------------------------------------------------------------------------------- 1 | heloworld 2 | -------------------------------------------------------------------------------- /testsuite/easy/3.in: -------------------------------------------------------------------------------- 1 | helloworld 2 | -------------------------------------------------------------------------------- /testsuite/easy/4.in: -------------------------------------------------------------------------------- 1 | HELLO WORLD 2 | -------------------------------------------------------------------------------- /testsuite/easy/out.txt: -------------------------------------------------------------------------------- 1 | Hello World 2 | -------------------------------------------------------------------------------- /testsuite/helloworld/helloworld.in: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /testsuite/interactive/1.in: -------------------------------------------------------------------------------- 1 | 20 2 | 3 | -------------------------------------------------------------------------------- /testsuite/interactive/2.in: -------------------------------------------------------------------------------- 1 | 50 2 | 3 | -------------------------------------------------------------------------------- /testsuite/normalize/in2.txt: -------------------------------------------------------------------------------- 1 | 2 1 1 2 2 -------------------------------------------------------------------------------- /testsuite/siggrade/siggrade.1.in: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /testsuite/siggrade/siggrade.2.in: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /testsuite/batch_dependencies/1.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /testsuite/batch_dependencies/2.txt: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /testsuite/batch_dependencies/3.txt: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /testsuite/batch_short_circuit/1.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /testsuite/batch_short_circuit/2.txt: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /testsuite/mixed_str_int_cases/1.in: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /testsuite/mixed_str_int_cases/1.out: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /testsuite/scroll/tests/py2_wa/helloworld.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /testsuite/siggrade/siggrade.2.out: -------------------------------------------------------------------------------- 1 | wrong 2 | -------------------------------------------------------------------------------- /testsuite/easy/1.in: -------------------------------------------------------------------------------- 1 | h e l l o w o rld 2 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/c_ce/fail.c: -------------------------------------------------------------------------------- 1 | . 2 | -------------------------------------------------------------------------------- /testsuite/siggrade/siggrade.1.out: -------------------------------------------------------------------------------- 1 | correct 2 | -------------------------------------------------------------------------------- /testsuite/sorted/3.txt: -------------------------------------------------------------------------------- 1 | 1 2 3 4 5 6 7 8 9 10 2 | -------------------------------------------------------------------------------- /testsuite/sorted/4.txt: -------------------------------------------------------------------------------- 1 | 3 1 8 2 9 5 7 6 4 10 2 | -------------------------------------------------------------------------------- /testsuite/batched/tests/py2_wa/allone.py: -------------------------------------------------------------------------------- 1 | print 1 2 | -------------------------------------------------------------------------------- /testsuite/generator/1.in: -------------------------------------------------------------------------------- 1 | 1 2 | 1.in 3 | 1.out 4 | -------------------------------------------------------------------------------- /testsuite/generator/2.in: -------------------------------------------------------------------------------- 1 | 2 2 | 2.in 3 | 2.out 4 | -------------------------------------------------------------------------------- /testsuite/generator/3.in: -------------------------------------------------------------------------------- 1 | 3 2 | 3.in 3 | 3.out 4 | -------------------------------------------------------------------------------- /testsuite/helloworld/helloworld.out: -------------------------------------------------------------------------------- 1 | Hello, World! 2 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/bf_rte_low/fail.b: -------------------------------------------------------------------------------- 1 | <[] 2 | -------------------------------------------------------------------------------- /testsuite/mixed_str_int_cases/dummy.1.in: -------------------------------------------------------------------------------- 1 | dummy 1 2 | -------------------------------------------------------------------------------- /testsuite/mixed_str_int_cases/dummy.1.out: -------------------------------------------------------------------------------- 1 | dummy 1 2 | -------------------------------------------------------------------------------- /testsuite/mixed_str_int_cases/dummy.2.in: -------------------------------------------------------------------------------- 1 | dummy 2 2 | -------------------------------------------------------------------------------- /testsuite/mixed_str_int_cases/dummy.2.out: -------------------------------------------------------------------------------- 1 | dummy 2 2 | -------------------------------------------------------------------------------- /testsuite/normalize/in1.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 1 1 3 | 2 2 4 | -------------------------------------------------------------------------------- /testsuite/normalize/out.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 1 1 3 | 2 2 4 | -------------------------------------------------------------------------------- /testsuite/testlib_partial/tests/py_ac/ac.py: -------------------------------------------------------------------------------- 1 | pass 2 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_flags/tests/py_ac/ac.py: -------------------------------------------------------------------------------- 1 | pass 2 | -------------------------------------------------------------------------------- /testsuite/coci_partial/tests/py_empty_ie/ie.py: -------------------------------------------------------------------------------- 1 | pass 2 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/bf_ce_unclosed/fail.b: -------------------------------------------------------------------------------- 1 | [[] 2 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/bf_rte_high/fail.b: -------------------------------------------------------------------------------- 1 | +[>+] 2 | -------------------------------------------------------------------------------- /testsuite/bridged_checker/tests/py_ac/ac.py: -------------------------------------------------------------------------------- 1 | print -1, 1 2 | -------------------------------------------------------------------------------- /testsuite/bridged_checker/tests/py_wa/wa.py: -------------------------------------------------------------------------------- 1 | print -1, -2 2 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_multifile/tests/py_ac/ac.py: -------------------------------------------------------------------------------- 1 | pass 2 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_peg/tests/py_ac/ac.py: -------------------------------------------------------------------------------- 1 | print(10) 2 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_peg/tests/py_wa/wa.py: -------------------------------------------------------------------------------- 1 | print(0) 2 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_flags/tests/py_ac/ac.py: -------------------------------------------------------------------------------- 1 | pass 2 | -------------------------------------------------------------------------------- /testsuite/floats/1.txt: -------------------------------------------------------------------------------- 1 | Floats Test 2 | 50 3 | 50 4 | 50 5 | -------------------------------------------------------------------------------- /testsuite/floats/3.txt: -------------------------------------------------------------------------------- 1 | Floats Test 2 | 50.4 3 | 49.7 4 | 50 5 | -------------------------------------------------------------------------------- /testsuite/floats/5.txt: -------------------------------------------------------------------------------- 1 | Floats Test 2 | 20 3 | 50 4 | 50 5 | -------------------------------------------------------------------------------- /testsuite/floats/6.txt: -------------------------------------------------------------------------------- 1 | Floats Test 2 | 50 3 | 50.6 4 | 50 5 | -------------------------------------------------------------------------------- /testsuite/floats/8.txt: -------------------------------------------------------------------------------- 1 | Floats Test 2 | nan 3 | NaN 4 | NAN 5 | -------------------------------------------------------------------------------- /testsuite/generator_custom_limits/1.in: -------------------------------------------------------------------------------- 1 | 1 2 | 1.in 3 | 1.out 4 | -------------------------------------------------------------------------------- /testsuite/generator_custom_limits/2.in: -------------------------------------------------------------------------------- 1 | 2 2 | 2.in 3 | 2.out 4 | -------------------------------------------------------------------------------- /testsuite/generator_custom_limits/3.in: -------------------------------------------------------------------------------- 1 | 3 2 | 3.in 3 | 3.out 4 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/bf_ce_bad_stack/fail.b: -------------------------------------------------------------------------------- 1 | []][[] 2 | -------------------------------------------------------------------------------- /testsuite/rust_bridged/tests/empty/empty.rs: -------------------------------------------------------------------------------- 1 | fn main() {} 2 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_custom_args/tests/py_ac/ac.py: -------------------------------------------------------------------------------- 1 | pass 2 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_peg/in.txt: -------------------------------------------------------------------------------- 1 | This is the input file. 2 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_peg/out.txt: -------------------------------------------------------------------------------- 1 | This is the judge file. 2 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_peg/tests/py_partial_ac/ac.py: -------------------------------------------------------------------------------- 1 | print(1) 2 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_custom_args/tests/py_ac/ac.py: -------------------------------------------------------------------------------- 1 | pass 2 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_multifile/tests/py_ac/ac.py: -------------------------------------------------------------------------------- 1 | pass 2 | -------------------------------------------------------------------------------- /testsuite/coci_partial/tests/py_ac/ac.py: -------------------------------------------------------------------------------- 1 | print("partial 1/5") 2 | -------------------------------------------------------------------------------- /testsuite/easy/2.in: -------------------------------------------------------------------------------- 1 | hell 2 | o 3 | w 4 | o 5 | r 6 | l 7 | d 8 | -------------------------------------------------------------------------------- /testsuite/floats/2.txt: -------------------------------------------------------------------------------- 1 | Floats Test 2 | 49.99 3 | 50.01 4 | 50 5 | -------------------------------------------------------------------------------- /testsuite/floats/4.txt: -------------------------------------------------------------------------------- 1 | Floats TestFAILHERE 2 | 50 3 | 50 4 | 50 5 | -------------------------------------------------------------------------------- /testsuite/mixed_str_int_cases/tests/py_ac/ac.py: -------------------------------------------------------------------------------- 1 | print(input()) 2 | -------------------------------------------------------------------------------- /testsuite/shortest1/tests/custom_grader_ac/forever.py: -------------------------------------------------------------------------------- 1 | while 1:0 2 | -------------------------------------------------------------------------------- /testsuite/batch_dependencies/tests/python_pass_one/allone.py: -------------------------------------------------------------------------------- 1 | print(1) 2 | -------------------------------------------------------------------------------- /testsuite/batch_dependencies/tests/python_pass_two/alltwo.py: -------------------------------------------------------------------------------- 1 | print(2) 2 | -------------------------------------------------------------------------------- /testsuite/batch_short_circuit/tests/python_wa_batch/allone.py: -------------------------------------------------------------------------------- 1 | print 1 2 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_multifile/header.h: -------------------------------------------------------------------------------- 1 | #define HEADER_EXISTS 2 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_not_contrib_module/tests/py_ie/ie.py: -------------------------------------------------------------------------------- 1 | pass 2 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_multifile/header.h: -------------------------------------------------------------------------------- 1 | #define HEADER_EXISTS 2 | -------------------------------------------------------------------------------- /testsuite/coci_partial/tests/py_neg_ie/ie.py: -------------------------------------------------------------------------------- 1 | print("partial -1/10") 2 | -------------------------------------------------------------------------------- /testsuite/coci_partial/tests/py_no_match_ie/ie.py: -------------------------------------------------------------------------------- 1 | print("partial 10") 2 | -------------------------------------------------------------------------------- /testsuite/generator_test_ce/generator.cpp: -------------------------------------------------------------------------------- 1 | This is a compile error. 2 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/py2_ac/helloworld.py: -------------------------------------------------------------------------------- 1 | print 'Hello, World!' 2 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/py2_wa/helloworld.py: -------------------------------------------------------------------------------- 1 | print 'Hello World!' 2 | -------------------------------------------------------------------------------- /testsuite/batch_dependencies/tests/python_ac_all/echo.py: -------------------------------------------------------------------------------- 1 | print(input()) 2 | -------------------------------------------------------------------------------- /testsuite/bridged_checker/tests/py_pe/pe.py: -------------------------------------------------------------------------------- 1 | print 'This is not a number' 2 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_not_contrib_module/check.py: -------------------------------------------------------------------------------- 1 | raise SystemExit(0) 2 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_not_contrib_module/tests/py_ie/ie.py: -------------------------------------------------------------------------------- 1 | pass 2 | -------------------------------------------------------------------------------- /testsuite/coci_partial/tests/py_above_one_ie/ie.py: -------------------------------------------------------------------------------- 1 | print("partial 11/10") 2 | -------------------------------------------------------------------------------- /testsuite/coci_partial/tests/py_div_by_zero_ie/ie.py: -------------------------------------------------------------------------------- 1 | print("partial 1/0") 2 | -------------------------------------------------------------------------------- /testsuite/coci_partial/tests/py_lower_bound_ac/ac.py: -------------------------------------------------------------------------------- 1 | print("partial 0/4") 2 | -------------------------------------------------------------------------------- /testsuite/coci_partial/tests/py_upper_bound_ac/ac.py: -------------------------------------------------------------------------------- 1 | print("partial 4/4") 2 | -------------------------------------------------------------------------------- /testsuite/floats/7.txt: -------------------------------------------------------------------------------- 1 | Floats Test 2 | 3 | 50 4 | 5 | 50 6 | 7 | 50 8 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/py2_tle/helloworld.py: -------------------------------------------------------------------------------- 1 | while 1: 2 | pass 3 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/py3_grace/helloworld.py: -------------------------------------------------------------------------------- 1 | print('Hello, World!') 2 | -------------------------------------------------------------------------------- /testsuite/normalize/tests/cpp_echo/nothing.cpp: -------------------------------------------------------------------------------- 1 | int main() { return 0; } 2 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | status: 3 | project: off 4 | patch: off 5 | -------------------------------------------------------------------------------- /testsuite/batch_short_circuit/tests/python_ac_batch/echo.py: -------------------------------------------------------------------------------- 1 | print raw_input() 2 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor/tests/py2_tle/seed2.py: -------------------------------------------------------------------------------- 1 | while True: 2 | pass 3 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_not_contrib_module/interact.py: -------------------------------------------------------------------------------- 1 | raise SystemExit(0) 2 | -------------------------------------------------------------------------------- /testsuite/easy/tests/python_echo/echo.py: -------------------------------------------------------------------------------- 1 | import sys 2 | print sys.stdin.read() 3 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/pypy3_grace/helloworld.py: -------------------------------------------------------------------------------- 1 | print('Hello, World!') 2 | -------------------------------------------------------------------------------- /testsuite/interactive/tests/py_no_flush/no_flush.py: -------------------------------------------------------------------------------- 1 | print 0 2 | print input() 3 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_noflush/tests/py2_tle/seed2.py: -------------------------------------------------------------------------------- 1 | while True: 2 | pass 3 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/py2_ir_raise_SyntaxError/helloworld.py: -------------------------------------------------------------------------------- 1 | raise SyntaxError 2 | -------------------------------------------------------------------------------- /testsuite/linecount/tests/python_echo/echo.py: -------------------------------------------------------------------------------- 1 | import sys 2 | print sys.stdin.read() 3 | -------------------------------------------------------------------------------- /testsuite/scroll/init.yml: -------------------------------------------------------------------------------- 1 | checker: checker.py 2 | test_cases: 3 | - {points: 100} 4 | -------------------------------------------------------------------------------- /testsuite/check_memory_limit/tests/c_blank/empty.c: -------------------------------------------------------------------------------- 1 | int main() { 2 | return 0; 3 | } 4 | -------------------------------------------------------------------------------- /testsuite/rust_bridged/checker.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | std::process::exit(1); // WA 3 | } 4 | -------------------------------------------------------------------------------- /dmoj/cptbox/ptdebug_freebsd_x64.h: -------------------------------------------------------------------------------- 1 | #include 2 | typedef struct reg ptbox_regs; 3 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_flags/checker.c: -------------------------------------------------------------------------------- 1 | #ifdef FLAG 2 | int main() { return 0; } 3 | #endif 4 | -------------------------------------------------------------------------------- /testsuite/coci_partial/tests/py_garbage_ac/ac.py: -------------------------------------------------------------------------------- 1 | print("abcdefg") 2 | print("partial 1/10") 3 | -------------------------------------------------------------------------------- /testsuite/floats/tests/python_echo/echo.py: -------------------------------------------------------------------------------- 1 | import sys 2 | sys.stdout.write(sys.stdin.read()) 3 | -------------------------------------------------------------------------------- /testsuite/generator_multifile/tests/cpp_ac/aplusb.py: -------------------------------------------------------------------------------- 1 | print sum(map(int, raw_input().split())) 2 | -------------------------------------------------------------------------------- /testsuite/generator_test_ce/init.yml: -------------------------------------------------------------------------------- 1 | generator: generator.cpp 2 | test_cases: 3 | - points: 10 4 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/c_failinit/fail.c: -------------------------------------------------------------------------------- 1 | int fail[32][1024][1024]; 2 | 3 | int main() {} 4 | -------------------------------------------------------------------------------- /testsuite/rust_generator/tests/AC/sol.py: -------------------------------------------------------------------------------- 1 | x, y = map(int, input().split()) 2 | print(x + y) 3 | -------------------------------------------------------------------------------- /testsuite/scroll/tests/py2_ac/helloworld.py: -------------------------------------------------------------------------------- 1 | #! -*- encoding: utf-8 -*- 2 | 3 | print 'バカ' 4 | -------------------------------------------------------------------------------- /testsuite/shortest1/init.yml: -------------------------------------------------------------------------------- 1 | custom_judge: shortest1.py 2 | test_cases: 3 | - {points: 10} 4 | -------------------------------------------------------------------------------- /testsuite/sorted/1.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 9 | 9 10 | 10 11 | -------------------------------------------------------------------------------- /testsuite/sorted/2.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 1 3 | 8 4 | 2 5 | 9 6 | 5 7 | 7 8 | 6 9 | 4 10 | 10 11 | -------------------------------------------------------------------------------- /testsuite/sorted/tests/python_echo/echo.py: -------------------------------------------------------------------------------- 1 | import sys 2 | sys.stdout.write(sys.stdin.read()) 3 | -------------------------------------------------------------------------------- /mypy.ini: -------------------------------------------------------------------------------- 1 | [mypy] 2 | ignore_missing_imports = True 3 | 4 | [mypy-setup] 5 | ignore_errors = True 6 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_flags/interactor.c: -------------------------------------------------------------------------------- 1 | #ifdef FLAG 2 | int main() { return 0; } 3 | #endif 4 | -------------------------------------------------------------------------------- /testsuite/check_memory_limit/init.yml: -------------------------------------------------------------------------------- 1 | checker: checker.py 2 | points: 1 3 | test_cases: 4 | - {} 5 | -------------------------------------------------------------------------------- /testsuite/linecount/1.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 1 4 | 1 5 | 1 6 | 1 7 | 1 8 | 1 9 | 1 10 | 1 11 | 12 | -------------------------------------------------------------------------------- /testsuite/linecount/2.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 1 4 | 1 5 | 1 6 | 1 7 | 1 8 | 1 9 | 1 10 | 2 11 | 12 | -------------------------------------------------------------------------------- /testsuite/linecount/3.txt: -------------------------------------------------------------------------------- 1 | 0 2 | 0 3 | 0 4 | 0 5 | 0 6 | 0 7 | 0 8 | 0 9 | 0 10 | 0 11 | 12 | -------------------------------------------------------------------------------- /testsuite/siggrade/tests/cpp_signature_grading/sigtest.cpp: -------------------------------------------------------------------------------- 1 | bool is_valid(int n) { return n == 1; } 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | cython 2 | pylru 3 | pygments 4 | pyyaml 5 | setproctitle 6 | termcolor 7 | watchdog 8 | -------------------------------------------------------------------------------- /testsuite/aplusb/aplusb.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DMOJ/judge-server/HEAD/testsuite/aplusb/aplusb.zip -------------------------------------------------------------------------------- /testsuite/generator_test_sandbox/init.yml: -------------------------------------------------------------------------------- 1 | generator: generator.cpp 2 | test_cases: 3 | - {points: 10} 4 | -------------------------------------------------------------------------------- /testsuite/helloworld/init.yml: -------------------------------------------------------------------------------- 1 | test_cases: 2 | - {in: helloworld.in, out: helloworld.out, points: 100} 3 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/cpp_badalloc/badalloc.cpp: -------------------------------------------------------------------------------- 1 | int main() { return (new int[512][512][512])[0][0][0]; } 2 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/python_mle/helloworld.py: -------------------------------------------------------------------------------- 1 | A = [i for i in xrange(10**6)] 2 | print 'Hello, World!' 3 | -------------------------------------------------------------------------------- /dmoj/executors/java_sandbox.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DMOJ/judge-server/HEAD/dmoj/executors/java_sandbox.jar -------------------------------------------------------------------------------- /testsuite/rust_generator/README.md: -------------------------------------------------------------------------------- 1 | This test checks that a generator, using rand, can be compiled and run in Rust. 2 | -------------------------------------------------------------------------------- /testsuite/aplusb/tests/cpp_macro_test/cpp_ce.cpp: -------------------------------------------------------------------------------- 1 | #ifdef SIGNATURE_GRADER 2 | 3 | int main() { return -1; } 4 | #endif 5 | -------------------------------------------------------------------------------- /testsuite/binary_data/tests/c_echo/test.yml: -------------------------------------------------------------------------------- 1 | language: C 2 | time: 1 3 | memory: 65536 4 | source: echo.c 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor/tests/py2_closes_pipes/seed2.py: -------------------------------------------------------------------------------- 1 | import sys 2 | sys.stdin.close() 3 | sys.stdout.close() 4 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor/tests/py2_presentation_error/seed2.py: -------------------------------------------------------------------------------- 1 | # It expects numbers between 1 and 2e9 2 | print 0 3 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/c_ce/test.yml: -------------------------------------------------------------------------------- 1 | language: C 2 | time: 1 3 | memory: 1024 4 | source: fail.c 5 | expect: CE 6 | -------------------------------------------------------------------------------- /testsuite/interactive/tests/c_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: C 2 | time: 2 3 | memory: 65536 4 | source: ac.c 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/interactive/tests/py_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: ac.py 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/interactive/tests/py_wa/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: wa.py 5 | expect: WA 6 | -------------------------------------------------------------------------------- /testsuite/seed2/seed2_abridged.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DMOJ/judge-server/HEAD/testsuite/seed2/seed2_abridged.zip -------------------------------------------------------------------------------- /testsuite/seed2/tests/tur_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: TUR 2 | time: 2 3 | memory: 65536 4 | source: seed2.tur 5 | expect: AC 6 | -------------------------------------------------------------------------------- /dmoj/main.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | from dmoj.judge import main 4 | 5 | if __name__ == '__main__': 6 | sys.exit(main()) 7 | -------------------------------------------------------------------------------- /testsuite/aplusb/tests/pas_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PAS 2 | time: 2 3 | memory: 65536 4 | source: aplusb.pas 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/bridged_checker/tests/py_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: ac.py 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/bridged_checker/tests/py_wa/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: wa.py 5 | expect: WA 6 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_noflush/tests/py2_closes_pipes/seed2.py: -------------------------------------------------------------------------------- 1 | import sys 2 | sys.stdin.close() 3 | sys.stdout.close() 4 | -------------------------------------------------------------------------------- /testsuite/coci_partial/tests/py_neg_ie/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 2 3 | memory: 65536 4 | source: ie.py 5 | expect: IE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/bf_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: BF 2 | time: 1 3 | memory: 64 4 | source: helloworld.b 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/bf_ce_unclosed/test.yml: -------------------------------------------------------------------------------- 1 | language: BF 2 | time: 1 3 | memory: 64 4 | source: fail.b 5 | expect: CE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/bf_rte_high/test.yml: -------------------------------------------------------------------------------- 1 | language: BF 2 | time: 1 3 | memory: 64 4 | source: fail.b 5 | expect: RTE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/bf_rte_low/test.yml: -------------------------------------------------------------------------------- 1 | language: BF 2 | time: 1 3 | memory: 64 4 | source: fail.b 5 | expect: RTE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_py3_bad_file/helloworld.py: -------------------------------------------------------------------------------- 1 | with open('/dev/full') as f: 2 | print('Hello, World!') 3 | -------------------------------------------------------------------------------- /testsuite/interactive/tests/pas_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PAS 2 | time: 2 3 | memory: 65536 4 | source: ac.pas 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/rust_bridged/tests/empty/test.yml: -------------------------------------------------------------------------------- 1 | language: RUST 2 | time: 2 3 | memory: 65536 4 | source: empty.rs 5 | expect: WA 6 | -------------------------------------------------------------------------------- /testsuite/scroll/tests/py2_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: helloworld.py 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/scroll/tests/py2_wa/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: helloworld.py 5 | expect: WA 6 | -------------------------------------------------------------------------------- /testsuite/seed2/tests/cpp_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 2 3 | memory: 65536 4 | source: seed2.cpp 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/seed2/tests/java8_grace/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 2 3 | memory: 1 4 | source: seed2.java 5 | expect: MLE 6 | -------------------------------------------------------------------------------- /testsuite/seed2/tests/java_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 2 3 | memory: 65536 4 | source: seed2.java 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/seed2/tests/java_grace/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA 2 | time: 2 3 | memory: 1 4 | source: seed2.java 5 | expect: MLE 6 | -------------------------------------------------------------------------------- /testsuite/seed2/tests/java_mle/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 2 3 | memory: 65536 4 | source: seed2.java 5 | expect: MLE 6 | -------------------------------------------------------------------------------- /dmoj/utils/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | setbufsize_path = os.path.join(os.path.dirname(__file__), 'setbufsize.so') 4 | del os 5 | -------------------------------------------------------------------------------- /testsuite/aplusb/tests/java_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 10 3 | memory: 65536 4 | source: aplusb.java 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/batched/tests/py2_wa/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: allone.py 5 | cases: [AC, WA, SC] 6 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_flags/tests/py_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: ac.py 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_peg/tests/py_wa/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 1 3 | memory: 65536 4 | source: wa.py 5 | expect: WA 6 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_flags/init.yml: -------------------------------------------------------------------------------- 1 | interactive: {files: interactor.c, flags: [-DFLAG]} 2 | test_cases: 3 | - points: 20 4 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_multifile/init.yml: -------------------------------------------------------------------------------- 1 | interactive: {files: [interactor.c, header.h]} 2 | test_cases: 3 | - points: 20 4 | -------------------------------------------------------------------------------- /testsuite/check_memory_limit/tests/c_blank/test.yml: -------------------------------------------------------------------------------- 1 | language: C 2 | time: 2 3 | memory: 262144 4 | source: empty.c 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/coci_partial/tests/py_empty_ie/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 2 3 | memory: 65536 4 | source: ie.py 5 | expect: IE 6 | -------------------------------------------------------------------------------- /testsuite/coci_partial/tests/py_no_match_ie/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 2 3 | memory: 65536 4 | source: ie.py 5 | expect: IE 6 | -------------------------------------------------------------------------------- /testsuite/generator/tests/cpp_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 5 3 | memory: 65536 4 | source: aplusb.cpp 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/generator_test_ce/tests/cpp_ie/test.yml: -------------------------------------------------------------------------------- 1 | language: C 2 | time: 1 3 | memory: 65536 4 | source: test.c 5 | expect: IE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/bf_ce_bad_stack/test.yml: -------------------------------------------------------------------------------- 1 | language: BF 2 | time: 1 3 | memory: 64 4 | source: fail.b 5 | expect: CE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/c_signal_ir/test.yml: -------------------------------------------------------------------------------- 1 | language: C 2 | time: 1 3 | memory: 65536 4 | source: signal.c 5 | expect: IR 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/cpp_ole/test.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 5 3 | memory: 65536 4 | source: hello.cpp 5 | expect: OLE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/go_low_mem/test.yml: -------------------------------------------------------------------------------- 1 | language: GO 2 | time: 2 3 | memory: 8192 4 | source: helloworld.go 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java8_grace/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 2 3 | memory: 1 4 | source: grace.java 5 | expect: MLE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java_grace/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA 2 | time: 2 3 | memory: 1 4 | source: grace.java 5 | expect: MLE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/py2_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: helloworld.py 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/py2_wa/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: helloworld.py 5 | expect: WA 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/py3_grace/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 2 3 | memory: 1 4 | source: helloworld.py 5 | expect: MLE 6 | -------------------------------------------------------------------------------- /testsuite/interactive/tests/c_no_flush/test.posix.yml: -------------------------------------------------------------------------------- 1 | language: C 2 | time: 2 3 | memory: 65536 4 | source: ac.c 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/interactive/tests/java_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 2 3 | memory: 65536 4 | source: ac.java 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/mixed_str_int_cases/cases.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DMOJ/judge-server/HEAD/testsuite/mixed_str_int_cases/cases.zip -------------------------------------------------------------------------------- /testsuite/mixed_str_int_cases/tests/py_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 1 3 | memory: 65536 4 | source: ac.py 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/normalize/tests/cpp_echo/test.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 2 3 | memory: 65536 4 | source: nothing.cpp 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/aplusb/tests/cpp_macro_test/test.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 2 3 | memory: 65536 4 | source: cpp_ce.cpp 5 | expect: CE 6 | -------------------------------------------------------------------------------- /testsuite/batched/init.yml: -------------------------------------------------------------------------------- 1 | points: 1 2 | test_cases: 3 | - {out: a.out} 4 | - batched: 5 | - {out: b.out} 6 | - {out: a.out} -------------------------------------------------------------------------------- /testsuite/bridged_checker_multifile/tests/py_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: ac.py 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor/tests/cpp_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 2 3 | memory: 65536 4 | source: seed2.cpp 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor/tests/py2_tle/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 1 3 | memory: 65536 4 | source: seed2.py 5 | expect: TLE 6 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor/tests/tur_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: TUR 2 | time: 2 3 | memory: 65536 4 | source: seed2.tur 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_flags/tests/py_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: ac.py 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/coci_partial/tests/py_above_one_ie/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 2 3 | memory: 65536 4 | source: ie.py 5 | expect: IE 6 | -------------------------------------------------------------------------------- /testsuite/coci_partial/tests/py_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 2 3 | memory: 65536 4 | source: ac.py 5 | expect: AC 6 | score: 2 7 | -------------------------------------------------------------------------------- /testsuite/coci_partial/tests/py_div_by_zero_ie/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 2 3 | memory: 65536 4 | source: ie.py 5 | expect: IE 6 | -------------------------------------------------------------------------------- /testsuite/generator_multifile/tests/cpp_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 5 3 | memory: 65536 4 | source: aplusb.py 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/generator_python/tests/cpp_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 5 3 | memory: 65536 4 | source: aplusb.cpp 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/cpp_compiler_fmax_errors/hello.cpp: -------------------------------------------------------------------------------- 1 | template class a { a operator->(); }; 2 | a i = i->b; -------------------------------------------------------------------------------- /testsuite/helloworld/tests/py2_tle/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 0.25 3 | memory: 65536 4 | source: helloworld.py 5 | expect: TLE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/pypy3_grace/test.yml: -------------------------------------------------------------------------------- 1 | language: PYPY3 2 | time: 2 3 | memory: 1 4 | source: helloworld.py 5 | expect: MLE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/python_mle/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 8192 4 | source: helloworld.py 5 | expect: MLE 6 | -------------------------------------------------------------------------------- /testsuite/interactive/tests/py_ac/ac.py: -------------------------------------------------------------------------------- 1 | from sys import stdout 2 | print 0 3 | stdout.flush() 4 | print input() 5 | stdout.flush() 6 | -------------------------------------------------------------------------------- /testsuite/interactive/tests/py_no_flush/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: no_flush.py 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/seed2/tests/cpp_no_flush/test.posix.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 2 3 | memory: 65536 4 | source: seed2.cpp 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/shortest1/tests/custom_grader_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: forever.py 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/siggrade/tests/cpp_macro_test/siggrade.cpp: -------------------------------------------------------------------------------- 1 | #ifdef SIGNATURE_GRADER 2 | bool is_valid(int n) { return n == 1; } 3 | #endif 4 | -------------------------------------------------------------------------------- /testsuite/siggrade/tests/cpp_macro_test/test.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 2 3 | memory: 65536 4 | source: siggrade.cpp 5 | expect: AC 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "java_sandbox"] 2 | path = dmoj/executors/java_sandbox 3 | url = https://github.com/DMOJ/java-sandbox-agent.git 4 | -------------------------------------------------------------------------------- /testsuite/aplusb/tests/cpp_io_symlinks/test.posix.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 2 3 | memory: 65536 4 | source: aplusb.cpp 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_custom_args/tests/py_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 1 3 | memory: 65536 4 | source: ac.py 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_multifile/checker.c: -------------------------------------------------------------------------------- 1 | #include "header.h" 2 | 3 | #ifdef HEADER_EXISTS 4 | int main() { return 0; } 5 | #endif 6 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor/tests/java8_grace/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 2 3 | memory: 1 4 | source: seed2.java 5 | expect: MLE 6 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor/tests/java_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 2 3 | memory: 65536 4 | source: seed2.java 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_custom_args/tests/py_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 1 3 | memory: 65536 4 | source: ac.py 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_multifile/tests/py_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: ac.py 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/generator_custom_limits/tests/cpp_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 5 3 | memory: 65536 4 | source: aplusb.cpp 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/generator_pass_flags/tests/cpp_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 5 3 | memory: 65536 4 | source: aplusb.cpp 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/generator_test_sandbox/tests/cpp_ie/test.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 5 3 | memory: 65536 4 | source: aplusb.cpp 5 | expect: IE 6 | -------------------------------------------------------------------------------- /testsuite/generator_test_tle/init.yml: -------------------------------------------------------------------------------- 1 | generator: 2 | source: generator.cpp 3 | time_limit: 2 4 | test_cases: 5 | - {points: 10} 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/go_main_package/test.yml: -------------------------------------------------------------------------------- 1 | language: GO 2 | time: 2 3 | memory: 65536 4 | source: helloworld.go 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/go_not_main_package/test.yml: -------------------------------------------------------------------------------- 1 | language: GO 2 | time: 2 3 | memory: 65536 4 | source: helloworld.go 5 | expect: CE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/monocs_ac/test.posix.yml: -------------------------------------------------------------------------------- 1 | language: MONOCS 2 | time: 2 3 | memory: 65536 4 | source: helloworld.cs 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/monocs_grace/test.posix.yml: -------------------------------------------------------------------------------- 1 | language: MONOCS 2 | time: 2 3 | memory: 1 4 | source: helloworld.cs 5 | expect: MLE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_c_null_path/test.yml: -------------------------------------------------------------------------------- 1 | language: C 2 | time: 1 3 | memory: 65536 4 | source: nullpath.c 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/normalize/normalize.py: -------------------------------------------------------------------------------- 1 | def check(process_output, judge_output, judge_input, **kwargs): 2 | return judge_output == judge_input 3 | -------------------------------------------------------------------------------- /testsuite/sorted/tests/python_echo/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: echo.py 5 | cases: [AC, AC, AC, WA] 6 | -------------------------------------------------------------------------------- /testsuite/testlib_partial/tests/py_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: ac.py 5 | expect: AC 6 | score: 5 7 | -------------------------------------------------------------------------------- /dmoj/cptbox/ext_linux.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | inline long ptrace_traceme() { 4 | return ptrace(PTRACE_TRACEME, 0, NULL, NULL); 5 | } -------------------------------------------------------------------------------- /testsuite/bridged_checker_peg/tests/py_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 1 3 | memory: 65536 4 | source: ac.py 5 | expect: AC 6 | points: 10 7 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor/seed2_abridged.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DMOJ/judge-server/HEAD/testsuite/bridged_interactor/seed2_abridged.zip -------------------------------------------------------------------------------- /testsuite/bridged_interactor/tests/py2_closes_pipes/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: seed2.py 5 | expect: WA 6 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_multifile/interactor.c: -------------------------------------------------------------------------------- 1 | #include "header.h" 2 | 3 | #ifdef HEADER_EXISTS 4 | int main() { return 0; } 5 | #endif 6 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_noflush/tests/cpp_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 2 3 | memory: 65536 4 | source: seed2.cpp 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_noflush/tests/py2_tle/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 1 3 | memory: 65536 4 | source: seed2.py 5 | expect: TLE 6 | -------------------------------------------------------------------------------- /testsuite/coci_partial/tests/py_garbage_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 2 3 | memory: 65536 4 | source: ac.py 5 | expect: AC 6 | score: 1 7 | -------------------------------------------------------------------------------- /testsuite/easy/tests/python_echo/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: echo.py 5 | cases: [AC,AC,AC,AC,AC,WA] 6 | 7 | -------------------------------------------------------------------------------- /testsuite/floats/tests/python_echo/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: echo.py 5 | cases: [AC,AC,WA,WA,WA,AC,WA] 6 | -------------------------------------------------------------------------------- /testsuite/generator_test_ce/tests/cpp_ie/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() { 3 | puts("This should not run"); 4 | return 0; 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/generator_test_mle/init.yml: -------------------------------------------------------------------------------- 1 | generator: 2 | source: generator.cpp 3 | memory_limit: 65536 4 | test_cases: 5 | - {points: 10} 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/cpp_ole/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | while (1) 5 | putchar('a'); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/cpp_wall_clock/test.posix.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 2 3 | memory: 65536 4 | source: stall.cpp 5 | expect: TLE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java_final_class/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 2 3 | memory: 65536 4 | source: final_class.java 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/monocs_mle/test.posix.yml: -------------------------------------------------------------------------------- 1 | language: MONOCS 2 | time: 2 3 | memory: 8192 4 | source: helloworld.cs 5 | expect: MLE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_c_format_open/test.yml: -------------------------------------------------------------------------------- 1 | language: C 2 | time: 1 3 | memory: 65536 4 | source: format_open.c 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_c_nametoolong/test.yml: -------------------------------------------------------------------------------- 1 | language: C 2 | time: 1 3 | memory: 65536 4 | source: nametoolong.c 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/siggrade/tests/cpp_signature_grading/test.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 2 3 | memory: 65536 4 | source: sigtest.cpp 5 | expect: AC 6 | -------------------------------------------------------------------------------- /dmoj/cptbox/syscalls/aliases.list: -------------------------------------------------------------------------------- 1 | sysctl _sysctl 2 | sgetmask siggetmask 3 | ssetmask sigsetmask 4 | restart_syscall setup 5 | rt_sigaction sigaction 6 | -------------------------------------------------------------------------------- /testsuite/batch_dependencies/tests/python_ac_all/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 2 3 | memory: 65536 4 | source: echo.py 5 | cases: [AC, AC, AC, AC] 6 | -------------------------------------------------------------------------------- /testsuite/batch_short_circuit/tests/python_ac_batch/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: echo.py 5 | cases: [AC, AC, WA] 6 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_peg/tests/py_partial_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 1 3 | memory: 65536 4 | source: ac.py 5 | expect: AC 6 | points: 1 7 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor/tests/cpp_no_flush/test.posix.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 2 3 | memory: 65536 4 | source: seed2.cpp 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_noflush/tests/py2_closes_pipes/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: seed2.py 5 | expect: WA 6 | -------------------------------------------------------------------------------- /testsuite/check_memory_limit/tests/cpp_too_much_memory/test.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 2 3 | memory: 262144 4 | source: bloat.cpp 5 | expect: WA 6 | -------------------------------------------------------------------------------- /testsuite/coci_partial/tests/py_lower_bound_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 2 3 | memory: 65536 4 | source: ac.py 5 | expect: AC 6 | score: 0 7 | -------------------------------------------------------------------------------- /testsuite/coci_partial/tests/py_upper_bound_ac/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 2 3 | memory: 65536 4 | source: ac.py 5 | expect: AC 6 | score: 10 7 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/cpp_compile_tle/test.linux.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 2 3 | memory: 65536 4 | source: helloworld.cpp 5 | expect: CE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java8_ce_name_too_long/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 2 3 | memory: 65536 4 | source: helloworld.java 5 | expect: CE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java8_ce_with_package/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 2 3 | memory: 65536 4 | source: helloworld.java 5 | expect: CE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java_abstract_class/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 2 3 | memory: 65536 4 | source: abstract_class.java 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java_strictfp_class/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 2 3 | memory: 65536 4 | source: strictfp_class.java 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/py2_ir_raise_SyntaxError/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: helloworld.py 5 | expect: IR 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_c_bad_unicode_open/test.yml: -------------------------------------------------------------------------------- 1 | language: C 2 | time: 1 3 | memory: 65536 4 | source: bad_unicode.c 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/scroll/tests/c_rte_protection_fault_freebsd/test.freebsd.yml: -------------------------------------------------------------------------------- 1 | language: C 2 | time: 2 3 | memory: 65536 4 | source: scroll.c 5 | expect: RTE 6 | -------------------------------------------------------------------------------- /testsuite/scroll/tests/c_rte_protection_fault_linux/test.linux.yml: -------------------------------------------------------------------------------- 1 | language: C 2 | time: 2 3 | memory: 65536 4 | source: scroll.c 5 | expect: RTE 6 | -------------------------------------------------------------------------------- /testsuite/batch_dependencies/tests/python_pass_one/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 2 3 | memory: 65536 4 | source: allone.py 5 | cases: [AC, WA, SC, AC] 6 | -------------------------------------------------------------------------------- /testsuite/batch_dependencies/tests/python_pass_two/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 2 3 | memory: 65536 4 | source: alltwo.py 5 | cases: [WA, AC, SC, WA] 6 | -------------------------------------------------------------------------------- /testsuite/batch_short_circuit/tests/python_wa_batch/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: allone.py 5 | cases: [WA, SC, SC] 6 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_noflush/tests/cpp_no_flush/test.posix.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 2 3 | memory: 65536 4 | source: seed2.cpp 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/go_low_mem/helloworld.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("Hello, World!") 7 | } 8 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java_no_public_class/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 2 3 | memory: 65536 4 | source: no_public_class.java 5 | expect: CE 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_nasm_kill_judge/test.linux.yml: -------------------------------------------------------------------------------- 1 | language: NASM 2 | time: 1 3 | memory: 65536 4 | source: kill_judge.asm 5 | expect: IR 6 | -------------------------------------------------------------------------------- /testsuite/interactive/init.yml: -------------------------------------------------------------------------------- 1 | custom_judge: interact.py 2 | unbuffered: yes 3 | test_cases: 4 | - {in: 1.in, points: 10} 5 | - {in: 2.in, points: 10} 6 | -------------------------------------------------------------------------------- /testsuite/interactive/tests/py_not_num/not_num.py: -------------------------------------------------------------------------------- 1 | from sys import stdout 2 | print 'A number, this is not. Yet crash, you should not.' 3 | stdout.flush() 4 | -------------------------------------------------------------------------------- /testsuite/siggrade/header.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRADER_HEADER_INCLUDED 2 | #define _GRADER_HEADER_INCLUDED 3 | #include 4 | bool is_valid(int); 5 | #endif -------------------------------------------------------------------------------- /dmoj/__main__.py: -------------------------------------------------------------------------------- 1 | from dmoj.judge import main 2 | 3 | if __name__ == '__main__': 4 | import sys 5 | 6 | sys.argv[0] = 'python -m dmoj' 7 | main() 8 | -------------------------------------------------------------------------------- /testsuite/bridged_checker/tests/py_pe/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: pe.py 5 | expect: WA 6 | feedback: Presentation Error 7 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_noflush/seed2_abridged.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DMOJ/judge-server/HEAD/testsuite/bridged_interactor_noflush/seed2_abridged.zip -------------------------------------------------------------------------------- /testsuite/generator/init.yml: -------------------------------------------------------------------------------- 1 | generator: generator.cpp 2 | test_cases: 3 | - {in: 1.in, points: 10} 4 | - {in: 2.in, points: 10} 5 | - {in: 3.in, points: 30} 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java8_ir_throw_RuntimeException/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 2 3 | memory: 65536 4 | source: helloworld.java 5 | expect: IR 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_nasm64_kill_judge/test.linux.yml: -------------------------------------------------------------------------------- 1 | language: NASM64 2 | time: 1 3 | memory: 65536 4 | source: kill_judge.asm 5 | expect: IR 6 | -------------------------------------------------------------------------------- /testsuite/normalize/init.yml: -------------------------------------------------------------------------------- 1 | checker: normalize.py 2 | test_cases: 3 | - {in: in1.txt, out: out.txt, points: 1} 4 | - {in: in2.txt, out: out.txt, points: 1} 5 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java_final_strictfp_class/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 2 3 | memory: 65536 4 | source: final_strictfp_class.java 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/rust_generator/tests/AC/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | required_auxiliary_executors: [RUST] 3 | time: 2 4 | memory: 65536 5 | source: sol.py 6 | expect: AC 7 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_custom_args/check.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | if sys.argv[1] == "The arguments": 4 | raise SystemExit(0) 5 | else: 6 | raise SystemExit(1) 7 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java_strictfp_abstract_class/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 2 3 | memory: 65536 4 | source: strictfp_abstract_class.java 5 | expect: AC 6 | -------------------------------------------------------------------------------- /testsuite/interactive/tests/py_not_num/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: not_num.py 5 | expect: WA 6 | feedback: expected int, got "A" 7 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_custom_args/interact.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | if sys.argv[1] == "The arguments": 4 | raise SystemExit(0) 5 | else: 6 | raise SystemExit(1) 7 | -------------------------------------------------------------------------------- /testsuite/coci_partial/init.yml: -------------------------------------------------------------------------------- 1 | checker: 2 | name: bridged 3 | args: 4 | files: checker.cpp 5 | lang: CPP14 6 | type: coci 7 | test_cases: 8 | - points: 10 9 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/cpp_compiler_ole/test.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 1 3 | memory: 1024 4 | source: hello.cpp 5 | expect: CE 6 | feedback: compiler output too long 7 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_c_null_path_noat/test.linux.yml: -------------------------------------------------------------------------------- 1 | language: C 2 | time: 1 3 | memory: 16384 4 | source: nullpath.c 5 | expect: AC 6 | arch: [x86, amd64, arm] 7 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_py3_bad_file/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 2 3 | memory: 65536 4 | source: helloworld.py 5 | expect: IR 6 | feedback: PermissionError 7 | -------------------------------------------------------------------------------- /testsuite/interactive/tests/c_no_flush/ac.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { 4 | int n; 5 | puts("0"); 6 | scanf("%d", &n); 7 | printf("%d\n", n); 8 | } 9 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_multifile/init.yml: -------------------------------------------------------------------------------- 1 | checker: 2 | name: bridged 3 | args: 4 | files: [checker.c, header.h] 5 | lang: C 6 | test_cases: 7 | - points: 10 8 | 9 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor/tests/py2_presentation_error/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: seed2.py 5 | expect: WA 6 | feedback: Presentation Error 7 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_not_contrib_module/init.yml: -------------------------------------------------------------------------------- 1 | interactive: 2 | files: interact.py 3 | lang: PY3 4 | type: not-a-contrib-module 5 | test_cases: 6 | - {points: 100} 7 | -------------------------------------------------------------------------------- /testsuite/generator_test_mle/generator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { return (new int[512][512][512])[0][0][0]; } 7 | -------------------------------------------------------------------------------- /testsuite/generator_test_mle/tests/cpp_ie/test.posix.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 5 3 | memory: 65536 4 | source: aplusb.cpp 5 | expect: IE 6 | feedback: 'generator exited with' 7 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java8_grace/grace.java: -------------------------------------------------------------------------------- 1 | public class grace { 2 | public static void main(String[] args) { 3 | System.out.println("Hello, World!"); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java_grace/grace.java: -------------------------------------------------------------------------------- 1 | public class grace { 2 | public static void main(String[] args) { 3 | System.out.println("Hello, World!"); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/monocs_oom/test.posix.yml: -------------------------------------------------------------------------------- 1 | language: MONOCS 2 | time: 2 3 | memory: 65536 4 | source: oom.cs 5 | expect: IR 6 | feedback: 'System.OutOfMemoryException' 7 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_c_nametoolong_noat/test.linux.yml: -------------------------------------------------------------------------------- 1 | language: C 2 | time: 1 3 | memory: 16384 4 | source: nametoolong.c 5 | expect: AC 6 | arch: [x86, amd64, arm] 7 | -------------------------------------------------------------------------------- /testsuite/interactive/tests/pas_ac/ac.pas: -------------------------------------------------------------------------------- 1 | var 2 | a:longint; 3 | 4 | begin 5 | writeln(0); 6 | flush(Output); 7 | readln(a); 8 | writeln(a); 9 | end. 10 | -------------------------------------------------------------------------------- /testsuite/interactive/tests/py_wa/wa.py: -------------------------------------------------------------------------------- 1 | from sys import stdout 2 | print 0 3 | stdout.flush() 4 | N = input() 5 | for i in xrange(1, N + 1): 6 | print i 7 | stdout.flush() 8 | -------------------------------------------------------------------------------- /testsuite/seed2/tests/java_ir/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 2 3 | memory: 65536 4 | source: seed2.java 5 | expect: IR 6 | feedback: java.lang.ArrayIndexOutOfBoundsException 7 | -------------------------------------------------------------------------------- /testsuite/testlib_partial/checker.cpp: -------------------------------------------------------------------------------- 1 | #include "testlib.h" 2 | 3 | int main(int argc, char *argv[]) { 4 | registerTestlibCmd(argc, argv); 5 | quitp(_pc(5 - 16), ""); 6 | } 7 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_custom_args/init.yml: -------------------------------------------------------------------------------- 1 | interactive: 2 | files: interact.py 3 | args_format_string: '"The arguments"' 4 | lang: PY3 5 | test_cases: 6 | - {points: 100} 7 | -------------------------------------------------------------------------------- /testsuite/generator_test_tle/tests/cpp_ie/test.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 5 3 | memory: 65536 4 | source: aplusb.cpp 5 | expect: IE 6 | feedback: 'generator timed out (> 2 seconds)' 7 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_c_bad_unicode_open_noat/test.linux.yml: -------------------------------------------------------------------------------- 1 | language: C 2 | time: 1 3 | memory: 16384 4 | source: bad_unicode.c 5 | expect: AC 6 | arch: [x86, amd64, arm] 7 | -------------------------------------------------------------------------------- /testsuite/seed2/tests/java_ir/seed2.java: -------------------------------------------------------------------------------- 1 | public class Seed2 { 2 | public static void main(String[] args) { 3 | int[] arr = new int[1]; 4 | arr[1] = 1; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /testsuite/aplusb/tests/java_bigdecimal/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 5 3 | memory: 65535 4 | source: aplusb.java 5 | expect: IR 6 | feedback: ca.dmoj.java.BigDecimalDisallowedException 7 | -------------------------------------------------------------------------------- /testsuite/aplusb/tests/java_biginteger/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 5 3 | memory: 65535 4 | source: aplusb.java 5 | expect: IR 6 | feedback: ca.dmoj.java.BigIntegerDisallowedException 7 | -------------------------------------------------------------------------------- /testsuite/batch_short_circuit/init.yml: -------------------------------------------------------------------------------- 1 | test_cases: 2 | - batched: 3 | - {in: 2.txt, out: 2.txt} 4 | - {in: 1.txt, out: 1.txt} 5 | points: 0 6 | - {in: 2.txt, out: 1.txt, points: 5} 7 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java_unsafe/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 5 3 | memory: 65535 4 | source: HelloWorld.java 5 | expect: IR 6 | feedback: ca.dmoj.java.UnsafeDisallowedException 7 | -------------------------------------------------------------------------------- /testsuite/seed2/init.yml: -------------------------------------------------------------------------------- 1 | custom_judge: seed2.py 2 | unbuffered: true 3 | archive: seed2_abridged.zip 4 | test_cases: 5 | - {in: seed2.1.in, points: 20} 6 | - {in: seed2.2.in, points: 20} 7 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_flags/init.yml: -------------------------------------------------------------------------------- 1 | checker: 2 | name: bridged 3 | args: 4 | files: checker.c 5 | lang: C 6 | flags: [-DFLAG] 7 | test_cases: 8 | - points: 10 9 | 10 | -------------------------------------------------------------------------------- /testsuite/generator_python/gen.py2: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import sys 3 | 4 | A = int(sys.argv[1]) 5 | B = int(sys.argv[2]) 6 | print(A, B) 7 | print(A + B, file=sys.stderr) 8 | -------------------------------------------------------------------------------- /testsuite/generator_test_tle/generator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | for (;;) 8 | ; 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java8_unicode_class/helloworld.java: -------------------------------------------------------------------------------- 1 | public class нет { 2 | public static void main(String[] args){ 3 | System.out.println("Hello, World!"); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/rust_generator/init.yml: -------------------------------------------------------------------------------- 1 | generator: generator.rs 2 | test_cases: 3 | - {generator_args: [1], points: 10} 4 | - {generator_args: [2], points: 10} 5 | - {generator_args: [3], points: 30} 6 | -------------------------------------------------------------------------------- /testsuite/testlib_partial/init.yml: -------------------------------------------------------------------------------- 1 | checker: 2 | name: bridged 3 | args: 4 | files: [checker.cpp, testlib.h] 5 | lang: CPP11 6 | type: testlib 7 | test_cases: 8 | - points: 10 9 | -------------------------------------------------------------------------------- /testsuite/binary_data/tests/c_echo/echo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int c = getchar(); 5 | while (c != EOF) { 6 | putchar(c); 7 | c = getchar(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java_final_class/final_class.java: -------------------------------------------------------------------------------- 1 | public final class final_class { 2 | public static void main(String[] args) { 3 | System.out.println("Hello, World!"); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java_no_public_class/no_public_class.java: -------------------------------------------------------------------------------- 1 | class no_public_class { 2 | public static void main(String[] args) { 3 | System.out.println("Hello, World!"); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/interactive/tests/c_ac/ac.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { 4 | int n; 5 | puts("0"); 6 | fflush(stdout); 7 | scanf("%d", &n); 8 | printf("%d\n", n); 9 | } 10 | -------------------------------------------------------------------------------- /testsuite/bridged_checker/init.yml: -------------------------------------------------------------------------------- 1 | checker: 2 | name: bridged 3 | args: 4 | files: checker.c 5 | lang: C 6 | feedback: true 7 | type: testlib 8 | test_cases: 9 | - points: 10 10 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_peg/init.yml: -------------------------------------------------------------------------------- 1 | checker: 2 | name: bridged 3 | args: 4 | files: check.cpp 5 | lang: CPP11 6 | type: peg 7 | test_cases: 8 | - {in: in.txt, out: out.txt, points: 10} 9 | -------------------------------------------------------------------------------- /testsuite/generator_python/init.yml: -------------------------------------------------------------------------------- 1 | generator: gen.py2 2 | test_cases: 3 | - {generator_args: [1, 2], points: 1} 4 | - {generator_args: [10, 20], points: 1} 5 | - {generator_args: [100, 200], points: 1} 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/cpp_compiler_fmax_errors/test.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 1 3 | memory: 1024 4 | source: hello.cpp 5 | expect: CE 6 | feedback: compilation terminated due to -fmax-errors= 7 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java8_ir_throw_RuntimeException/helloworld.java: -------------------------------------------------------------------------------- 1 | public class helloworld { 2 | public static void main(String[] argv) { 3 | throw new RuntimeException(); 4 | } 5 | } -------------------------------------------------------------------------------- /testsuite/bridged_checker_not_contrib_module/init.yml: -------------------------------------------------------------------------------- 1 | checker: 2 | name: bridged 3 | args: 4 | files: check.py 5 | lang: PY3 6 | type: not-a-contrib-module 7 | test_cases: 8 | - {points: 100} 9 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_not_contrib_module/tests/py_ie/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 1 3 | memory: 65536 4 | source: ie.py 5 | expect: IE 6 | feedback: 'not-a-contrib-module is not a valid contrib module' 7 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_custom_args/init.yml: -------------------------------------------------------------------------------- 1 | checker: 2 | name: bridged 3 | args: 4 | files: check.py 5 | args_format_string: '"The arguments"' 6 | lang: PY3 7 | test_cases: 8 | - {points: 100} 9 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_not_contrib_module/tests/py_ie/test.yml: -------------------------------------------------------------------------------- 1 | language: PY3 2 | time: 1 3 | memory: 65536 4 | source: ie.py 5 | expect: IE 6 | feedback: 'not-a-contrib-module is not a valid contrib module' 7 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/cpp_badalloc/test.linux.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 1 3 | memory: 4096 4 | source: badalloc.cpp 5 | expect: [RTE, MLE] 6 | feedback: 7 | - std::bad_alloc 8 | - std::bad_array_new_length 9 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java8_ir_no_entry_point/helloworld.java: -------------------------------------------------------------------------------- 1 | public class helloworld { 2 | public static void not_main(String[] argv) { 3 | System.out.println("Hello, World!"); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java8_ir_no_entry_point/test.yml: -------------------------------------------------------------------------------- 1 | language: JAVA8 2 | time: 2 3 | memory: 65536 4 | source: helloworld.java 5 | expect: IR 6 | feedback: public static void main(String[] args) not found 7 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java_abstract_class/abstract_class.java: -------------------------------------------------------------------------------- 1 | public abstract class abstract_class { 2 | public static void main(String[] args) { 3 | System.out.println("Hello, World!"); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java_strictfp_class/strictfp_class.java: -------------------------------------------------------------------------------- 1 | public strictfp class strictfp_class { 2 | public static void main(String[] args) { 3 | System.out.println("Hello, World!"); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/go_main_package/helloworld.go: -------------------------------------------------------------------------------- 1 | // Test for line comment 2 | package /* Test for inline comment */ main 3 | 4 | import "fmt" 5 | 6 | func main() { 7 | fmt.Println("Hello, World!") 8 | } 9 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java8_ce_with_package/helloworld.java: -------------------------------------------------------------------------------- 1 | package ca.dmoj; 2 | 3 | public class helloworld { 4 | public static void main(String[] argv) { 5 | throw new RuntimeException(); 6 | } 7 | } -------------------------------------------------------------------------------- /testsuite/mixed_str_int_cases/init.yml: -------------------------------------------------------------------------------- 1 | archive: cases.zip 2 | test_cases: 3 | input_format: ((?P\w+)\.)?(?P\d+)\.in 4 | output_format: ((?P\w+)\.)?(?P\d+)\.out 5 | case_points: [0, 1] 6 | -------------------------------------------------------------------------------- /testsuite/siggrade/init.yml: -------------------------------------------------------------------------------- 1 | signature_grader: {entry: handler.c, header: header.h} 2 | test_cases: 3 | - {in: siggrade.1.in, out: siggrade.1.out, points: 50} 4 | - {in: siggrade.2.in, out: siggrade.2.out, points: 50} 5 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/go_not_main_package/helloworld.go: -------------------------------------------------------------------------------- 1 | // Test for line comment 2 | package /* Test for inline comment */ notmain 3 | 4 | import "fmt" 5 | 6 | func main() { 7 | fmt.Println("Hello, World!") 8 | } 9 | -------------------------------------------------------------------------------- /testsuite/sorted/init.yml: -------------------------------------------------------------------------------- 1 | checker: sorted 2 | test_cases: 3 | - {in: 1.txt, out: 1.txt, points: 1} 4 | - {in: 1.txt, out: 2.txt, points: 1} 5 | - {in: 3.txt, out: 3.txt, points: 1} 6 | - {in: 3.txt, out: 4.txt, points: 1} 7 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools", "wheel", "Cython"] 3 | 4 | [tool.black] 5 | line-length = 120 6 | skip-string-normalization = true # Black prefers double-quotes 7 | extend-exclude = '^/testsuite/' 8 | -------------------------------------------------------------------------------- /testsuite/binary_data/init.yml: -------------------------------------------------------------------------------- 1 | binary_data: True 2 | generator: gen.c 3 | checker: identical 4 | test_cases: 5 | - {points: 10, generator_args: [1]} 6 | - {points: 10, generator_args: [2]} 7 | - {points: 10, generator_args: [3]} 8 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor/init.yml: -------------------------------------------------------------------------------- 1 | unbuffered: true 2 | archive: seed2_abridged.zip 3 | interactive: {files: interactor.cpp, type: testlib} 4 | test_cases: 5 | - {in: seed2.1.in, points: 20} 6 | - {in: seed2.2.in, points: 20} 7 | -------------------------------------------------------------------------------- /testsuite/generator_python/tests/cpp_ac/aplusb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int a, b; 7 | scanf("%d %d", &a, &b); 8 | printf("%d\n", a + b); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/monocs_ac/helloworld.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class HelloWorld 4 | { 5 | public static void Main(string[] args) 6 | { 7 | Console.WriteLine("Hello, World!"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/monocs_mle/helloworld.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class HelloWorld 4 | { 5 | public static void Main(string[] args) 6 | { 7 | Console.WriteLine("Hello, World!"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /testsuite/linecount/init.yml: -------------------------------------------------------------------------------- 1 | checker: 2 | name: linecount 3 | args: {feedback: True} 4 | test_cases: 5 | - {in: 1.txt, out: 1.txt, points: 1} 6 | - {in: 2.txt, out: 1.txt, points: 1} 7 | - {in: 3.txt, out: 1.txt, points: 1} 8 | -------------------------------------------------------------------------------- /testsuite/rust_bridged/init.yml: -------------------------------------------------------------------------------- 1 | checker: 2 | args: 3 | cached: true 4 | feedback: true 5 | files: checker.rs 6 | lang: RUST 7 | type: coci 8 | name: bridged 9 | test_cases: 10 | - {} 11 | - {} 12 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/monocs_grace/helloworld.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | class HelloWorld 4 | { 5 | public static void Main(string[] args) 6 | { 7 | Console.WriteLine("Hello, World!"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_noflush/init.yml: -------------------------------------------------------------------------------- 1 | unbuffered: true 2 | archive: seed2_abridged.zip 3 | interactive: {files: interactor.cpp, type: testlib} 4 | test_cases: 5 | - {in: seed2.1.in, points: 20} 6 | - {in: seed2.2.in, points: 20} 7 | -------------------------------------------------------------------------------- /testsuite/generator_custom_limits/init.yml: -------------------------------------------------------------------------------- 1 | generator: 2 | source: generator.cpp 3 | time_limit: 5 4 | memory_limit: 65536 5 | test_cases: 6 | - {in: 1.in, points: 10} 7 | - {in: 2.in, points: 10} 8 | - {in: 3.in, points: 30} 9 | -------------------------------------------------------------------------------- /testsuite/generator_pass_flags/init.yml: -------------------------------------------------------------------------------- 1 | generator: 2 | source: generator.cpp 3 | flags: [-DFLAG] 4 | test_cases: 5 | - {generator_args: [1], points: 10} 6 | - {generator_args: [2], points: 10} 7 | - {generator_args: [3], points: 30} 8 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/c_failinit/test.linux.yml: -------------------------------------------------------------------------------- 1 | language: C 2 | time: 1 3 | memory: 1024 4 | source: fail.c 5 | expect: [RTE, MLE] 6 | feedback: ['', 'failed initializing', 'segmentation fault'] # '' temporary workaround, see #1149 7 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/cpp_badalloc/test.freebsd.yml: -------------------------------------------------------------------------------- 1 | language: CPP11 2 | time: 1 3 | memory: 4096 4 | source: badalloc.cpp 5 | expect: [RTE, MLE] 6 | feedback: 7 | - std::bad_alloc 8 | - std::bad_array_new_length 9 | - '' 10 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java_final_strictfp_class/final_strictfp_class.java: -------------------------------------------------------------------------------- 1 | public final strictfp class final_strictfp_class { 2 | public static void main(String[] args) { 3 | System.out.println("Hello, World!"); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java8_unicode_class/test.posix.yml: -------------------------------------------------------------------------------- 1 | # On Windows systems, Java cannot load classes with Unicode names from the command line 2 | 3 | language: JAVA8 4 | time: 2 5 | memory: 65536 6 | source: helloworld.java 7 | expect: AC 8 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java_strictfp_abstract_class/strictfp_abstract_class.java: -------------------------------------------------------------------------------- 1 | public strictfp abstract class strictfp_abstract_class { 2 | public static void main(String[] args) { 3 | System.out.println("Hello, World!"); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /dmoj/cptbox/ptdebug_x86.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef id198d0986_429f_4748_b77b_d50bbfd77289 3 | #define id198d0986_429f_4748_b77b_d50bbfd77289 4 | 5 | #include 6 | 7 | typedef struct user_regs_struct ptbox_regs; 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /dmoj/executors/__main__.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors import load_executors 2 | from dmoj.judgeenv import load_env 3 | 4 | 5 | def main(): 6 | load_env(cli=True) 7 | load_executors() 8 | 9 | 10 | if __name__ == '__main__': 11 | main() 12 | -------------------------------------------------------------------------------- /testsuite/aplusb/tests/pas_ac/aplusb.pas: -------------------------------------------------------------------------------- 1 | program aplusb; 2 | 3 | var 4 | n, i : longint; 5 | a, b : longint; 6 | 7 | begin 8 | readln (n); 9 | for i := 1 to n do 10 | begin 11 | readln (a,b); 12 | writeln (a+b); 13 | end; 14 | 15 | end. -------------------------------------------------------------------------------- /dmoj/checkers/floatsabs.py: -------------------------------------------------------------------------------- 1 | from dmoj.checkers.floats import check as floats_check 2 | 3 | 4 | def check(process_output: bytes, judge_output: bytes, **kwargs) -> bool: 5 | return floats_check(process_output, judge_output, error_mode='absolute', **kwargs) 6 | -------------------------------------------------------------------------------- /dmoj/checkers/floatsrel.py: -------------------------------------------------------------------------------- 1 | from dmoj.checkers.floats import check as floats_check 2 | 3 | 4 | def check(process_output: bytes, judge_output: bytes, **kwargs) -> bool: 5 | return floats_check(process_output, judge_output, error_mode='relative', **kwargs) 6 | -------------------------------------------------------------------------------- /testsuite/scroll/tests/c_rte_protection_fault_freebsd/scroll.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() { 6 | if (reboot(RB_HALT) == -1) { 7 | perror("reboot"); 8 | } 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /testsuite/easy/init.yml: -------------------------------------------------------------------------------- 1 | checker: easy 2 | test_cases: 3 | - {in: out.txt, out: out.txt, points: 1} 4 | - {in: 1.in, out: out.txt, points: 1} 5 | - {in: 2.in, out: out.txt, points: 1} 6 | - {in: 3.in, out: out.txt, points: 1} 7 | - {in: 4.in, out: out.txt, points: 1} 8 | -------------------------------------------------------------------------------- /testsuite/check_memory_limit/tests/cpp_too_much_memory/bloat.cpp: -------------------------------------------------------------------------------- 1 | #pragma GCC optimize "O0" 2 | 3 | const int MN = 100 * 1024 * 1024; 4 | char arr[MN]; 5 | 6 | int main() { 7 | for (int i = 0; i < MN; ++i) 8 | arr[i] = ' '; 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /testsuite/scroll/tests/c_rte_protection_fault_linux/scroll.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() { 6 | if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) == -1) { 7 | perror("ptrace"); 8 | } 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /testsuite/siggrade/handler.c: -------------------------------------------------------------------------------- 1 | #include "header.h" 2 | #include 3 | #include 4 | 5 | int main() { 6 | int n; 7 | scanf("%d", &n); 8 | bool valid = is_valid(n); // Defined in header 9 | printf(valid ? "correct" : "wrong"); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /dmoj/commands/quit.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | from dmoj.commands.base_command import Command 4 | 5 | 6 | class QuitCommand(Command): 7 | name = 'quit' 8 | help = 'Exits the DMOJ command-line interface.' 9 | 10 | def execute(self, line: str) -> None: 11 | sys.exit(0) 12 | -------------------------------------------------------------------------------- /dmoj/graders/__init__.py: -------------------------------------------------------------------------------- 1 | from dmoj.graders.bridged import BridgedInteractiveGrader 2 | from dmoj.graders.custom import CustomGrader 3 | from dmoj.graders.interactive import InteractiveGrader 4 | from dmoj.graders.signature import SignatureGrader 5 | from dmoj.graders.standard import StandardGrader 6 | -------------------------------------------------------------------------------- /testsuite/generator/tests/cpp_ac/aplusb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int N; 7 | scanf("%d", &N); 8 | 9 | while (N--) { 10 | int a, b; 11 | scanf("%d %d", &a, &b); 12 | printf("%d\n", a + b); 13 | } 14 | return 0; 15 | } -------------------------------------------------------------------------------- /testsuite/generator_test_mle/tests/cpp_ie/aplusb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int N; 7 | scanf("%d", &N); 8 | 9 | while (N--) { 10 | int a, b; 11 | scanf("%d %d", &a, &b); 12 | printf("%d\n", a + b); 13 | } 14 | return 0; 15 | } -------------------------------------------------------------------------------- /testsuite/generator_test_tle/tests/cpp_ie/aplusb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int N; 7 | scanf("%d", &N); 8 | 9 | while (N--) { 10 | int a, b; 11 | scanf("%d %d", &a, &b); 12 | printf("%d\n", a + b); 13 | } 14 | return 0; 15 | } -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include MANIFEST.in 2 | include dmoj/cptbox/*.cpp 3 | include dmoj/cptbox/*.h 4 | include dmoj/cptbox/syscalls/aliases.list 5 | include dmoj/cptbox/syscalls/*.tbl 6 | include dmoj/executors/*.policy 7 | include dmoj/executors/java_sandbox.jar 8 | 9 | exclude dmoj/cptbox/_cptbox.pyx 10 | -------------------------------------------------------------------------------- /testsuite/generator_custom_limits/tests/cpp_ac/aplusb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int N; 7 | scanf("%d", &N); 8 | 9 | while (N--) { 10 | int a, b; 11 | scanf("%d %d", &a, &b); 12 | printf("%d\n", a + b); 13 | } 14 | return 0; 15 | } -------------------------------------------------------------------------------- /testsuite/generator_pass_flags/tests/cpp_ac/aplusb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int N; 7 | scanf("%d", &N); 8 | 9 | while (N--) { 10 | int a, b; 11 | scanf("%d %d", &a, &b); 12 | printf("%d\n", a + b); 13 | } 14 | return 0; 15 | } -------------------------------------------------------------------------------- /testsuite/generator_test_sandbox/tests/cpp_ie/aplusb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int N; 7 | scanf("%d", &N); 8 | 9 | while (N--) { 10 | int a, b; 11 | scanf("%d %d", &a, &b); 12 | printf("%d\n", a + b); 13 | } 14 | return 0; 15 | } -------------------------------------------------------------------------------- /dmoj/utils/pyyaml_patch.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | import yaml.reader 4 | 5 | if yaml.reader.Reader.NON_PRINTABLE.pattern == '[^\t\n\r -~\x85\xa0-\ud7ff\ue000-\ufffd]': 6 | yaml.reader.Reader.NON_PRINTABLE = re.compile( 7 | '[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD\U00010000-\U0010FFFF]' 8 | ) 9 | -------------------------------------------------------------------------------- /testsuite/interactive/tests/java_ac/ac.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class ac { 3 | public static void main(String[]args) { 4 | Scanner S = new Scanner(System.in); 5 | System.out.println(0); 6 | System.out.flush(); 7 | System.out.println(S.nextInt()); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /testsuite/aplusb/init.yml: -------------------------------------------------------------------------------- 1 | archive: aplusb.zip 2 | 3 | symlinks: { 4 | in_link: /dev/stdin 5 | } 6 | 7 | hints: [nobigmath] 8 | 9 | test_cases: 10 | - {in: aplusb.1.in, out: aplusb.1.out, points: 5} 11 | - {in: aplusb.2.in, out: aplusb.2.out, points: 20} 12 | - {in: aplusb.3.in, out: aplusb.3.out, points: 75} 13 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_nasm64_kill_judge/kill_judge.asm: -------------------------------------------------------------------------------- 1 | section .text 2 | global _start 3 | 4 | _start: 5 | mov rax, 110 6 | syscall 7 | 8 | mov rdi, rax 9 | mov rsi, 24 10 | mov rax, 62 11 | syscall 12 | 13 | mov rdi, rax 14 | mov rax, 231 15 | syscall 16 | 17 | -------------------------------------------------------------------------------- /testsuite/linecount/tests/python_echo/test.yml: -------------------------------------------------------------------------------- 1 | language: PY2 2 | time: 2 3 | memory: 65536 4 | source: echo.py 5 | cases: [AC, WA, WA] 6 | extended_feedback_cases: 7 | - |- 8 | Case Feedback: 9 | ✓✓✓✓✓✓✓✓✓✓ 10 | - |- 11 | Case Feedback: 12 | ✓✓✓✓✓✓✓✓✓✗ 13 | - |- 14 | Case Feedback: 15 | ✗✗✗✗✗✗✗✗✗✗ 16 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_nasm_kill_judge/kill_judge.asm: -------------------------------------------------------------------------------- 1 | section .text 2 | global _start 3 | 4 | _start: 5 | mov eax, 64 6 | int 80h 7 | 8 | mov ebx, eax 9 | mov ecx, 24 10 | mov eax, 37 11 | int 80h 12 | 13 | mov ebx, eax 14 | xor eax, eax 15 | inc eax 16 | int 80h 17 | -------------------------------------------------------------------------------- /dmoj/executors/PYPY3.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.PYPY import Executor as PYPYExecutor 2 | 3 | 4 | class Executor(PYPYExecutor): 5 | command = 'pypy3' 6 | pygments_traceback_lexer = 'py3tb' 7 | test_program = """ 8 | import sys 9 | if sys.version_info.major == 3: 10 | print(sys.stdin.read(), end='') 11 | """ 12 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/monocs_oom/oom.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | public class Example 5 | { 6 | public static void Main() 7 | { 8 | StringBuilder sb = new StringBuilder(15, 15); 9 | sb.Append("Substring #1 "); 10 | sb.Insert(0, "Substring #2 ", 1); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /dmoj/executors/F95.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.c_like_executor import CLikeExecutor, GCCMixin 2 | 3 | 4 | class Executor(GCCMixin, CLikeExecutor): 5 | command = 'gfortran' 6 | ext = 'f95' 7 | std = 'f95' 8 | test_program = """\ 9 | character(100) :: line 10 | read(*,'(A)') line 11 | write(*,'(A)') line 12 | end 13 | """ 14 | -------------------------------------------------------------------------------- /testsuite/batch_dependencies/init.yml: -------------------------------------------------------------------------------- 1 | test_cases: 2 | - batched: 3 | - {in: 1.txt, out: 1.txt} 4 | points: 1 5 | - batched: 6 | - {in: 2.txt, out: 2.txt} 7 | points: 1 8 | - batched: 9 | - {in: 3.txt, out: 3.txt} 10 | points: 1 11 | dependencies: [1, 2] 12 | - batched: 13 | - {in: 1.txt, out: 1.txt} 14 | points: 1 15 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: LLVM 2 | --- 3 | Language: Cpp 4 | PointerAlignment: Right 5 | ColumnLimit: 120 6 | IndentWidth: 4 7 | SpaceAfterCStyleCast: yes 8 | AllowShortFunctionsOnASingleLine: Inline 9 | SpacesBeforeTrailingComments: 2 10 | Cpp11BracedListStyle: no 11 | AlignConsecutiveMacros: Consecutive 12 | IndentCaseLabels: yes 13 | -------------------------------------------------------------------------------- /dmoj/executors/BASH.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from dmoj.executors.shell_executor import ShellExecutor 4 | 5 | 6 | class Executor(ShellExecutor): 7 | ext = 'sh' 8 | command = 'bash' 9 | test_program = 'exec cat' 10 | 11 | def get_cmdline(self, **kwargs) -> List[str]: 12 | return ['bash', self._code] 13 | -------------------------------------------------------------------------------- /dmoj/utils/glob_ext.py: -------------------------------------------------------------------------------- 1 | import glob 2 | from pathlib import Path 3 | 4 | 5 | def find_glob_root(g: str) -> Path: 6 | """ 7 | Given a glob, find a directory that contains all its possible patterns 8 | """ 9 | dir = Path(g) 10 | while str(dir) != glob.escape(str(dir)): 11 | dir = dir.parent 12 | return dir 13 | -------------------------------------------------------------------------------- /testsuite/generator_multifile/gen.cpp: -------------------------------------------------------------------------------- 1 | #include "testlib.h" 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main(int argc, char *argv[]) { 8 | registerGen(argc, argv, 1); 9 | cout << atoi(argv[1]) << " " << atoi(argv[2]) << endl; 10 | cerr << atoi(argv[1]) + atoi(argv[2]) << endl; 11 | } 12 | -------------------------------------------------------------------------------- /testsuite/rust_bridged/README.md: -------------------------------------------------------------------------------- 1 | This test checks the shared target functionality of Rust, by having a 2 | submission and checker in Rust. The first case always runs fine, since the 3 | checker will not be compiled until after the submission is run. The second case 4 | will IR if the submission and checker have misconfigured target directories. 5 | -------------------------------------------------------------------------------- /testsuite/scroll/checker.py: -------------------------------------------------------------------------------- 1 | #! -*- encoding: utf-8 -*- 2 | 3 | def check(process_output, judge_output, judge_input, point_value, submission_source, **kwargs): 4 | from dmoj.result import CheckerResult 5 | 6 | if not process_output: 7 | return CheckerResult(False, 0) 8 | return CheckerResult(True, point_value, '正しい出力なのです') 9 | -------------------------------------------------------------------------------- /testsuite/aplusb/tests/cpp_io_symlinks/aplusb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | freopen("in_link", "r", stdin); 7 | 8 | int N; 9 | scanf("%d", &N); 10 | 11 | while (N--) { 12 | int a, b; 13 | scanf("%d %d", &a, &b); 14 | printf("%d\n", a + b); 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /testsuite/generator_multifile/init.yml: -------------------------------------------------------------------------------- 1 | generator: 2 | source: [gen.cpp, testlib.h] 3 | compiler_time_limit: 60 4 | test_cases: 5 | - {generator_args: [10, 5], points: 1} 6 | - {generator_args: [24, 89], points: 1} 7 | - {generator_args: [10, 15], points: 1} 8 | - {generator_args: [93, 51], points: 1} 9 | - {generator_args: [223, 703], points: 1} 10 | -------------------------------------------------------------------------------- /testsuite/bridged_checker/checker.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | FILE *proc_output; 4 | void read(int *i) { 5 | if (fscanf(proc_output, "%d", i) != 1) 6 | exit(2); 7 | } 8 | int main(int argc, char *argv[]) { 9 | proc_output = fopen(argv[2], "r"); 10 | int a, b; 11 | read(&a); 12 | read(&b); 13 | return a + b != 0; 14 | } 15 | -------------------------------------------------------------------------------- /testsuite/check_memory_limit/checker.py: -------------------------------------------------------------------------------- 1 | from dmoj.checkers import standard 2 | from dmoj.result import Result 3 | 4 | 5 | def check(process_output: bytes, judge_output: bytes, *, result: Result, **kwargs) -> bool: 6 | if result.max_memory > 65536: 7 | return False 8 | 9 | return standard.check(process_output, judge_output, result=result, **kwargs) 10 | -------------------------------------------------------------------------------- /dmoj/executors/PY2.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.python_executor import PythonExecutor 2 | 3 | 4 | class Executor(PythonExecutor): 5 | command = 'python' 6 | command_paths = ['python2.7', 'python2', 'python'] 7 | pygments_traceback_lexer = 'py2tb' 8 | test_program = """ 9 | import sys 10 | if sys.version_info.major == 2: 11 | print sys.stdin.read() 12 | """ 13 | -------------------------------------------------------------------------------- /dmoj/cptbox/ptdebug_arm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef id4e82dbcf_e693_404b_ba19_f27c2410e35c 3 | #define id4e82dbcf_e693_404b_ba19_f27c2410e35c 4 | 5 | #include 6 | 7 | // defines this, which breaks it for ptrace use. 8 | #ifdef PTRACE_SET_SYSCALL 9 | #undef PTRACE_SET_SYSCALL 10 | #endif 11 | 12 | typedef struct pt_regs ptbox_regs; 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /testsuite/floats/init.yml: -------------------------------------------------------------------------------- 1 | checker: 2 | name: floats 3 | args: {precision: 2} 4 | test_cases: 5 | - {in: 2.txt, out: 1.txt, points: 1} 6 | - {in: 3.txt, out: 1.txt, points: 1} 7 | - {in: 4.txt, out: 1.txt, points: 1} 8 | - {in: 5.txt, out: 1.txt, points: 1} 9 | - {in: 6.txt, out: 1.txt, points: 1} 10 | - {in: 7.txt, out: 1.txt, points: 1} 11 | - {in: 8.txt, out: 1.txt, points: 1} 12 | -------------------------------------------------------------------------------- /dmoj/checkers/standard.py: -------------------------------------------------------------------------------- 1 | from typing import Callable 2 | 3 | from ._checker import standard 4 | from ..utils.unicode import utf8bytes 5 | 6 | 7 | def check( 8 | process_output: bytes, judge_output: bytes, _checker: Callable[[bytes, bytes], bool] = standard, **kwargs 9 | ) -> bool: 10 | return _checker(utf8bytes(judge_output), utf8bytes(process_output)) 11 | 12 | 13 | del standard 14 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/c_signal_ir/signal.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | void handle_alarm(int _) { 7 | printf("Hello, World!\n"); 8 | exit(1); 9 | } 10 | 11 | int main(void) { 12 | signal(SIGVTALRM, handle_alarm); 13 | raise(SIGVTALRM); 14 | 15 | for (;;) { __asm__ volatile ("nop"); } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /dmoj/cptbox/ext_freebsd.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | inline long ptrace_traceme() { 5 | return ptrace(PT_TRACE_ME, 0, NULL, 0); 6 | } 7 | 8 | // Debian GNU/kFreeBSD neglected to define this in their libc. 9 | #if defined(__FreeBSD_kernel__) && !defined(PT_FOLLOW_FORK) 10 | #define PT_FOLLOW_FORK 23 11 | #endif 12 | 13 | // Constant for wait4 14 | #define __WALL 0 15 | -------------------------------------------------------------------------------- /dmoj/executors/CPP03.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.c_like_executor import CPPExecutor, GCCMixin 2 | 3 | 4 | class Executor(GCCMixin, CPPExecutor): 5 | command = 'g++' 6 | std = 'c++03' 7 | test_program = """ 8 | #include 9 | 10 | #if __cplusplus >= 199711 && __cplusplus < 201103 11 | int main() { 12 | std::cout << std::cin.rdbuf(); 13 | return 0; 14 | } 15 | #endif 16 | """ 17 | -------------------------------------------------------------------------------- /contrib/README.md: -------------------------------------------------------------------------------- 1 | # contrib 2 | 3 | This directory contains snippets that we use to administer judges on 4 | [dmoj.ca](https://dmoj.ca), and that we think might be more broadly useful. 5 | They are, however, provided with no support — please do not file bugs 6 | against scripts you find here (we will generally accept PRs, though). 7 | 8 | If you have a script you think would fit here, feel free to send in a PR. 9 | -------------------------------------------------------------------------------- /testsuite/aplusb/tests/java_biginteger/aplusb.java: -------------------------------------------------------------------------------- 1 | import java.math.BigInteger; 2 | import java.util.Scanner; 3 | public class aplusb { 4 | public static void main(String[] args) { 5 | Scanner in = new Scanner(System.in); 6 | int N = in.nextInt(); 7 | for(int i=0;i 2 | #include 3 | #include 4 | #include 5 | 6 | int main() { 7 | #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) 8 | if (ptrace(PT_TRACE_ME, 0, NULL, 0) == -1) 9 | #else 10 | if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) == -1) 11 | #endif 12 | { 13 | perror("ptrace"); 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /dmoj/checkers/unordered.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | 3 | from dmoj.checkers.sorted import check as sorted_check 4 | 5 | 6 | def check(process_output: bytes, judge_output: bytes, **kwargs) -> bool: 7 | warnings.warn( 8 | '`unordered` checker is deprecated, use `sorted` with `split_on` parameter instead', DeprecationWarning 9 | ) 10 | return sorted_check(process_output, judge_output, split_on='whitespace') 11 | -------------------------------------------------------------------------------- /dmoj/executors/C.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.c_like_executor import CExecutor, GCCMixin 2 | 3 | 4 | class Executor(GCCMixin, CExecutor): 5 | command = 'gcc' 6 | std = 'c99' 7 | 8 | test_program = """ 9 | #include 10 | 11 | #if __STDC_VERSION__ == 199901 12 | int main() { 13 | int ch; 14 | while ((ch = getchar()) != EOF) 15 | putchar(ch); 16 | return 0; 17 | } 18 | #endif 19 | """ 20 | -------------------------------------------------------------------------------- /dmoj/executors/PHP.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from dmoj.executors.script_executor import ScriptExecutor 4 | 5 | 6 | class Executor(ScriptExecutor): 7 | ext = 'php' 8 | command = 'php' 9 | command_paths = ['php7', 'php5', 'php'] 10 | 11 | test_program = ' List[str]: 14 | return ['php', self._code] 15 | -------------------------------------------------------------------------------- /dmoj/executors/PY3.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.python_executor import PythonExecutor 2 | 3 | 4 | class Executor(PythonExecutor): 5 | command = 'python3' 6 | command_paths = [f'python{i}' for i in ['3.6', '3.5', '3.4', '3.3', '3.2', '3.1', '3']] 7 | pygments_traceback_lexer = 'py3tb' 8 | test_program = """ 9 | import sys 10 | if sys.version_info.major == 3: 11 | print(sys.stdin.read(), end='') 12 | """ 13 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/cpp_compiler_ole/hello.cpp: -------------------------------------------------------------------------------- 1 | #define A(x) x##x##x##x 2 | #define B(x) A(x##x##x##x) 3 | #define C(x) B(x##x##x##x) 4 | #define D(x) C(x##x##x##x) 5 | #define E(x) D(x##x##x##x) 6 | #define F(x) E(x##x##x##x) 7 | #define G(x) F(x##x##x##x) 8 | #define H(x) G(x##x##x##x) 9 | #define I(x) H(x##x##x##x) 10 | #define J(x) I(x##x##x##x) 11 | #define K(x) J(x##x##x##x) 12 | int main() { int x = K(a); } 13 | -------------------------------------------------------------------------------- /testsuite/seed2/tests/tur_ac/seed2.tur: -------------------------------------------------------------------------------- 1 | var minium, maxium, mid : int 2 | var status : string 3 | minium := 1 4 | maxium := 2 * 10 ** 9 5 | loop 6 | mid := minium + (maxium - minium) div 2 7 | put mid 8 | get status 9 | if status = "SINKS" then 10 | minium := mid + 1 11 | elsif status = "FLOATS" then 12 | maxium := mid - 1 13 | end if 14 | exit when status = "OK" 15 | end loop 16 | -------------------------------------------------------------------------------- /dmoj/executors/GASARM.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.asm_executor import GASExecutor, PlatformARMMixin 2 | 3 | 4 | class Executor(PlatformARMMixin, GASExecutor): 5 | as_name = 'as_arm' 6 | test_program = r""" 7 | .global _start 8 | _start: 9 | mov r7, #4 10 | mov r0, #1 11 | mov r2, #20 12 | ldr r1, =string 13 | swi 0 14 | mov r7, #1 15 | swi 0 16 | .data 17 | string: 18 | .ascii "echo: Hello, World!\n" 19 | """ 20 | -------------------------------------------------------------------------------- /testsuite/aplusb/tests/java_bigdecimal/aplusb.java: -------------------------------------------------------------------------------- 1 | import java.math.BigDecimal; 2 | import java.util.Scanner; 3 | public class aplusb { 4 | public static void main(String[] args) { 5 | Scanner in = new Scanner(System.in); 6 | int N = in.nextInt(); 7 | for(int i=0;i bool: 8 | process_all = regex.sub(b'', utf8bytes(process_output)) 9 | judge_all = regex.sub(b'', utf8bytes(judge_output)) 10 | return Counter(process_all.lower()) == Counter(judge_all.lower()) 11 | -------------------------------------------------------------------------------- /testsuite/coci_partial/checker.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int main(int argc, char *argv[]) { 8 | std::unique_ptr streamPtr = 9 | std::make_unique(std::string(argv[2])); 10 | std::istream &in = *streamPtr; 11 | std::string s; 12 | while (getline(in, s)) 13 | std::cerr << s << std::endl; 14 | return 7; 15 | } 16 | -------------------------------------------------------------------------------- /testsuite/rust_generator/generator.rs: -------------------------------------------------------------------------------- 1 | use rand::{Rng, SeedableRng}; 2 | 3 | type ConcreteRng = rand_xoshiro::Xoshiro256PlusPlus; 4 | 5 | fn main() { 6 | let mut args = std::env::args(); 7 | args.next(); 8 | let mut rng = ConcreteRng::seed_from_u64(args.next().unwrap().parse().unwrap()); 9 | 10 | let x = rng.gen_range(0..10); 11 | let y = rng.gen_range(0..10); 12 | println!("{x} {y}"); 13 | eprintln!("{}", x + y); 14 | } 15 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/cpp_wall_clock/stall.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void gettime(uint64_t *w) { 6 | struct timespec spec; 7 | clock_gettime(CLOCK_MONOTONIC, &spec); 8 | *w = spec.tv_sec * 1000000000 + spec.tv_nsec; 9 | } 10 | 11 | int main() { 12 | uint64_t w, k; 13 | gettime(&w); 14 | k = w; 15 | while (k - w < 10000000000) 16 | gettime(&k); 17 | puts("Hello, World!"); 18 | } 19 | -------------------------------------------------------------------------------- /dmoj/executors/C11.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.c_like_executor import CExecutor, GCCMixin 2 | 3 | 4 | class Executor(GCCMixin, CExecutor): 5 | command = 'gcc11' 6 | std = 'c11' 7 | command_paths = ['gcc'] 8 | 9 | test_program = """ 10 | #include 11 | 12 | #if __STDC_VERSION__ == 201112 13 | int main() { 14 | int ch; 15 | while ((ch = getchar()) != EOF) 16 | putchar(ch); 17 | return 0; 18 | } 19 | #endif 20 | """ 21 | -------------------------------------------------------------------------------- /testsuite/seed2/tests/cpp_no_flush/seed2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | long long l = 1, r = 2000000000; 7 | while (l <= r) { 8 | long long mid = (l + r) / 2; 9 | cout << mid << '\n'; 10 | string s; 11 | cin >> s; 12 | if (s == "SINKS") { 13 | l = mid + 1; 14 | } else if (s == "FLOATS") { 15 | r = mid - 1; 16 | } else { 17 | return 0; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /dmoj/executors/CPP11.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.c_like_executor import CPPExecutor, GCCMixin 2 | 3 | 4 | class Executor(GCCMixin, CPPExecutor): 5 | command = 'g++11' 6 | command_paths = ['g++-5', 'g++-4.9', 'g++-4.8', 'g++'] 7 | std = 'c++11' 8 | test_program = """ 9 | #include 10 | 11 | #if __cplusplus == 201103 12 | int main() { 13 | auto input = std::cin.rdbuf(); 14 | std::cout << input; 15 | return 0; 16 | } 17 | #endif 18 | """ 19 | -------------------------------------------------------------------------------- /dmoj/executors/CPP14.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.c_like_executor import CPPExecutor, GCCMixin 2 | 3 | 4 | class Executor(GCCMixin, CPPExecutor): 5 | command = 'g++14' 6 | command_paths = ['g++-5', 'g++'] 7 | std = 'c++14' 8 | test_program = """ 9 | #include 10 | 11 | auto input() { 12 | return std::cin.rdbuf(); 13 | } 14 | 15 | #if __cplusplus == 201402 16 | int main() { 17 | std::cout << input(); 18 | return 0; 19 | } 20 | #endif 21 | """ 22 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor/tests/cpp_no_flush/seed2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | long long l = 1, r = 2000000000; 7 | while (l <= r) { 8 | long long mid = (l + r) / 2; 9 | cout << mid << '\n'; 10 | string s; 11 | cin >> s; 12 | if (s == "SINKS") { 13 | l = mid + 1; 14 | } else if (s == "FLOATS") { 15 | r = mid - 1; 16 | } else { 17 | return 0; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.coveragerc: -------------------------------------------------------------------------------- 1 | [report] 2 | exclude_lines = 3 | pragma: no cover 4 | raise AssertionError 5 | raise NotImplementedError 6 | if __name__ == .__main__.: 7 | except ImportError: 8 | except OSError: 9 | 10 | ignore_errors = True 11 | 12 | [run] 13 | concurrency = multiprocessing 14 | source = dmoj 15 | omit = 16 | dmoj/cli.py 17 | dmoj/citest.py 18 | dmoj/testsuite.py 19 | dmoj/commands/* 20 | dmoj/packet.py 21 | dmoj/executors/autoconfig.py 22 | -------------------------------------------------------------------------------- /dmoj/executors/PERL.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from dmoj.cptbox.filesystem_policies import RecursiveDir 4 | from dmoj.executors.script_executor import ScriptExecutor 5 | 6 | 7 | class Executor(ScriptExecutor): 8 | ext = 'pl' 9 | command = 'perl' 10 | fs = [RecursiveDir('/etc/perl')] 11 | test_program = 'print<>' 12 | syscalls = ['umtx_op'] 13 | 14 | def get_cmdline(self, **kwargs) -> List[str]: 15 | return ['perl', '-Mre=eval', self._code] 16 | -------------------------------------------------------------------------------- /testsuite/binary_data/gen.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char **argv) { 5 | int T = atoi(argv[1]); 6 | if (T == 1) { 7 | fprintf(stdout, "Hi\r\n"); 8 | fprintf(stderr, "Hi\r\n"); 9 | } else if (T == 2) { 10 | fprintf(stdout, "Hi\r"); 11 | fprintf(stderr, "Hi\r"); 12 | } else if (T == 3) { 13 | fprintf(stdout, "Hi\n"); 14 | fprintf(stderr, "Hi\n"); 15 | } 16 | fflush(stdout); 17 | fflush(stderr); 18 | } 19 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_noflush/tests/cpp_no_flush/seed2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | long long l = 1, r = 2000000000; 7 | while (l <= r) { 8 | long long mid = (l + r) / 2; 9 | cout << mid << '\n'; 10 | string s; 11 | cin >> s; 12 | if (s == "SINKS") { 13 | l = mid + 1; 14 | } else if (s == "FLOATS") { 15 | r = mid - 1; 16 | } else { 17 | return 0; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_c_null_path/nullpath.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int main() { 8 | int fd; 9 | if ((fd = open(NULL, O_RDONLY)) >= 0) { 10 | close(fd); 11 | puts("Should not open the file"); 12 | } else if (errno == EFAULT) { 13 | puts("Hello, World!"); 14 | } else { 15 | printf("Wrong errno: %d", errno); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /dmoj/cptbox/__init__.py: -------------------------------------------------------------------------------- 1 | from dmoj.cptbox._cptbox import ( 2 | Debugger, 3 | NATIVE_ABI, 4 | PTBOX_ABI_ARM, 5 | PTBOX_ABI_ARM64, 6 | PTBOX_ABI_INVALID, 7 | PTBOX_ABI_X32, 8 | PTBOX_ABI_X64, 9 | PTBOX_ABI_X86, 10 | ) 11 | from dmoj.cptbox.handlers import ALLOW, DISALLOW 12 | from dmoj.cptbox.isolate import FilesystemSyscallKind, IsolateTracer 13 | from dmoj.cptbox.syscalls import SYSCALL_COUNT 14 | from dmoj.cptbox.tracer import PIPE, TracedPopen, can_debug 15 | -------------------------------------------------------------------------------- /dmoj/executors/CPP17.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.c_like_executor import CPPExecutor, GCCMixin 2 | 3 | 4 | class Executor(GCCMixin, CPPExecutor): 5 | command = 'g++17' 6 | command_paths = ['g++-7', 'g++'] 7 | std = 'c++17' 8 | test_program = """ 9 | #include 10 | 11 | #if __cplusplus == 201703 12 | int main() { 13 | float literal = 0x3.ABCp-10; 14 | auto input = std::cin.rdbuf(); 15 | std::cout << input; 16 | return 0; 17 | } 18 | #endif 19 | """ 20 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_c_bad_unicode_open/bad_unicode.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int main() { 8 | int fd; 9 | if ((fd = open("\xaa", O_RDONLY)) >= 0) { 10 | close(fd); 11 | puts("Should not open the file"); 12 | } else if (errno == ENOENT) { 13 | puts("Hello, World!"); 14 | } else { 15 | printf("Wrong errno: %d", errno); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testsuite/interactive/interact.py: -------------------------------------------------------------------------------- 1 | from dmoj.graders.interactive import InteractiveGrader 2 | 3 | class Grader(InteractiveGrader): 4 | def interact(self, case, interactor): 5 | N = int(case.input_data()) 6 | guess = None 7 | guesses = 0 8 | while True: 9 | guesses += 1 10 | guess = interactor.readint() 11 | if guess == N: 12 | break 13 | interactor.writeln(N - guess) 14 | return guesses < 10 15 | -------------------------------------------------------------------------------- /dmoj/commands/help.py: -------------------------------------------------------------------------------- 1 | from dmoj.commands.base_command import Command, commands 2 | 3 | 4 | class HelpCommand(Command): 5 | name = 'help' 6 | help = 'Prints listing of commands.' 7 | 8 | def execute(self, line: str) -> None: 9 | print('Run `command -h/--help` for individual command usage.') 10 | for name, command in commands.items(): 11 | if command == self: 12 | continue 13 | print(f' {name}: {command.help}') 14 | print() 15 | -------------------------------------------------------------------------------- /dmoj/executors/CPP20.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.c_like_executor import CPPExecutor, GCCMixin 2 | 3 | 4 | class Executor(GCCMixin, CPPExecutor): 5 | command = 'g++20' 6 | command_paths = ['g++-11', 'g++'] 7 | std = 'c++20' 8 | test_program = """ 9 | #include 10 | 11 | #if __cplusplus == 202002 12 | int main() { 13 | std::strong_ordering comparison = 1 <=> 2; 14 | auto input = std::cin.rdbuf(); 15 | std::cout << input; 16 | return 0; 17 | } 18 | #endif 19 | """ 20 | -------------------------------------------------------------------------------- /dmoj/checkers/__init__.py: -------------------------------------------------------------------------------- 1 | from typing import Callable, Union 2 | 3 | from dmoj.checkers import ( 4 | bridged, 5 | easy, 6 | floats, 7 | floatsabs, 8 | floatsrel, 9 | identical, 10 | linecount, 11 | linematches, 12 | rstripped, 13 | sorted, 14 | standard, 15 | unordered, 16 | ) 17 | from dmoj.result import CheckerResult 18 | 19 | CheckerOutput = Union[bool, CheckerResult] 20 | 21 | CheckerCallable = Callable 22 | 23 | 24 | class Checker: 25 | check: CheckerCallable 26 | -------------------------------------------------------------------------------- /dmoj/executors/CLANG.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.c_like_executor import CExecutor, CLANG_VERSIONS, ClangMixin 2 | 3 | 4 | class Executor(ClangMixin, CExecutor): 5 | command = 'clang' 6 | std = 'c11' 7 | command_paths = [f'clang-{i}' for i in CLANG_VERSIONS] + ['clang'] 8 | 9 | test_program = """ 10 | #include 11 | 12 | #if __STDC_VERSION__ == 201112 13 | int main() { 14 | int ch; 15 | while ((ch = getchar()) != EOF) 16 | putchar(ch); 17 | return 0; 18 | } 19 | #endif 20 | """ 21 | -------------------------------------------------------------------------------- /dmoj/executors/PIKE.py: -------------------------------------------------------------------------------- 1 | from dmoj.cptbox.handlers import ACCESS_EACCES 2 | from dmoj.executors.script_executor import ScriptExecutor 3 | 4 | 5 | class Executor(ScriptExecutor): 6 | ext = 'pike' 7 | command = 'pike' 8 | syscalls = [ 9 | # Linux 10 | ('fstatfs', ACCESS_EACCES), 11 | # FreeBSD 12 | 'socketpair', 13 | ('fpathconf', ACCESS_EACCES), 14 | ] 15 | test_program = """\ 16 | int main() { 17 | write(Stdio.stdin.gets()); 18 | return 0; 19 | } 20 | """ 21 | -------------------------------------------------------------------------------- /dmoj/executors/LUA.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from dmoj.executors.base_executor import VersionFlags 4 | from dmoj.executors.script_executor import ScriptExecutor 5 | 6 | 7 | class Executor(ScriptExecutor): 8 | ext = 'lua' 9 | command = 'lua' 10 | command_paths = ['lua', 'lua5.3', 'lua5.2', 'lua5.1'] 11 | address_grace = 131072 12 | test_program = "io.write(io.read('*all'))" 13 | 14 | @classmethod 15 | def get_version_flags(cls, command: str) -> List[VersionFlags]: 16 | return ['-v'] 17 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_c_format_open/format_open.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main() { 7 | int fd; 8 | if ((fd = open("%s", O_RDONLY)) >= 0) { 9 | puts("Should not open the file"); 10 | } else if (errno == EACCES || errno == ENOENT) { // differs between seccomp and landlock 11 | puts("Hello, World!"); 12 | return 0; 13 | } else { 14 | printf("Wrong errno: %d", errno); 15 | } 16 | return -1; 17 | } 18 | -------------------------------------------------------------------------------- /dmoj/executors/CLANGX.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.c_like_executor import CLANG_VERSIONS, CPPExecutor, ClangMixin 2 | 3 | 4 | class Executor(ClangMixin, CPPExecutor): 5 | command = 'clang++' 6 | std = 'c++14' 7 | command_paths = [f'clang++-{i}' for i in CLANG_VERSIONS] + ['clang++'] 8 | 9 | test_program = """ 10 | #include 11 | 12 | auto input() { 13 | return std::cin.rdbuf(); 14 | } 15 | 16 | #if __cplusplus == 201402 17 | int main() { 18 | std::cout << input(); 19 | return 0; 20 | } 21 | #endif 22 | """ 23 | -------------------------------------------------------------------------------- /dmoj/executors/TEXT.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.mixins import StripCarriageReturnsMixin 2 | from dmoj.executors.script_executor import ScriptExecutor 3 | 4 | 5 | # We want to strip carriage returns because the source code is outputted byte-for-byte, 6 | # and we strip these in test data. 7 | class Executor(StripCarriageReturnsMixin, ScriptExecutor): 8 | ext = 'txt' 9 | command = 'cat' 10 | test_program = 'echo: Hello, World!\n' 11 | syscalls = ['fadvise64_64', 'fadvise64', 'posix_fadvise', 'arm_fadvise64_64', 'copy_file_range'] 12 | -------------------------------------------------------------------------------- /dmoj/executors/FORTH.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from dmoj.executors.script_executor import ScriptExecutor 4 | 5 | 6 | class Executor(ScriptExecutor): 7 | command = 'gforth' 8 | ext = 'fs' 9 | test_program = """\ 10 | : HELLO ( -- ) ." echo: Hello, World!" CR ; 11 | 12 | HELLO 13 | """ 14 | 15 | def get_cmdline(self, **kwargs) -> List[str]: 16 | command = self.get_command() 17 | assert command is not None 18 | assert self._code is not None 19 | return [command, self._code, '-e', 'bye'] 20 | -------------------------------------------------------------------------------- /.docker/Makefile: -------------------------------------------------------------------------------- 1 | GIT_TAG ?= master 2 | TAG ?= latest 3 | 4 | .PHONY: all judge-tier1 judge-tier2 judge-tier3 5 | 6 | all: judge-tier1 judge-tier2 judge-tier3 7 | 8 | judge-tier1: 9 | cd tier1 && docker build --build-arg TAG="${GIT_TAG}" -t dmoj/judge-tier1 -t dmoj/judge-tier1:$(TAG) . 10 | 11 | judge-tier2: 12 | cd tier2 && docker build --build-arg TAG="${GIT_TAG}" -t dmoj/judge-tier2 -t dmoj/judge-tier2:$(TAG) . 13 | 14 | judge-tier3: 15 | cd tier3 && docker build --build-arg TAG="${GIT_TAG}" -t dmoj/judge-tier3 -t dmoj/judge-tier3:$(TAG) . 16 | -------------------------------------------------------------------------------- /dmoj/graders/custom.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from dmoj.judgeenv import get_problem_root 4 | from dmoj.utils.module import load_module_from_file 5 | 6 | 7 | class CustomGrader: 8 | def __init__(self, judge, problem, language, source): 9 | self.judge = judge 10 | self.mod = load_module_from_file(os.path.join(get_problem_root(problem.id), problem.config['custom_judge'])) 11 | self._grader = self.mod.Grader(judge, problem, language, source) 12 | 13 | def __getattr__(self, item): 14 | return getattr(self._grader, item) 15 | -------------------------------------------------------------------------------- /testsuite/aplusb/tests/java_ac/aplusb.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | 4 | public class aplusb { 5 | public static void main(String args[]) throws IOException { 6 | BufferedReader cin = new BufferedReader(new InputStreamReader(System.in)); 7 | int N = Integer.parseInt(cin.readLine()); 8 | 9 | for (int i = 0; i < N; i++) { 10 | String[] line = cin.readLine().split(" "); 11 | System.out.println(Integer.parseInt(line[0]) + Integer.parseInt(line[1])); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /dmoj/cptbox/handlers.pyi: -------------------------------------------------------------------------------- 1 | from dmoj.cptbox._cptbox import Debugger 2 | 3 | ALLOW: int 4 | DISALLOW: int 5 | _CALLBACK: int 6 | 7 | class ErrnoHandlerCallback: 8 | errno: int 9 | error_name: str 10 | def __call__(self, debugger: Debugger) -> bool: ... 11 | 12 | ACCESS_EACCES: ErrnoHandlerCallback 13 | ACCESS_EAGAIN: ErrnoHandlerCallback 14 | ACCESS_EFAULT: ErrnoHandlerCallback 15 | ACCESS_EINVAL: ErrnoHandlerCallback 16 | ACCESS_ENOENT: ErrnoHandlerCallback 17 | ACCESS_EPERM: ErrnoHandlerCallback 18 | ACCESS_ENAMETOOLONG: ErrnoHandlerCallback 19 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_c_null_path_noat/nullpath.c: -------------------------------------------------------------------------------- 1 | #define _DEFAULT_SOURCE 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | int main() { 10 | int fd; 11 | if ((fd = syscall(SYS_open, NULL, O_RDONLY)) >= 0) { 12 | close(fd); 13 | puts("Should not open the file"); 14 | } else if (errno == EFAULT) { 15 | puts("Hello, World!"); 16 | } else { 17 | printf("Wrong errno: %d", errno); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_c_bad_unicode_open_noat/bad_unicode.c: -------------------------------------------------------------------------------- 1 | #define _DEFAULT_SOURCE 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | int main() { 10 | int fd; 11 | if ((fd = syscall(SYS_open, "\xaa", O_RDONLY)) >= 0) { 12 | close(fd); 13 | puts("Should not open the file"); 14 | } else if (errno == ENOENT) { 15 | puts("Hello, World!"); 16 | } else { 17 | printf("Wrong errno: %d", errno); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /dmoj/executors/ADA.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from dmoj.executors.base_executor import VersionFlags 4 | from dmoj.executors.c_like_executor import CLikeExecutor, GCCMixin 5 | 6 | 7 | class Executor(GCCMixin, CLikeExecutor): 8 | command = 'gnatmake' 9 | ext = 'adb' 10 | test_program = """\ 11 | with Ada.Text_IO; use Ada.Text_IO; 12 | procedure Hello is 13 | begin 14 | Put_Line ("echo: Hello, World!"); 15 | end Hello; 16 | """ 17 | 18 | @classmethod 19 | def get_version_flags(cls, command: str) -> List[VersionFlags]: 20 | return ['--version'] 21 | -------------------------------------------------------------------------------- /testsuite/seed2/tests/cpp_ac/seed2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(int argc, const char *argv[]) { 6 | cin.tie(0); 7 | cin.sync_with_stdio(0); 8 | long long low = 1, high = 2000000000; 9 | while (low <= high) { 10 | long long mid = (low + high) / 2; 11 | cout << mid << endl; 12 | string res; 13 | cin >> res; 14 | if (res == "OK") 15 | return 0; 16 | else if (res == "FLOATS") 17 | high = mid - 1; 18 | else 19 | low = mid + 1; 20 | } 21 | cout << low << endl; 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /dmoj/tests/test_malformed_unicode.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from dmoj.error import CompileError 4 | from dmoj.executors.JAVA8 import Executor as JAVA8Executor 5 | 6 | 7 | class ProblemTest(unittest.TestCase): 8 | def test_malformed_unicode(self): 9 | source = b"""\ 10 | public class malformed { 11 | public static void main(String[] args){ 12 | S = "\xc1\xbf"; // This is malformed unicode 13 | } 14 | }""" 15 | with self.assertRaisesRegex(CompileError, 'Your UTF-8 is bad, and you should feel bad'): 16 | JAVA8Executor('malformed', source) 17 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/java8_ce_name_too_long/helloworld.java: -------------------------------------------------------------------------------- 1 | public class aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa { 2 | public static void main(String[] argv) { 3 | throw new RuntimeException(); 4 | } 5 | } -------------------------------------------------------------------------------- /testsuite/bridged_interactor/tests/cpp_ac/seed2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(int argc, const char *argv[]) { 6 | cin.tie(0); 7 | cin.sync_with_stdio(0); 8 | long long low = 1, high = 2000000000; 9 | while (low <= high) { 10 | long long mid = (low + high) / 2; 11 | cout << mid << endl; 12 | string res; 13 | cin >> res; 14 | if (res == "OK") 15 | return 0; 16 | else if (res == "FLOATS") 17 | high = mid - 1; 18 | else 19 | low = mid + 1; 20 | } 21 | cout << low << endl; 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_noflush/tests/cpp_ac/seed2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(int argc, const char *argv[]) { 6 | cin.tie(0); 7 | cin.sync_with_stdio(0); 8 | long long low = 1, high = 2000000000; 9 | while (low <= high) { 10 | long long mid = (low + high) / 2; 11 | cout << mid << endl; 12 | string res; 13 | cin >> res; 14 | if (res == "OK") 15 | return 0; 16 | else if (res == "FLOATS") 17 | high = mid - 1; 18 | else 19 | low = mid + 1; 20 | } 21 | cout << low << endl; 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /dmoj/executors/SED.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from dmoj.executors.base_executor import VersionFlags 4 | from dmoj.executors.script_executor import ScriptExecutor 5 | 6 | 7 | class Executor(ScriptExecutor): 8 | ext = 'sed' 9 | command = 'sed' 10 | test_program = 's/^//' 11 | 12 | def get_cmdline(self, **kwargs) -> List[str]: 13 | command = self.get_command() 14 | assert command is not None 15 | return [command, '-f', self._code] 16 | 17 | @classmethod 18 | def get_version_flags(cls, command: str) -> List[VersionFlags]: 19 | return ['--version'] 20 | -------------------------------------------------------------------------------- /dmoj/utils/normalize.py: -------------------------------------------------------------------------------- 1 | from io import TextIOWrapper 2 | 3 | 4 | def normalized_file_copy(src, dst, block_size=16384): 5 | src_wrap = TextIOWrapper(src, encoding='iso-8859-1', newline=None) 6 | dst_wrap = TextIOWrapper(dst, encoding='iso-8859-1', newline='') 7 | 8 | add_newline = False 9 | while True: 10 | buf = src_wrap.read(block_size) 11 | if not buf: 12 | break 13 | dst_wrap.write(buf) 14 | add_newline = not buf.endswith('\n') 15 | 16 | if add_newline: 17 | dst_wrap.write('\n') 18 | 19 | src_wrap.detach() 20 | dst_wrap.detach() 21 | -------------------------------------------------------------------------------- /.docker/entry: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export DMOJ_IN_DOCKER=1 4 | export PYTHONUNBUFFERED=1 5 | export LANG=C.UTF-8 6 | export PYTHONIOENCODING=utf8 7 | 8 | cd /judge || exit 9 | /env/bin/pip3 install -q -e . 10 | 11 | case "$1" in 12 | run) command=(/env/bin/dmoj) ;; 13 | cli) command=(/env/bin/dmoj-cli) ;; 14 | test) command=(/env/bin/python3 -m dmoj.testsuite testsuite) ;; 15 | *) 16 | echo "Invalid command, must be one of [run, cli, test]" 1>&2 17 | exit 1 18 | ;; 19 | esac 20 | 21 | shift 22 | export HOME=~judge 23 | . ~judge/.profile 24 | exec setpriv --reuid judge --regid judge --clear-groups "${command[@]}" "$@" 25 | -------------------------------------------------------------------------------- /testsuite/seed2/seed2.py: -------------------------------------------------------------------------------- 1 | from dmoj.graders.interactive import InteractiveGrader 2 | 3 | class Grader(InteractiveGrader): 4 | def interact(self, case, interactor): 5 | N = int(case.input_data()) 6 | guesses = 0 7 | guess = 0 8 | while guess != N: 9 | guess = interactor.readint(1, 2000000000) 10 | guesses += 1 11 | if guess == N: 12 | interactor.writeln('OK') 13 | elif guess > N: 14 | interactor.writeln('FLOATS') 15 | else: 16 | interactor.writeln('SINKS') 17 | return guesses <= 31 18 | -------------------------------------------------------------------------------- /dmoj/utils/module.py: -------------------------------------------------------------------------------- 1 | import os 2 | import types 3 | from typing import Any, Optional 4 | 5 | 6 | def load_module(name: str, code: str, filename: Optional[str] = None) -> Any: 7 | mod = types.ModuleType(name) 8 | if filename is not None: 9 | mod.__file__ = filename 10 | exec(compile(code, filename or '', 'exec'), mod.__dict__) 11 | return mod 12 | 13 | 14 | def load_module_from_file(filename: str) -> Any: 15 | path, name = os.path.split(filename) 16 | name, ext = os.path.splitext(name) 17 | 18 | with open(filename) as f: 19 | return load_module(name, f.read(), os.path.abspath(filename)) 20 | -------------------------------------------------------------------------------- /testsuite/generator_pass_flags/generator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #ifdef FLAG 5 | void gen(int N) { 6 | printf("%d\n", N); 7 | for (int i = 0; i < N; i++) { 8 | int a = rand() % 10, b = rand() % 10; 9 | printf("%d %d\n", a, b); 10 | fprintf(stderr, "%d\n", a + b); 11 | } 12 | fflush(stdout); 13 | fflush(stderr); 14 | } 15 | 16 | int main(int argc, char *argv[]) { 17 | int T = atoi(argv[1]); 18 | if (T == 1) 19 | gen(10); 20 | else if (T == 2) 21 | gen(1000); 22 | else if (T == 3) 23 | gen(1000000); 24 | else if (T == 4) 25 | gen(10000000); 26 | return 0; 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /dmoj/executors/GAS32.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.asm_executor import GASExecutor, PlatformX86Mixin 2 | 3 | 4 | class Executor(PlatformX86Mixin, GASExecutor): 5 | as_name = 'as_x86' 6 | 7 | test_program = r""".intel_syntax noprefix 8 | 9 | .text 10 | .global _start 11 | 12 | _start: 13 | mov eax, 3 14 | xor ebx, ebx 15 | mov ecx, offset buffer 16 | mov edx, 4096 17 | int 0x80 18 | 19 | test eax, eax 20 | jz _exit 21 | 22 | mov edx, eax 23 | inc ebx 24 | mov eax, 4 25 | int 0x80 26 | 27 | jmp _start 28 | _exit: 29 | xor eax, eax 30 | xor ebx, ebx 31 | inc eax 32 | int 0x80 33 | 34 | .bss 35 | buffer: 36 | .skip 4096 37 | """ # noqa: W191 38 | -------------------------------------------------------------------------------- /dmoj/executors/GAS64.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.asm_executor import GASExecutor, PlatformX64Mixin 2 | 3 | 4 | class Executor(PlatformX64Mixin, GASExecutor): 5 | as_name = 'as_x64' 6 | 7 | test_program = r""".intel_syntax noprefix 8 | 9 | .text 10 | .global _start 11 | 12 | _start: 13 | xor rax, rax 14 | xor rdi, rdi 15 | mov rsi, offset buffer 16 | mov rdx, 4096 17 | syscall 18 | 19 | test rax, rax 20 | jz _exit 21 | 22 | mov rdx, rax 23 | xor rax, rax 24 | inc rdi 25 | inc rax 26 | syscall 27 | 28 | jmp _start 29 | _exit: 30 | mov rax, 60 31 | xor rdi, rdi 32 | syscall 33 | 34 | .bss 35 | buffer: 36 | .skip 4096 37 | """ # noqa: W191 38 | -------------------------------------------------------------------------------- /testsuite/generator/generator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | void gen(int N) { 7 | printf("%d\n", N); 8 | for (int i = 0; i < N; i++) { 9 | int a = rand() % 10, b = rand() % 10; 10 | printf("%d %d\n", a, b); 11 | fprintf(stderr, "%d\n", a + b); 12 | } 13 | fflush(stdout); 14 | fflush(stderr); 15 | } 16 | 17 | int main() { 18 | int T; 19 | scanf("%d", &T); 20 | while (getchar() != -1) 21 | ; 22 | if (T == 1) 23 | gen(10); 24 | else if (T == 2) 25 | gen(1000); 26 | else if (T == 3) 27 | gen(1000000); 28 | else if (T == 4) 29 | gen(10000000); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /.docker/tier1/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM dmoj/runtimes-tier1 2 | 3 | ARG TAG=master 4 | RUN mkdir /judge /problems && cd /judge && \ 5 | curl -L https://github.com/DMOJ/judge-server/archive/"${TAG}".tar.gz | tar -xz --strip-components=1 && \ 6 | python3 -m venv --prompt=DMOJ /env && \ 7 | /env/bin/pip3 install cython setuptools && \ 8 | /env/bin/pip3 install -e . && \ 9 | /env/bin/python3 setup.py develop && \ 10 | HOME=~judge . ~judge/.profile && \ 11 | runuser -u judge -w PATH -- /env/bin/dmoj-autoconf -V > /judge-runtime-paths.yml && \ 12 | echo ' crt_x86_in_lib32: true' >> /judge-runtime-paths.yml 13 | 14 | ENTRYPOINT ["/usr/bin/tini", "--", "/judge/.docker/entry"] 15 | -------------------------------------------------------------------------------- /.docker/tier2/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM dmoj/runtimes-tier2 2 | 3 | ARG TAG=master 4 | RUN mkdir /judge /problems && cd /judge && \ 5 | curl -L https://github.com/DMOJ/judge-server/archive/"${TAG}".tar.gz | tar -xz --strip-components=1 && \ 6 | python3 -m venv --prompt=DMOJ /env && \ 7 | /env/bin/pip3 install cython setuptools && \ 8 | /env/bin/pip3 install -e . && \ 9 | /env/bin/python3 setup.py develop && \ 10 | HOME=~judge . ~judge/.profile && \ 11 | runuser -u judge -w PATH -- /env/bin/dmoj-autoconf -V > /judge-runtime-paths.yml && \ 12 | echo ' crt_x86_in_lib32: true' >> /judge-runtime-paths.yml 13 | 14 | ENTRYPOINT ["/usr/bin/tini", "--", "/judge/.docker/entry"] 15 | -------------------------------------------------------------------------------- /.docker/tier3/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM dmoj/runtimes-tier3 2 | 3 | ARG TAG=master 4 | RUN mkdir /judge /problems && cd /judge && \ 5 | curl -L https://github.com/DMOJ/judge-server/archive/"${TAG}".tar.gz | tar -xz --strip-components=1 && \ 6 | python3 -m venv --prompt=DMOJ /env && \ 7 | /env/bin/pip3 install cython setuptools && \ 8 | /env/bin/pip3 install -e . && \ 9 | /env/bin/python3 setup.py develop && \ 10 | HOME=~judge . ~judge/.profile && \ 11 | runuser -u judge -w PATH -- /env/bin/dmoj-autoconf -V > /judge-runtime-paths.yml && \ 12 | echo ' crt_x86_in_lib32: true' >> /judge-runtime-paths.yml 13 | 14 | ENTRYPOINT ["/usr/bin/tini", "--", "/judge/.docker/entry"] 15 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_c_nametoolong/nametoolong.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int main() { 8 | char buf[4352]; 9 | memset(buf, 'a', sizeof buf - 1); 10 | for (int i = 0; i < sizeof buf; i += 256) 11 | buf[i] = '/'; 12 | buf[sizeof buf - 1] = '\0'; 13 | 14 | int fd; 15 | if ((fd = open(buf, O_RDONLY)) >= 0) { 16 | close(fd); 17 | puts("Should not open the file"); 18 | } else if (errno == ENAMETOOLONG) { 19 | puts("Hello, World!"); 20 | } else { 21 | printf("Wrong errno: %d", errno); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testsuite/generator_custom_limits/generator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | void gen(int N) { 7 | printf("%d\n", N); 8 | for (int i = 0; i < N; i++) { 9 | int a = rand() % 10, b = rand() % 10; 10 | printf("%d %d\n", a, b); 11 | fprintf(stderr, "%d\n", a + b); 12 | } 13 | fflush(stdout); 14 | fflush(stderr); 15 | } 16 | 17 | int main() { 18 | int T; 19 | scanf("%d", &T); 20 | while (getchar() != -1) 21 | ; 22 | if (T == 1) 23 | gen(10); 24 | else if (T == 2) 25 | gen(1000); 26 | else if (T == 3) 27 | gen(1000000); 28 | else if (T == 4) 29 | gen(10000000); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /testsuite/seed2/tests/java_ac/seed2.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class Seed2 { 4 | public static void main(String[] args) { 5 | Scanner sc = new Scanner(System.in); 6 | String result; 7 | long lo = 1; 8 | long hi = 2000000000; 9 | long num; 10 | while (lo < hi) { 11 | num = (lo + hi) / 2; 12 | System.out.println(num); 13 | result = sc.nextLine(); 14 | if (result.equals("FLOATS")) 15 | hi = num; 16 | else if (result.equals("SINKS")) 17 | lo = num + 1; 18 | else 19 | break; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testsuite/seed2/tests/java8_grace/seed2.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class Seed2 { 4 | public static void main(String[] args) { 5 | Scanner sc = new Scanner(System.in); 6 | String result; 7 | long lo = 1; 8 | long hi = 2000000000; 9 | long num; 10 | while (lo < hi) { 11 | num = (lo + hi) / 2; 12 | System.out.println(num); 13 | result = sc.nextLine(); 14 | if (result.equals("FLOATS")) 15 | hi = num; 16 | else if (result.equals("SINKS")) 17 | lo = num + 1; 18 | else 19 | break; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testsuite/seed2/tests/java_grace/seed2.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class Seed2 { 4 | public static void main(String[] args) { 5 | Scanner sc = new Scanner(System.in); 6 | String result; 7 | long lo = 1; 8 | long hi = 2000000000; 9 | long num; 10 | while (lo < hi) { 11 | num = (lo + hi) / 2; 12 | System.out.println(num); 13 | result = sc.nextLine(); 14 | if (result.equals("FLOATS")) 15 | hi = num; 16 | else if (result.equals("SINKS")) 17 | lo = num + 1; 18 | else 19 | break; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /dmoj/contrib/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | import re 3 | from typing import Any, Dict, List, TYPE_CHECKING 4 | 5 | from dmoj.utils.load import get_available_modules, load_module, load_modules 6 | 7 | _recontribmodule = re.compile(r'([a-z]+)\.py') 8 | 9 | contrib_modules: Dict[str, Any] = {} 10 | 11 | 12 | def get_available() -> List[str]: 13 | return get_available_modules(_recontribmodule, os.path.dirname(__file__), None, None) 14 | 15 | 16 | def load_contrib_module(name: str) -> Any: 17 | return load_module(f'{__name__}.{name}', ()) 18 | 19 | 20 | def load_contrib_modules() -> None: 21 | load_modules(get_available(), load_contrib_module, 'ContribModule', contrib_modules, set()) 22 | -------------------------------------------------------------------------------- /dmoj/error.py: -------------------------------------------------------------------------------- 1 | from dmoj.utils.unicode import utf8text 2 | 3 | 4 | class CompileError(Exception): 5 | def __init__(self, message): 6 | super().__init__(utf8text(message, 'replace') or 'compiler exited abnormally') 7 | 8 | @property 9 | def message(self) -> str: 10 | return self.args[0] 11 | 12 | 13 | class InternalError(Exception): 14 | pass 15 | 16 | 17 | class OutputLimitExceeded(Exception): 18 | def __init__(self, stream, limit): 19 | super().__init__('exceeded %d-byte limit on %s stream' % (limit, stream)) 20 | 21 | 22 | class InvalidCommandException(Exception): 23 | def __init__(self, message=None): 24 | self.message = message 25 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor/tests/java_ac/seed2.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class Seed2 { 4 | public static void main(String[] args) { 5 | Scanner sc = new Scanner(System.in); 6 | String result; 7 | long lo = 1; 8 | long hi = 2000000000; 9 | long num; 10 | while (lo < hi) { 11 | num = (lo + hi) / 2; 12 | System.out.println(num); 13 | result = sc.nextLine(); 14 | if (result.equals("FLOATS")) 15 | hi = num; 16 | else if (result.equals("SINKS")) 17 | lo = num + 1; 18 | else 19 | break; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor/tests/java8_grace/seed2.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class Seed2 { 4 | public static void main(String[] args) { 5 | Scanner sc = new Scanner(System.in); 6 | String result; 7 | long lo = 1; 8 | long hi = 2000000000; 9 | long num; 10 | while (lo < hi) { 11 | num = (lo + hi) / 2; 12 | System.out.println(num); 13 | result = sc.nextLine(); 14 | if (result.equals("FLOATS")) 15 | hi = num; 16 | else if (result.equals("SINKS")) 17 | lo = num + 1; 18 | else 19 | break; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /contrib/vm-host-problem-watch/vm-host-problem-watch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | problem_storage_root="$(realpath "$1")" 4 | judge_hosts_file="$(realpath "$2")" 5 | 6 | echo "$(date): Start watching ${problem_storage_root}, notifying ${judge_hosts_file}" 7 | 8 | inotifywait -rm "${problem_storage_root}" -e move,create,delete -q | while read -r line; do 9 | if [ "$(echo "$line" | cut -d' ' -f3)" != "init.yml" ]; then 10 | continue 11 | fi 12 | echo "$(date): Update problems [$line]" 13 | readarray -t judges < "${judge_hosts_file}" 14 | for judge in "${judges[@]}"; do 15 | curl -4 -s -X POST "http://$judge/update/problems" | sed "s/^/$(date) [$judge]: /"';$a\' 16 | done 17 | done 18 | -------------------------------------------------------------------------------- /dmoj/control.py: -------------------------------------------------------------------------------- 1 | from http.server import BaseHTTPRequestHandler 2 | 3 | 4 | class JudgeControlRequestHandler(BaseHTTPRequestHandler): 5 | judge = None 6 | 7 | def update_problems(self): 8 | if self.judge is not None: 9 | self.judge.update_problems() 10 | 11 | def do_POST(self): 12 | if self.path == '/update/problems': 13 | self.log_message('Problem update requested.') 14 | self.update_problems() 15 | self.send_response(200) 16 | self.end_headers() 17 | self.wfile.write(b'As you wish.') 18 | return 19 | self.send_error(404) 20 | 21 | def do_GET(self): 22 | self.send_error(404) 23 | -------------------------------------------------------------------------------- /dmoj/executors/PRO.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from dmoj.executors.script_executor import ScriptExecutor 4 | 5 | 6 | class Executor(ScriptExecutor): 7 | ext = 'pl' 8 | command = 'swipl' 9 | test_program = """ 10 | :- set_prolog_flag(verbose,silent). 11 | :- prompt(_, ''). 12 | :- use_module(library(readutil)). 13 | 14 | main:- 15 | process, 16 | halt. 17 | 18 | process:- 19 | write('echo: Hello, World!'), nl, 20 | true. 21 | 22 | :- main. 23 | """ 24 | 25 | def get_cmdline(self, **kwargs) -> List[str]: 26 | command = self.get_command() 27 | assert command is not None 28 | return [command, '--goal=main', '-c', self._code] 29 | -------------------------------------------------------------------------------- /dmoj/executors/V8JS.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from dmoj.executors.base_executor import VersionFlags 4 | from dmoj.executors.script_executor import ScriptExecutor 5 | 6 | 7 | class Executor(ScriptExecutor): 8 | ext = 'js' 9 | command = 'v8dmoj' 10 | test_program = 'print(gets());' 11 | address_grace = 786432 12 | nproc = -1 13 | 14 | @classmethod 15 | def get_version_flags(cls, command: str) -> List[VersionFlags]: 16 | return [('-e', 'print(version())')] 17 | 18 | def get_cmdline(self, **kwargs) -> List[str]: 19 | command = self.get_command() 20 | assert command is not None 21 | return [command, '--stack-size=131072', self._code] # 128MB Stack Limit 22 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor_noflush/interactor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | inline void read(long long *i) { 5 | if (scanf("%lld", i) != 1 || *i < 1 || *i > 2000000000) 6 | exit(2); 7 | } 8 | 9 | int main(int argc, char *argv[]) { 10 | FILE *input_file = fopen(argv[1], "r"); 11 | int N, guesses = 0; 12 | long long guess; 13 | fscanf(input_file, "%d", &N); 14 | while (guess != N) { 15 | read(&guess); 16 | if (guess == N) { 17 | puts("OK"); 18 | } else if (guess > N) { 19 | puts("FLOATS"); 20 | } else { 21 | puts("SINKS"); 22 | } 23 | guesses++; 24 | } 25 | if (guesses <= 31) 26 | return 0; // AC 27 | else 28 | return 1; // WA 29 | } 30 | -------------------------------------------------------------------------------- /dmoj/checkers/identical.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from dmoj.checkers._checker import standard 4 | from dmoj.result import CheckerResult 5 | from dmoj.utils.unicode import utf8bytes 6 | 7 | 8 | def check(process_output: bytes, judge_output: bytes, pe_allowed: bool = True, **kwargs) -> Union[CheckerResult, bool]: 9 | if judge_output == process_output: 10 | return True 11 | feedback = None 12 | if pe_allowed and standard(utf8bytes(judge_output), utf8bytes(process_output)): 13 | # in the event the standard checker would have passed the problem, raise a presentation error 14 | feedback = 'Presentation Error, check your whitespace' 15 | return CheckerResult(False, 0, feedback=feedback) 16 | -------------------------------------------------------------------------------- /dmoj/executors/AWK.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from dmoj.executors.base_executor import VersionFlags 4 | from dmoj.executors.script_executor import ScriptExecutor 5 | 6 | 7 | class Executor(ScriptExecutor): 8 | ext = 'awk' 9 | command = 'awk' 10 | command_paths = ['mawk', 'gawk', 'awk'] 11 | syscalls = ['getgroups'] # gawk is annoying. 12 | test_program = '{ print $0 }' 13 | 14 | def get_cmdline(self, **kwargs) -> List[str]: 15 | command = self.get_command() 16 | assert command is not None 17 | return [command, '-f', self._code] 18 | 19 | @classmethod 20 | def get_version_flags(cls, command: str) -> List[VersionFlags]: 21 | return ['-Wversion', '--version'] 22 | -------------------------------------------------------------------------------- /testsuite/seed2/tests/java_mle/seed2.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class Seed2 { 4 | public static void main(String[] args) { 5 | int[] arr = new int[1000000000]; 6 | Scanner sc = new Scanner(System.in); 7 | String result; 8 | long lo = 1; 9 | long hi = 2000000000; 10 | long num; 11 | while (lo < hi) { 12 | num = (lo + hi) / 2; 13 | System.out.println(num); 14 | result = sc.nextLine(); 15 | if (result.equals("FLOATS")) 16 | hi = num; 17 | else if (result.equals("SINKS")) 18 | lo = num + 1; 19 | else 20 | break; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testsuite/shortest1/shortest1.py: -------------------------------------------------------------------------------- 1 | from dmoj.graders.standard import StandardGrader 2 | from dmoj.result import Result, CheckerResult 3 | 4 | 5 | class Grader(StandardGrader): 6 | def check_result(self, case, result): 7 | passed = bool(result.result_flag & Result.TLE) 8 | result.result_flag &= ~Result.TLE & ~Result.RTE & ~Result.IR 9 | return CheckerResult(passed, min((9. / len(self.source)) ** 5 * case.points, case.points) if passed else 0) 10 | 11 | def _interact_with_process(self, case, result): 12 | process = self._current_proc 13 | for handle in [process.stdin, process.stdout, process.stderr]: 14 | if handle: 15 | handle.close() 16 | process.wait() 17 | -------------------------------------------------------------------------------- /dmoj/cptbox/handlers.py: -------------------------------------------------------------------------------- 1 | import errno 2 | 3 | from dmoj.cptbox._cptbox import Debugger 4 | 5 | DISALLOW = 0 6 | ALLOW = 1 7 | _CALLBACK = 2 8 | 9 | 10 | class ErrnoHandlerCallback: 11 | errno: int 12 | error_name: str 13 | 14 | def __init__(self, error_name: str, errno: int) -> None: 15 | self.errno = errno 16 | self.error_name = error_name 17 | 18 | def __call__(self, debugger: Debugger) -> bool: 19 | def on_return(): 20 | debugger.errno = self.errno 21 | 22 | debugger.syscall = -1 23 | debugger.on_return(on_return) 24 | return True 25 | 26 | 27 | for code, name in errno.errorcode.items(): 28 | globals()[f'ACCESS_{name}'] = ErrnoHandlerCallback(name, code) 29 | -------------------------------------------------------------------------------- /testsuite/bridged_interactor/interactor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | inline void read(long long *i) { 5 | if (scanf("%lld", i) != 1 || *i < 1 || *i > 2000000000) 6 | exit(2); 7 | } 8 | 9 | int main(int argc, char *argv[]) { 10 | FILE *input_file = fopen(argv[1], "r"); 11 | int N, guesses = 0; 12 | long long guess; 13 | fscanf(input_file, "%d", &N); 14 | while (guess != N) { 15 | read(&guess); 16 | if (guess == N) { 17 | puts("OK"); 18 | } else if (guess > N) { 19 | puts("FLOATS"); 20 | } else { 21 | puts("SINKS"); 22 | } 23 | fflush(stdout); 24 | guesses++; 25 | } 26 | if (guesses <= 31) 27 | return 0; // AC 28 | else 29 | return 1; // WA 30 | } 31 | -------------------------------------------------------------------------------- /testsuite/helloworld/tests/sandbox_c_nametoolong_noat/nametoolong.c: -------------------------------------------------------------------------------- 1 | #define _DEFAULT_SOURCE 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | int main() { 10 | char buf[4352]; 11 | memset(buf, 'a', sizeof buf - 1); 12 | for (int i = 0; i < sizeof buf; i += 256) 13 | buf[i] = '/'; 14 | buf[sizeof buf - 1] = '\0'; 15 | 16 | int fd; 17 | if ((fd = syscall(SYS_open, buf, O_RDONLY)) >= 0) { 18 | close(fd); 19 | puts("Should not open the file"); 20 | } else if (errno == ENAMETOOLONG) { 21 | puts("Hello, World!"); 22 | } else { 23 | printf("Wrong errno: %d", errno); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /dmoj/cptbox/ptdebug_arm64.h: -------------------------------------------------------------------------------- 1 | #ifndef id6ef72cec_c4c7_4879_9591_5c984afaa8a5 2 | #define id6ef72cec_c4c7_4879_9591_5c984afaa8a5 3 | 4 | #include 5 | 6 | typedef union { 7 | struct user_pt_regs arm64; 8 | struct { 9 | uint32_t r0; 10 | uint32_t r1; 11 | uint32_t r2; 12 | uint32_t r3; 13 | uint32_t r4; 14 | uint32_t r5; 15 | uint32_t r6; 16 | uint32_t r7; 17 | uint32_t r8; 18 | uint32_t r9; 19 | uint32_t r10; 20 | uint32_t fp; 21 | uint32_t ip; 22 | uint32_t sp; 23 | uint32_t lr; 24 | uint32_t pc; 25 | uint32_t cpsr; 26 | uint32_t orig_r0; 27 | } arm32; 28 | } ptbox_regs; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # PR 630 - Autoformat all code with Black 2 | # https://github.com/DMOJ/judge-server/pull/630 3 | ece768dfd3d2915e011706cf12a37017b3f1f328 4 | 5 | # PR 703 - Strip files of carriage returns 6 | # https://github.com/DMOJ/judge-server/pull/703 7 | 4bba186a57aeb7113e6d81144300a14dc0e4e36b 8 | 9 | # PR 887 - Autoformat all code with Black (again) 10 | # https://github.com/DMOJ/judge-server/pull/887 11 | 153808669a9c3de3044510f76edb623ff4fae9f3 12 | 13 | # PR 888 - Add flake8-quotes and fix quoting issues 14 | # https://github.com/DMOJ/judge-server/pull/888 15 | efc9f427e003f97c258a8aa82b6ce2d6de643ca5 16 | 17 | # PR 941 - clang-format C code 18 | # https://github.com/DMOJ/judge-server/pull/941 19 | 55734c5d96d628d72b2f9b2c339bb94f55612e15 20 | -------------------------------------------------------------------------------- /dmoj/cptbox/ptdebug_x64.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef ida57e8432_9ad6_4c63_8376_bb4395f2c3aa 3 | #define ida57e8432_9ad6_4c63_8376_bb4395f2c3aa 4 | 5 | #include 6 | 7 | typedef union { 8 | struct user_regs_struct x64; 9 | struct { 10 | uint32_t ebx; 11 | uint32_t ecx; 12 | uint32_t edx; 13 | uint32_t esi; 14 | uint32_t edi; 15 | uint32_t ebp; 16 | uint32_t eax; 17 | uint32_t xds; 18 | uint32_t xes; 19 | uint32_t xfs; 20 | uint32_t xgs; 21 | uint32_t orig_eax; 22 | uint32_t eip; 23 | uint32_t xcs; 24 | uint32_t eflags; 25 | uint32_t esp; 26 | uint32_t xss; 27 | } x86; 28 | } ptbox_regs; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /dmoj/checkers/rstripped.py: -------------------------------------------------------------------------------- 1 | from re import split as resplit 2 | 3 | from dmoj.utils.unicode import utf8bytes 4 | 5 | 6 | def check(process_output: bytes, judge_output: bytes, **kwargs) -> bool: 7 | process_lines = resplit(b'[\r\n]', utf8bytes(process_output)) 8 | judge_lines = resplit(b'[\r\n]', utf8bytes(judge_output)) 9 | 10 | if kwargs.get('filter_new_line'): 11 | process_lines = list(filter(None, process_lines)) 12 | judge_lines = list(filter(None, judge_lines)) 13 | 14 | if len(process_lines) != len(judge_lines): 15 | return False 16 | 17 | for process_line, judge_line in zip(process_lines, judge_lines): 18 | if process_line.rstrip() != judge_line.rstrip(): 19 | return False 20 | 21 | return True 22 | -------------------------------------------------------------------------------- /dmoj/commands/rejudge.py: -------------------------------------------------------------------------------- 1 | from dmoj.commands.base_command import Command 2 | from dmoj.judge import Submission 3 | 4 | 5 | class RejudgeCommand(Command): 6 | name = 'rejudge' 7 | help = 'Rejudge a submission.' 8 | 9 | def _populate_parser(self) -> None: 10 | self.arg_parser.add_argument('submission_id', type=int, help='id of submission to rejudge') 11 | 12 | def execute(self, line: str) -> None: 13 | args = self.arg_parser.parse_args(line) 14 | problem_id, lang, src, tl, ml = self.get_submission_data(args.submission_id) 15 | 16 | self.judge.begin_grading( 17 | Submission(self.judge.submission_id_counter, problem_id, lang, src, tl, ml, False, {}), 18 | blocking=True, 19 | report=print, 20 | ) 21 | -------------------------------------------------------------------------------- /testsuite/bridged_checker_peg/check.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv) { 6 | std::ifstream judge_stream(argv[1]), output_stream(argv[2]), 7 | input_stream(argv[3]); 8 | std::string input_string, judge_string; 9 | int i; 10 | std::getline(input_stream, input_string); 11 | if (input_string != "This is the input file.") { 12 | return -1; 13 | } 14 | std::getline(judge_stream, judge_string); 15 | if (judge_string != "This is the judge file.") { 16 | return -1; 17 | } 18 | output_stream >> i; 19 | if (i == 10) { 20 | return 0; 21 | } else if (1 <= i && i < 10) { 22 | std::cout << i << "\n" << 10 << "\n"; 23 | return 1; 24 | } else { 25 | return 1; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /dmoj/executors/SWIFT.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from dmoj.cptbox.filesystem_policies import ExactFile, RecursiveDir 4 | from dmoj.executors.compiled_executor import CompiledExecutor 5 | 6 | 7 | class Executor(CompiledExecutor): 8 | ext = 'swift' 9 | command = 'swiftc' 10 | compiler_read_fs = [ 11 | RecursiveDir('~/.cache'), 12 | ExactFile('/proc/self/cmdline'), 13 | ] 14 | compiler_write_fs = [ 15 | RecursiveDir('~/.cache'), 16 | ] 17 | compiler_required_dirs = ['~/.cache'] 18 | test_program = 'print(readLine()!)' 19 | 20 | def get_compile_args(self) -> List[str]: 21 | command = self.get_command() 22 | assert command is not None 23 | assert self._code is not None 24 | return [command, self._code] 25 | -------------------------------------------------------------------------------- /dmoj/executors/D.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from dmoj.cptbox.filesystem_policies import ExactFile 4 | from dmoj.executors.compiled_executor import CompiledExecutor 5 | 6 | 7 | class Executor(CompiledExecutor): 8 | ext = 'd' 9 | address_grace = 32768 10 | command = 'dmd' 11 | compiler_read_fs = [ 12 | ExactFile('/etc/dmd.conf'), 13 | ] 14 | test_program = """\ 15 | import std.stdio; 16 | 17 | void main() { 18 | writeln(readln()); 19 | } 20 | """ 21 | source_filename_format = 'main.{ext}' 22 | 23 | def get_compile_args(self) -> List[str]: 24 | command = self.get_command() 25 | assert command is not None 26 | assert self._code is not None 27 | return [command, '-O', '-inline', '-release', '-w', self._code, f'-of{self.problem}'] 28 | -------------------------------------------------------------------------------- /dmoj/utils/error.py: -------------------------------------------------------------------------------- 1 | import errno 2 | import logging 3 | import os 4 | from typing import List, Optional, Tuple 5 | 6 | log = logging.getLogger('dmoj.cptbox') 7 | 8 | 9 | def print_protection_fault(fault: Tuple[int, str, List[int], Optional[int]]) -> None: 10 | syscall, callname, args, update_errno = fault 11 | if update_errno is not None: 12 | log.warning( 13 | 'Failed to alter system call: %d (%s) with error %d (%s): %s', 14 | syscall, 15 | callname, 16 | update_errno, 17 | errno.errorcode[update_errno], 18 | os.strerror(update_errno), 19 | ) 20 | else: 21 | log.warning('Protection fault on: %d (%s)', syscall, callname) 22 | for i, arg in enumerate(args): 23 | log.warning('Arg%d: 0x%016x', i, arg) 24 | -------------------------------------------------------------------------------- /dmoj/executors/NASM64.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.asm_executor import NASMExecutor, PlatformX64Mixin 2 | 3 | 4 | class Executor(PlatformX64Mixin, NASMExecutor): 5 | nasm_format = 'elf64' 6 | 7 | test_program = """\ 8 | section .text 9 | global _start 10 | 11 | _start: 12 | xor rax, rax 13 | xor rdi, rdi 14 | mov rsi, buffer 15 | mov rdx, 4096 16 | syscall 17 | 18 | test rax, rax 19 | jz _exit 20 | 21 | mov rdx, rax 22 | xor rax, rax 23 | inc rdi 24 | inc rax 25 | syscall 26 | 27 | jmp _start 28 | _exit: 29 | mov rax, 60 30 | xor rdi, rdi 31 | syscall 32 | 33 | section .bss 34 | buffer resb 4096 35 | """ 36 | -------------------------------------------------------------------------------- /dmoj/commands/locate.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | from dmoj import judgeenv 4 | from dmoj.commands.base_command import Command 5 | 6 | 7 | class LocateCommand(Command): 8 | name = 'locate' 9 | help = 'Locates the folders for problems available to be graded on this judge.' 10 | 11 | def _populate_parser(self) -> None: 12 | self.arg_parser.add_argument('problems', nargs='+', help='problems to locate') 13 | 14 | def execute(self, line: str) -> None: 15 | args = self.arg_parser.parse_args(line) 16 | 17 | problems = args.problems 18 | for problem in problems: 19 | root = judgeenv.get_problem_root(problem) 20 | if root is None: 21 | print(f'{problem} is not a valid problem, skipping', file=sys.stderr) 22 | else: 23 | print(root) 24 | -------------------------------------------------------------------------------- /.docker.test.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import platform 3 | 4 | from dmoj import judgeenv 5 | from dmoj.citest import ci_test 6 | from dmoj.executors import get_available 7 | 8 | arch = platform.machine() 9 | ALLOW_FAIL = {'GASARM', 'SWIFT'} 10 | EXECUTORS = get_available() 11 | 12 | if arch == 'aarch64': 13 | ALLOW_FAIL -= {'GASARM'} 14 | ALLOW_FAIL |= {'D', 'GAS32', 'GAS64', 'LEAN4', 'NASM', 'NASM64', 'TUR'} 15 | elif arch != 'x86_64': 16 | raise AssertionError('invalid architecture') 17 | 18 | OVERRIDES = {} 19 | 20 | 21 | def main(): 22 | logging.basicConfig(level=logging.INFO) 23 | 24 | judgeenv.env['runtime'] = {} 25 | judgeenv.env['extra_fs'] = {} 26 | 27 | print('Testing executors...') 28 | 29 | ci_test(EXECUTORS, OVERRIDES, ALLOW_FAIL) 30 | 31 | 32 | if __name__ == '__main__': 33 | main() 34 | -------------------------------------------------------------------------------- /dmoj/executors/NASM.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.asm_executor import NASMExecutor, PlatformX86Mixin 2 | 3 | 4 | class Executor(PlatformX86Mixin, NASMExecutor): 5 | nasm_format = 'elf32' 6 | 7 | test_program = """\ 8 | section .text 9 | global _start 10 | 11 | _start: 12 | mov eax, 3 13 | xor ebx, ebx 14 | mov ecx, buffer 15 | mov edx, 4096 16 | int 0x80 17 | 18 | test eax, eax 19 | jz _exit 20 | 21 | mov edx, eax 22 | inc ebx 23 | mov eax, 4 24 | int 80h 25 | 26 | jmp _start 27 | _exit: 28 | xor eax, eax 29 | xor ebx, ebx 30 | inc eax 31 | int 80h 32 | 33 | 34 | section .bss 35 | buffer resb 4096 36 | """ 37 | -------------------------------------------------------------------------------- /dmoj/executors/JAVA.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.java_executor import JavacExecutor 2 | 3 | 4 | class Executor(JavacExecutor): 5 | compiler = 'javac' 6 | vm = 'java' 7 | jvm_regex = r'(?:java-|openjdk)(?:9|[1-9][0-9]+)' 8 | 9 | test_program = """\ 10 | import java.io.IOException; 11 | 12 | interface IORunnable { 13 | public void run() throws IOException; 14 | } 15 | 16 | public class self_test { 17 | public static void run(IORunnable target) throws IOException { 18 | target.run(); 19 | } 20 | 21 | public static void main(String[] args) throws IOException { 22 | run(() -> { 23 | byte[] buffer = new byte[4096]; 24 | int read; 25 | while ((read = System.in.read(buffer)) >= 0) 26 | System.out.write(buffer, 0, read); 27 | }); 28 | } 29 | }""" 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | 3 | # IntelliJ/PyCharm 4 | .idea/ 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Packages 10 | *.egg 11 | *.egg-info 12 | dist 13 | build 14 | eggs 15 | parts 16 | bin 17 | var 18 | sdist 19 | develop-eggs 20 | .installed.cfg 21 | lib 22 | lib64 23 | __pycache__ 24 | .mypy_cache 25 | 26 | # Installer logs 27 | pip-log.txt 28 | 29 | # Unit test / coverage reports 30 | .coverage 31 | .tox 32 | nosetests.xml 33 | 34 | # Translations 35 | *.mo 36 | 37 | # Mr Developer 38 | .mr.developer.cfg 39 | .project 40 | .pydevproject 41 | 42 | *.vcxproj* 43 | *.opensdf 44 | *.sdf 45 | *.suo 46 | *.sln 47 | *.exe 48 | *.obj 49 | *.exp 50 | *.pdb 51 | 52 | # Vim 53 | [._]*.s[a-v][a-z] 54 | [._]*.sw[a-p] 55 | [._]s[a-rt-v][a-z] 56 | [._]ss[a-gi-z] 57 | [._]sw[a-p] 58 | 59 | # DMOJ 60 | dmoj/cptbox/_cptbox.cpp 61 | 62 | java_sandbox/objs/ 63 | 64 | env*/ 65 | README.rst 66 | -------------------------------------------------------------------------------- /dmoj/executors/HASK.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from dmoj.cptbox.filesystem_policies import RecursiveDir 4 | from dmoj.executors.compiled_executor import CompiledExecutor 5 | from dmoj.executors.mixins import NullStdoutMixin 6 | 7 | 8 | class Executor(NullStdoutMixin, CompiledExecutor): 9 | ext = 'hs' 10 | command = 'ghc' 11 | compiler_read_fs = [ 12 | RecursiveDir('/proc/self/task'), 13 | RecursiveDir('/var/lib/ghc'), 14 | ] 15 | syscalls = ['pselect6', 'timerfd_settime'] 16 | nproc = -1 17 | 18 | test_program = """\ 19 | main = do 20 | a <- getContents 21 | putStr a 22 | """ 23 | 24 | def get_compile_args(self) -> List[str]: 25 | command = self.get_command() 26 | assert command is not None 27 | assert self._code is not None 28 | return [command, '-O2', '-o', self.problem, self._code] 29 | -------------------------------------------------------------------------------- /.github/workflows/upload-pypi.yml: -------------------------------------------------------------------------------- 1 | name: upload-pypi 2 | on: 3 | push: 4 | tags: v* 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v3 10 | - name: Set up Python 3.9 11 | uses: actions/setup-python@v4 12 | with: 13 | python-version: '3.9' 14 | - name: Install build dependencies 15 | run: pip install cython 16 | - name: Create sdist 17 | run: python setup.py sdist 18 | - name: Install test dependencies 19 | run: sudo apt-get install -y libseccomp-dev 20 | - name: Test sdist 21 | run: | 22 | pip install dist/*.tar.gz 23 | dmoj-autoconf 24 | - name: Publish package to PyPI 25 | uses: pypa/gh-action-pypi-publish@v1.4.2 26 | with: 27 | user: __token__ 28 | password: ${{ secrets.pypi_password }} 29 | -------------------------------------------------------------------------------- /dmoj/tests/test_memory_io.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import unittest 4 | 5 | from dmoj.cptbox.utils import MemoryIO 6 | 7 | TEST_DATA = b'Hello, World!' 8 | 9 | 10 | class TestMemoryIO(unittest.TestCase): 11 | def test_read_back(self): 12 | with MemoryIO() as f: 13 | f.write(TEST_DATA) 14 | f.seek(0, os.SEEK_SET) 15 | self.assertEqual(f.read(), TEST_DATA) 16 | 17 | @unittest.skipIf(sys.platform.startswith('freebsd'), 'Sealing not supported on FreeBSD') 18 | def test_seal(self): 19 | with MemoryIO() as f: 20 | f.write(TEST_DATA) 21 | f.seal() 22 | 23 | f.seek(0, os.SEEK_SET) 24 | self.assertEqual(f.read(), TEST_DATA) 25 | 26 | with self.assertRaises(IOError): 27 | f.write(TEST_DATA) 28 | 29 | with self.assertRaises(IOError): 30 | f.truncate(0) 31 | -------------------------------------------------------------------------------- /dmoj/utils/setbufsize.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void _DMOJ_setbuffersize(void) __attribute__((constructor)); 5 | 6 | void _DMOJ_setbuffer(FILE *handle, char *env_str) { 7 | char *buf_env_str = getenv(env_str); 8 | if (buf_env_str != NULL) { 9 | char *end; 10 | unsigned long buf_size = strtoul(buf_env_str, &end, 10); 11 | if (*end == NULL) { 12 | // Need this branch since IOFBF when buf_size=0 actually 13 | // sets the buffer size to an OS-preferred, nonzero buffer 14 | if (buf_size) { 15 | setvbuf(handle, NULL, _IOFBF, buf_size); 16 | } else { 17 | setvbuf(handle, NULL, _IONBF, 0); 18 | } 19 | } 20 | } 21 | } 22 | 23 | void _DMOJ_setbuffersize(void) { 24 | _DMOJ_setbuffer(stdout, "CPTBOX_STDOUT_BUFFER_SIZE"); 25 | _DMOJ_setbuffer(stderr, "CPTBOX_STDERR_BUFFER_SIZE"); 26 | } 27 | -------------------------------------------------------------------------------- /dmoj/utils/ansi.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | from termcolor import colored 4 | 5 | 6 | def strip_ansi(s: str) -> str: 7 | # https://stackoverflow.com/questions/13506033/filtering-out-ansi-escape-sequences 8 | return re.sub(r'\x1b\[([0-9,A-Z]{1,2}(;[0-9]{1,2})?(;[0-9]{3})?)?[m|K]?', '', s) 9 | 10 | 11 | def ansi_style(text: str) -> str: 12 | from dmoj.judgeenv import no_ansi 13 | 14 | def format_inline(text, attrs): 15 | data = attrs.split('|') 16 | colors = data[0].split(',') 17 | if not colors[0]: 18 | colors[0] = None 19 | attrs = data[1].split(',') if len(data) > 1 else [] 20 | return colored(text, *colors, attrs=attrs) 21 | 22 | return re.sub( 23 | r'#ansi\[(.*?)\]\((.*?)\)', lambda x: format_inline(x.group(1), x.group(2)) if not no_ansi else x.group(1), text 24 | ) 25 | 26 | 27 | def print_ansi(*args, **kwargs) -> None: 28 | print(*map(ansi_style, args), **kwargs) 29 | -------------------------------------------------------------------------------- /dmoj/executors/MONOCS.py: -------------------------------------------------------------------------------- 1 | from typing import List, Tuple 2 | 3 | from dmoj.executors.mono_executor import MonoExecutor 4 | 5 | 6 | class Executor(MonoExecutor): 7 | ext = 'cs' 8 | command = 'mono-csc' 9 | command_paths = ['mono-csc', 'mcs', 'dmcs', 'gmcs'] 10 | 11 | test_program = """\ 12 | using System; 13 | 14 | class test { 15 | static void Main() { 16 | string line; 17 | while (!string.IsNullOrEmpty(line = Console.ReadLine())) 18 | Console.WriteLine(line); 19 | } 20 | }""" 21 | 22 | def get_compile_args(self) -> List[str]: 23 | command = self.get_command() 24 | assert command is not None 25 | assert self._code is not None 26 | return [command, self._code, '-r:System.Numerics.dll', f'-out:{self.get_compiled_file()}'] 27 | 28 | @classmethod 29 | def get_versionable_commands(cls) -> List[Tuple[str, str]]: 30 | return [('csc', cls.runtime_dict['mono-csc']), ('mono', cls.runtime_dict['mono'])] 31 | -------------------------------------------------------------------------------- /dmoj/checkers/__init__.pyi: -------------------------------------------------------------------------------- 1 | from typing import Protocol, Union 2 | 3 | from dmoj.result import CheckerResult 4 | 5 | CheckerOutput = Union[bool, CheckerResult] 6 | 7 | class CheckerCallable(Protocol): 8 | def __call__( 9 | self, 10 | process_output: bytes, 11 | judge_outputz: bytes, 12 | *, 13 | submission_source: bytes, 14 | judge_input: bytes, 15 | point_value: int, 16 | case_position: int, 17 | batch: int, 18 | submission_language: str, 19 | binary_data: bool, 20 | execution_time: float, 21 | problem_id: str, 22 | **kwargs 23 | ) -> CheckerOutput: ... 24 | 25 | class Checker(Protocol): 26 | check: CheckerCallable 27 | 28 | bridged: Checker 29 | easy: Checker 30 | floats: Checker 31 | floatsabs: Checker 32 | floatsrel: Checker 33 | identical: Checker 34 | linecount: Checker 35 | linematches: Checker 36 | rstripped: Checker 37 | sorted: Checker 38 | standard: Checker 39 | unordered: Checker 40 | -------------------------------------------------------------------------------- /dmoj/contrib/base.py: -------------------------------------------------------------------------------- 1 | from typing import TYPE_CHECKING 2 | 3 | from dmoj.executors.base_executor import BaseExecutor 4 | 5 | if TYPE_CHECKING: 6 | from dmoj.cptbox import TracedPopen 7 | 8 | 9 | class BaseContribModule: 10 | name: str 11 | AC = 0 12 | WA = 1 13 | 14 | @classmethod 15 | def get_checker_args_format_string(cls) -> str: 16 | raise NotImplementedError 17 | 18 | @classmethod 19 | def get_interactor_args_format_string(cls) -> str: 20 | raise NotImplementedError 21 | 22 | @classmethod 23 | def get_validator_args_format_string(cls) -> str: 24 | raise NotImplementedError 25 | 26 | @classmethod 27 | def parse_return_code( 28 | cls, 29 | proc: 'TracedPopen', 30 | executor: BaseExecutor, 31 | point_value: float, 32 | time_limit: float, 33 | memory_limit: int, 34 | feedback: str, 35 | name: str, 36 | stderr: bytes, 37 | ): 38 | raise NotImplementedError 39 | -------------------------------------------------------------------------------- /dmoj/sysinfo.py: -------------------------------------------------------------------------------- 1 | import os 2 | from multiprocessing import cpu_count as _get_cpu_count 3 | 4 | _cpu_count = _get_cpu_count() 5 | 6 | 7 | if hasattr(os, 'getloadavg'): 8 | 9 | def load_fair(): 10 | try: 11 | load = os.getloadavg()[0] / _cpu_count 12 | except OSError: # as of May 2016, Windows' Linux subsystem throws OSError on getloadavg 13 | load = -1 14 | return 'load', load 15 | 16 | else: 17 | # There exist some Unix platforms (like Android) which don't 18 | # have `getloadavg` implemented, but aren't Windows 19 | # so we manually read the `/proc/loadavg` file. 20 | def load_fair(): 21 | try: 22 | with open('/proc/loadavg', 'r') as f: 23 | load = float(f.read().split()[0]) / _cpu_count 24 | except FileNotFoundError: 25 | load = -1 26 | return 'load', load 27 | 28 | 29 | def cpu_count(): 30 | return 'cpu-count', _cpu_count 31 | 32 | 33 | report_callbacks = [load_fair, cpu_count] 34 | -------------------------------------------------------------------------------- /dmoj/commands/submissions.py: -------------------------------------------------------------------------------- 1 | from dmoj.commands.base_command import Command 2 | from dmoj.error import InvalidCommandException 3 | from dmoj.utils.ansi import print_ansi 4 | 5 | 6 | class ListSubmissionsCommand(Command): 7 | name = 'submissions' 8 | help = 'List past submissions.' 9 | 10 | def _populate_parser(self) -> None: 11 | self.arg_parser.add_argument( 12 | '-l', '--limit', type=int, help='limit number of results by most recent', metavar='' 13 | ) 14 | 15 | def execute(self, line: str) -> None: 16 | args = self.arg_parser.parse_args(line) 17 | 18 | if args.limit is not None and args.limit <= 0: 19 | raise InvalidCommandException('--limit must be >= 0') 20 | 21 | submissions = self.judge.graded_submissions if not args.limit else self.judge.graded_submissions[: args.limit] 22 | 23 | for i, (problem, lang, src, tl, ml) in enumerate(submissions): 24 | print_ansi(f'#ansi[{problem}](yellow)/#ansi[{i + 1}](green) in {lang}') 25 | print() 26 | -------------------------------------------------------------------------------- /.github/workflows/update-syscalls.yml: -------------------------------------------------------------------------------- 1 | name: update-syscalls 2 | on: 3 | schedule: 4 | - cron: '0 0 * * *' 5 | jobs: 6 | build: 7 | if: github.repository == 'DMOJ/judge-server' 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | - name: Set up Python 3.7 12 | uses: actions/setup-python@v4 13 | with: 14 | python-version: '3.7' 15 | - name: Update syscalls 16 | run: | 17 | cd dmoj/cptbox/syscalls 18 | python generate.py 19 | - name: Create pull request 20 | uses: peter-evans/create-pull-request@v4 21 | with: 22 | token: ${{ secrets.REPO_SCOPED_TOKEN }} 23 | author: dmoj-build 24 | committer: dmoj-build 25 | commit-message: 'cptbox: update syscall lists' 26 | title: 'Update syscall lists' 27 | body: This PR has been auto-generated to update the syscall definitions in `cptbox`. 28 | labels: cptbox, security, enhancement 29 | reviewers: Xyene, quantum5 30 | branch: update-syscalls 31 | -------------------------------------------------------------------------------- /dmoj/executors/PYPY.py: -------------------------------------------------------------------------------- 1 | from typing import List, Optional, Tuple 2 | 3 | from dmoj.executors.base_executor import RuntimeVersionList, VersionTuple 4 | from dmoj.executors.python_executor import PythonExecutor 5 | 6 | 7 | class Executor(PythonExecutor): 8 | command = 'pypy' 9 | pygments_traceback_lexer = 'py2tb' 10 | test_program = """ 11 | import sys 12 | if sys.version_info.major == 2: 13 | print sys.stdin.read() 14 | """ 15 | _pypy_versions: List[Tuple[int, ...]] 16 | 17 | @classmethod 18 | def parse_version(cls, command: str, output: str) -> Optional[VersionTuple]: 19 | try: 20 | cls._pypy_versions = [tuple(map(int, version.split('.'))) for version in cls.version_regex.findall(output)] 21 | return cls._pypy_versions[1] 22 | except Exception: 23 | return None 24 | 25 | @classmethod 26 | def get_runtime_versions(cls) -> RuntimeVersionList: 27 | # A little hack to report implemented Python version too 28 | return list(super().get_runtime_versions()) + [('implementing python', cls._pypy_versions[0])] 29 | -------------------------------------------------------------------------------- /dmoj/executors/SCM.py: -------------------------------------------------------------------------------- 1 | from typing import List, Tuple 2 | 3 | from dmoj.cptbox.filesystem_policies import RecursiveDir 4 | from dmoj.executors.base_executor import VersionFlags 5 | from dmoj.executors.compiled_executor import CompiledExecutor 6 | 7 | 8 | class Executor(CompiledExecutor): 9 | ext = 'scm' 10 | command = 'chicken-csc' 11 | command_paths = ['chicken-csc', 'csc'] 12 | compiler_read_fs = [ 13 | RecursiveDir('/var/lib/chicken'), 14 | ] 15 | test_program = '(import chicken.io) (map print (read-lines))' 16 | 17 | def get_compile_args(self) -> List[str]: 18 | command = self.get_command() 19 | assert command is not None 20 | assert self._code is not None 21 | return [command, self._code] 22 | 23 | @classmethod 24 | def get_versionable_commands(cls) -> List[Tuple[str, str]]: 25 | command = cls.get_command() 26 | assert command is not None 27 | return [('csc', command)] 28 | 29 | @classmethod 30 | def get_version_flags(cls, command: str) -> List[VersionFlags]: 31 | return ['-version'] 32 | -------------------------------------------------------------------------------- /dmoj/executors/LEAN4.py: -------------------------------------------------------------------------------- 1 | from dmoj.executors.compiled_executor import CompiledExecutor 2 | 3 | 4 | class Executor(CompiledExecutor): 5 | ext = 'lean' 6 | command = 'lean' 7 | test_program = """ 8 | def main : IO Unit := do 9 | let cin ← IO.getStdin 10 | let line ← cin.getLine 11 | IO.println line 12 | """ 13 | nproc = -1 14 | syscalls = ['eventfd2'] 15 | 16 | def compile(self) -> str: 17 | command = self.get_command() 18 | assert command is not None 19 | assert self._code is not None 20 | c_file = f'{self.problem}.c' 21 | 22 | # lean -c f2.c f1.lean && leanc -o f3 f2.c -O3 -DNDEBUG 23 | proc1 = self.create_compile_process([command, '-c', c_file, self._code]) 24 | out1 = self.get_compile_output(proc1) 25 | proc2 = self.create_compile_process([f'{command}c', '-o', self.problem, c_file, '-O3', '-DNDEBUG']) 26 | out2 = self.get_compile_output(proc2) 27 | 28 | self.warning = b'\n'.join(filter(None, [out1, out2])) 29 | self._executable = self.get_compiled_file() 30 | return self._executable 31 | -------------------------------------------------------------------------------- /dmoj/executors/NODEJS.py: -------------------------------------------------------------------------------- 1 | from dmoj.cptbox.filesystem_policies import ExactFile 2 | from dmoj.executors.script_executor import ScriptExecutor 3 | 4 | 5 | class Executor(ScriptExecutor): 6 | ext = 'js' 7 | command = 'node' 8 | nproc = -1 9 | command_paths = ['node', 'nodejs'] 10 | syscalls = [ 11 | 'capget', 12 | 'eventfd2', 13 | 'shutdown', 14 | 'pkey_alloc', 15 | 'pkey_free', 16 | ] 17 | address_grace = 1048576 18 | test_program = """ 19 | process.stdin.on('readable', () => { 20 | const chunk = process.stdin.read(); 21 | if (chunk != null) { 22 | process.stdout.write(chunk); 23 | } 24 | }); 25 | """ 26 | 27 | def get_env(self): 28 | env = super().get_env() 29 | # Disable io_uring due to potential security implications 30 | env['UV_USE_IO_URING'] = '0' 31 | return env 32 | 33 | def get_fs(self): 34 | return super().get_fs() + [ExactFile('/usr/lib/ssl/openssl.cnf')] 35 | 36 | @classmethod 37 | def get_version_flags(cls, command): 38 | return ['--version'] 39 | -------------------------------------------------------------------------------- /dmoj/commands/__init__.py: -------------------------------------------------------------------------------- 1 | from typing import List, Type 2 | 3 | from dmoj.commands.base_command import Command, commands, register_command 4 | from dmoj.commands.diff import DifferenceCommand 5 | from dmoj.commands.help import HelpCommand 6 | from dmoj.commands.locate import LocateCommand 7 | from dmoj.commands.problems import ListProblemsCommand 8 | from dmoj.commands.quit import QuitCommand 9 | from dmoj.commands.rejudge import RejudgeCommand 10 | from dmoj.commands.resubmit import ResubmitCommand 11 | from dmoj.commands.show import ShowCommand 12 | from dmoj.commands.submissions import ListSubmissionsCommand 13 | from dmoj.commands.submit import SubmitCommand 14 | from dmoj.commands.test import TestCommand 15 | from dmoj.commands.validate import ValidateCommand 16 | 17 | all_commands: List[Type[Command]] = [ 18 | ListProblemsCommand, 19 | ListSubmissionsCommand, 20 | SubmitCommand, 21 | ResubmitCommand, 22 | RejudgeCommand, 23 | DifferenceCommand, 24 | TestCommand, 25 | ShowCommand, 26 | LocateCommand, 27 | HelpCommand, 28 | QuitCommand, 29 | ValidateCommand, 30 | ] 31 | -------------------------------------------------------------------------------- /dmoj/executors/JAVA8.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from dmoj.executors.java_executor import JavacExecutor 4 | 5 | 6 | class Executor(JavacExecutor): 7 | compiler = 'javac8' 8 | vm = 'java8' 9 | jvm_regex = r'java-8-|jdk-8-|openjdk8|oracle-java8' 10 | 11 | test_program = """\ 12 | import java.io.IOException; 13 | 14 | interface IORunnable { 15 | public void run() throws IOException; 16 | } 17 | 18 | public class self_test { 19 | public static void run(IORunnable target) throws IOException { 20 | target.run(); 21 | } 22 | 23 | public static void main(String[] args) throws IOException { 24 | run(() -> { 25 | byte[] buffer = new byte[4096]; 26 | int read; 27 | while ((read = System.in.read(buffer)) >= 0) 28 | System.out.write(buffer, 0, read); 29 | }); 30 | } 31 | }""" 32 | 33 | def get_compile_args(self) -> List[str]: 34 | compiler = self.get_compiler() 35 | assert compiler is not None 36 | assert self._code is not None 37 | return [compiler, '-encoding', 'UTF-8', '-profile', 'compact1', self._code] 38 | -------------------------------------------------------------------------------- /dmoj/utils/unicode.py: -------------------------------------------------------------------------------- 1 | import codecs 2 | import sys 3 | from typing import AnyStr, Optional, overload 4 | 5 | 6 | @overload 7 | def utf8bytes(maybe_text: AnyStr) -> bytes: 8 | pass 9 | 10 | 11 | @overload 12 | def utf8bytes(maybe_text: None) -> None: 13 | pass 14 | 15 | 16 | def utf8bytes(maybe_text): 17 | if maybe_text is None: 18 | return None 19 | if isinstance(maybe_text, bytes): 20 | return maybe_text 21 | return maybe_text.encode('utf-8') 22 | 23 | 24 | @overload 25 | def utf8text(maybe_bytes: AnyStr, errors='strict') -> str: 26 | pass 27 | 28 | 29 | @overload 30 | def utf8text(maybe_bytes: None, errors='strict') -> None: 31 | pass 32 | 33 | 34 | def utf8text(maybe_bytes, errors='strict') -> Optional[str]: 35 | if maybe_bytes is None: 36 | return None 37 | if isinstance(maybe_bytes, str): 38 | return maybe_bytes 39 | return maybe_bytes.decode('utf-8', errors) 40 | 41 | 42 | def unicode_stdout_stderr(): 43 | sys.stdout = codecs.getwriter('utf-8')(open(sys.stdout.fileno(), 'wb', 0, closefd=False)) 44 | sys.stderr = codecs.getwriter('utf-8')(sys.stderr.detach()) 45 | -------------------------------------------------------------------------------- /dmoj/cptbox/helper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef idABBEC9C1_3EF3_4A45_B187B10060CB9F85 3 | #define idABBEC9C1_3EF3_4A45_B187B10060CB9F85 4 | 5 | #include 6 | 7 | #define PTBOX_SPAWN_FAIL_NO_NEW_PRIVS 202 8 | #define PTBOX_SPAWN_FAIL_SECCOMP 203 9 | #define PTBOX_SPAWN_FAIL_TRACEME 204 10 | #define PTBOX_SPAWN_FAIL_EXECVE 205 11 | #define PTBOX_SPAWN_FAIL_SETAFFINITY 206 12 | 13 | struct child_config { 14 | unsigned long memory; 15 | unsigned long address_space; 16 | unsigned int cpu_time; 17 | unsigned long personality; 18 | int nproc; 19 | int fsize; 20 | char *file; 21 | char *dir; 22 | char **argv; 23 | char **envp; 24 | int stdin_; 25 | int stdout_; 26 | int stderr_; 27 | int *seccomp_handlers; 28 | // 64 cores ought to be enough for anyone. 29 | unsigned long cpu_affinity_mask; 30 | }; 31 | 32 | void cptbox_closefrom(int lowfd); 33 | int cptbox_child_run(const struct child_config *config); 34 | 35 | char *bsd_get_proc_cwd(pid_t pid); 36 | char *bsd_get_proc_fdno(pid_t pid, int fdno); 37 | 38 | int cptbox_memfd_create(void); 39 | int cptbox_memfd_seal(int fd); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /dmoj/checkers/sorted.py: -------------------------------------------------------------------------------- 1 | from re import split as resplit 2 | from typing import Any, List 3 | 4 | from dmoj.error import InternalError 5 | from dmoj.utils.unicode import utf8bytes 6 | 7 | 8 | def check(process_output: bytes, judge_output: bytes, split_on: str = 'lines', **kwargs) -> bool: 9 | split_pattern = {'lines': b'[\r\n]', 'whitespace': br'[\s]'}.get(split_on) 10 | 11 | if not split_pattern: 12 | raise InternalError('invalid `split_on` mode') 13 | 14 | process_lines: List[Any] 15 | judge_lines: List[Any] 16 | 17 | process_lines = list(filter(None, resplit(split_pattern, utf8bytes(process_output)))) 18 | judge_lines = list(filter(None, resplit(split_pattern, utf8bytes(judge_output)))) 19 | 20 | if len(process_lines) != len(judge_lines): 21 | return False 22 | 23 | if split_on == 'lines': 24 | process_lines = list(map(bytes.split, process_lines)) 25 | judge_lines = list(map(bytes.split, judge_lines)) 26 | 27 | process_lines.sort() 28 | judge_lines.sort() 29 | 30 | for process_line, judge_line in zip(process_lines, judge_lines): 31 | if process_line != judge_line: 32 | return False 33 | 34 | return True 35 | -------------------------------------------------------------------------------- /dmoj/executors/PAS.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from dmoj.cptbox import TracedPopen 4 | from dmoj.cptbox.filesystem_policies import ExactFile 5 | from dmoj.executors.base_executor import VersionFlags 6 | from dmoj.executors.compiled_executor import CompiledExecutor 7 | 8 | 9 | class Executor(CompiledExecutor): 10 | ext = 'pas' 11 | command = 'fpc' 12 | compiler_read_fs = [ 13 | ExactFile('/etc/fpc.cfg'), 14 | ] 15 | compiler_time_limit = 20 16 | test_program = """\ 17 | var line : string; 18 | begin 19 | readln(line); 20 | writeln(line); 21 | end. 22 | """ 23 | 24 | def get_compile_args(self) -> List[str]: 25 | command = self.get_command() 26 | assert command is not None 27 | assert self._code is not None 28 | return [command, '-Fe/dev/stderr', '-O2', self._code] 29 | 30 | def get_compile_output(self, process: TracedPopen) -> bytes: 31 | output = super().get_compile_output(process) 32 | return output if b'Fatal:' in output or b'Warning:' in output or b'Note:' in output else b'' 33 | 34 | @classmethod 35 | def get_version_flags(cls, command: str) -> List[VersionFlags]: 36 | return ['-help'] 37 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | max-line-length = 120 3 | application-import-names = dmoj 4 | import-order-style = pycharm 5 | enable-extensions = G 6 | ignore = 7 | # for Black 8 | E203, E501, W503, 9 | # line break occurred after a binary operator 10 | W504, 11 | # allow only generator_stop and annotations future imports 12 | FI10,FI11,FI12,FI13,FI14,FI15,FI16,FI17,FI18,FI55,FI58, 13 | # missing trailing comma in Python 2 only 14 | C814, 15 | # trailing comma on bare tuple prohibited 16 | C818 17 | per-file-ignores = 18 | # F403: import *, F405: name comes from import * 19 | ./dmoj/cptbox/compiler_isolate.py:F403,F405 20 | ./dmoj/cptbox/isolate.py:F403,F405 21 | ./dmoj/cptbox/tracer.py:F403,F405 22 | # F821: undefined name, flake8 incorrectly thinks name is deleted 23 | ./dmoj/cptbox/syscalls.py:F821 24 | # F401: unused imports, ignore in all __init__.py 25 | ./*/__init__.py:F401 26 | # E101: mix tab and spaces, ignore in files that use tabs in ''' strings 27 | ./dmoj/executors/CBL.py:E101 28 | ./dmoj/executors/GAS32.py:E101 29 | ./dmoj/executors/GAS64.py:E101 30 | exclude = 31 | ./testsuite # The standard location for the test suite repository 32 | -------------------------------------------------------------------------------- /.freebsd.test.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from dmoj import judgeenv 4 | from dmoj.citest import ci_test 5 | 6 | EXECUTORS = [ 7 | 'AWK', 8 | 'C', 9 | 'C11', 10 | 'CPP03', 11 | 'CPP11', 12 | 'CPP14', 13 | 'CPP17', 14 | 'CLANG', 15 | 'CLANGX', 16 | 'F95', 17 | 'JAVA8', 18 | 'MONOCS', 19 | 'MONOFS', 20 | 'MONOVB', 21 | 'PAS', 22 | 'PERL', 23 | 'PY2', 24 | 'PY3', 25 | 'RUBY', 26 | 'SED', 27 | 'TEXT', 28 | ] 29 | OVERRIDES = {} 30 | 31 | 32 | def main(): 33 | judgeenv.env['runtime'] = {} 34 | judgeenv.env['extra_fs'] = { 35 | 'PERL': [{'exact_file': '/dev/dtrace/helper'}], 36 | 'RUBY': [{'exact_file': '/dev/dtrace/helper'}], 37 | } 38 | 39 | logging.basicConfig(level=logging.INFO) 40 | 41 | print('Using extra allowed filesystems:') 42 | for lang, fs in judgeenv.env['extra_fs'].iteritems(): 43 | for rules in fs: 44 | for access_type, file in rules.iteritems(): 45 | print('%-6s: %s: %s' % (lang, access_type, file)) 46 | print() 47 | 48 | print('Testing executors...') 49 | ci_test(EXECUTORS, OVERRIDES) 50 | 51 | 52 | if __name__ == '__main__': 53 | main() 54 | -------------------------------------------------------------------------------- /dmoj/tests/test_cpp_demangle.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from dmoj.utils.cpp_demangle import demangle 4 | 5 | 6 | class CppDemangleTest(unittest.TestCase): 7 | def test_valid_demangle(self): 8 | self.assertEqual(demangle(b'St9bad_alloc'), b'std::bad_alloc') 9 | self.assertEqual(demangle(b'_Z1hic'), b'h(int, char)') 10 | self.assertEqual(demangle(b'_ZN9wikipedia7article6formatEv'), b'wikipedia::article::format()') 11 | self.assertEqual( 12 | demangle(b'_ZN9wikipedia7article8print_toERSo'), b'wikipedia::article::print_to(std::ostream&)' 13 | ) 14 | self.assertEqual( 15 | demangle(b'_ZN9wikipedia7article8wikilinkC1ERKSs'), 16 | b'wikipedia::article::wikilink::wikilink(std::string const&)', 17 | ) 18 | self.assertEqual( 19 | demangle(b'_ZNK3MapI10StringName3RefI8GDScriptE10ComparatorIS0_E16DefaultAllocatorE3hasERKS0_'), 20 | b'Map, Comparator, DefaultAllocator>::has(StringName const&) const', 21 | ) 22 | 23 | def test_invalid_demangle(self): 24 | for invalid in [b'std::bad_alloc', b'\1\2\3\r\n']: 25 | self.assertEqual(demangle(invalid), invalid) 26 | -------------------------------------------------------------------------------- /dmoj/executors/MONOFS.py: -------------------------------------------------------------------------------- 1 | from typing import List, Tuple 2 | 3 | from dmoj.executors.base_executor import VersionFlags 4 | from dmoj.executors.mono_executor import MonoExecutor 5 | 6 | 7 | class Executor(MonoExecutor): 8 | ext = 'fs' 9 | command = 'fsharpc' 10 | compiler_time_limit = 20 11 | 12 | test_program = """\ 13 | open System 14 | 15 | [] 16 | let main argv = 17 | Console.WriteLine(Console.ReadLine()) 18 | 0 19 | """ 20 | 21 | def get_compile_args(self) -> List[str]: 22 | command = self.get_command() 23 | assert command is not None 24 | assert self._code is not None 25 | return [ 26 | command, 27 | '--nologo', 28 | '--optimize', 29 | '--tailcalls', 30 | f'--out:{self.get_compiled_file()}', 31 | self._code, 32 | ] 33 | 34 | @classmethod 35 | def get_version_flags(cls, command: str) -> List[VersionFlags]: 36 | return ['--help'] if command == cls.command else super().get_version_flags(command) 37 | 38 | @classmethod 39 | def get_versionable_commands(cls) -> List[Tuple[str, str]]: 40 | return [('fsharpc', cls.runtime_dict['fsharpc']), ('mono', cls.runtime_dict['mono'])] 41 | -------------------------------------------------------------------------------- /dmoj/checkers/linecount.py: -------------------------------------------------------------------------------- 1 | from re import split as resplit 2 | from typing import Union 3 | 4 | from dmoj.result import CheckerResult 5 | from dmoj.utils.unicode import utf8bytes 6 | 7 | verdict = '\u2717\u2713' 8 | 9 | 10 | def check( 11 | process_output: bytes, judge_output: bytes, point_value: float, feedback: bool = True, **kwargs 12 | ) -> Union[CheckerResult, bool]: 13 | process_lines = list(filter(None, resplit(b'[\r\n]', utf8bytes(process_output)))) 14 | judge_lines = list(filter(None, resplit(b'[\r\n]', utf8bytes(judge_output)))) 15 | 16 | if len(process_lines) > len(judge_lines): 17 | return False 18 | 19 | if not judge_lines: 20 | return True 21 | 22 | cases = [verdict[0]] * len(judge_lines) 23 | count = 0 24 | 25 | for i, (process_line, judge_line) in enumerate(zip(process_lines, judge_lines)): 26 | if process_line.strip() == judge_line.strip(): 27 | cases[i] = verdict[1] 28 | count += 1 29 | 30 | return CheckerResult( 31 | count == len(judge_lines), 32 | point_value * count / len(judge_lines), 33 | extended_feedback='Case Feedback:\n' + ''.join(cases) if feedback else '', 34 | ) 35 | 36 | 37 | check.run_on_error = True # type: ignore 38 | -------------------------------------------------------------------------------- /dmoj/utils/builtin_int_patch.py: -------------------------------------------------------------------------------- 1 | # type: ignore 2 | import sys 3 | 4 | # Drop to Python's limit, see https://github.com/python/cpython/issues/95778 5 | INT_MAX_NUMBER_DIGITS = getattr(sys.int_info, 'default_max_str_digits', 4300) 6 | int_ = int 7 | 8 | if isinstance(__builtins__, dict): 9 | builtins = __builtins__ 10 | else: 11 | builtins = __builtins__.__dict__ 12 | 13 | 14 | class patched_int_meta(type): 15 | def __instancecheck__(self, instance): 16 | return isinstance(instance, int_) 17 | 18 | def __subclasscheck__(cls, subclass): 19 | return issubclass(subclass, int_) 20 | 21 | def __eq__(self, other): 22 | return self is other or other is int_ 23 | 24 | def __hash__(self): 25 | return hash(int_) 26 | 27 | 28 | class patched_int(int_, metaclass=patched_int_meta): 29 | def __new__(cls, s=0, *args, **kwargs): 30 | if isinstance(s, str) and len(s) > INT_MAX_NUMBER_DIGITS: 31 | raise ValueError('integer is too long') 32 | if cls is patched_int: 33 | cls = int_ 34 | return int_.__new__(cls, s, *args, **kwargs) 35 | 36 | 37 | def apply(): 38 | builtins['int'], builtins['int_'] = patched_int, int_ 39 | 40 | 41 | def unapply(): 42 | builtins['int'] = int_ 43 | --------------------------------------------------------------------------------