From be2491b093b1f0ca430bede679ecbb670041e483 Mon Sep 17 00:00:00 2001
From: cassio
Date: Tue, 2 Jul 2013 09:46:45 +0400
Subject: restructuring of boca's git
---
README | 1 +
doc/.htaccess | 1 +
doc/ADMIN.txt | 469 +++++++
doc/APACHE.txt | 88 ++
doc/AUTOJUDGING.txt | 128 ++
doc/INSTALL.txt | 197 +++
doc/LICENSE.txt | 674 ++++++++++
doc/PC2_Team.tab | 6 +
doc/READMEubuntu.txt | 37 +
doc/READMEvm.txt | 167 +++
doc/Teams.tsv | 9 +
doc/acknowledgments.txt | 40 +
doc/changelog.txt | 197 +++
doc/dump.sh | 27 +
doc/html/.htaccess | 1 +
doc/html/manualjudge.en.html | 203 +++
doc/html/manualjudge.pt_br.html | 219 ++++
doc/html/manualteam.en.html | 198 +++
doc/html/manualteam.pt_br.html | 227 ++++
doc/import-user.txt | 114 ++
doc/problemexamples/abacaxi.zip | Bin 0 -> 22384 bytes
doc/problemexamples/abacaxi/compare/c | 97 ++
doc/problemexamples/abacaxi/compare/cpp | 97 ++
doc/problemexamples/abacaxi/compare/java | 97 ++
doc/problemexamples/abacaxi/compile/c | 172 +++
doc/problemexamples/abacaxi/compile/cpp | 172 +++
doc/problemexamples/abacaxi/compile/java | 189 +++
doc/problemexamples/abacaxi/compile/pas | 172 +++
.../abacaxi/description/abacaxi.txt | 1 +
.../abacaxi/description/problem.info | 3 +
doc/problemexamples/abacaxi/input/abacaxi | 25 +
doc/problemexamples/abacaxi/limits/c | 15 +
doc/problemexamples/abacaxi/limits/cpp | 15 +
doc/problemexamples/abacaxi/limits/java | 15 +
doc/problemexamples/abacaxi/output/abacaxi | 24 +
doc/problemexamples/abacaxi/run/c | 128 ++
doc/problemexamples/abacaxi/run/cpp | 128 ++
doc/problemexamples/abacaxi/run/java | 183 +++
doc/problemexamples/abacaxi/tests/c | 36 +
doc/problemexamples/bits.zip | Bin 0 -> 22200 bytes
doc/problemexamples/bits/compare/c | 97 ++
doc/problemexamples/bits/compare/cpp | 97 ++
doc/problemexamples/bits/compare/java | 97 ++
doc/problemexamples/bits/compile/c | 172 +++
doc/problemexamples/bits/compile/cpp | 172 +++
doc/problemexamples/bits/compile/java | 189 +++
doc/problemexamples/bits/compile/pas | 172 +++
doc/problemexamples/bits/description/bits.txt | 1 +
doc/problemexamples/bits/description/problem.info | 3 +
doc/problemexamples/bits/input/bits | 9 +
doc/problemexamples/bits/limits/c | 15 +
doc/problemexamples/bits/limits/cpp | 15 +
doc/problemexamples/bits/limits/java | 15 +
doc/problemexamples/bits/output/bits | 24 +
doc/problemexamples/bits/run/c | 128 ++
doc/problemexamples/bits/run/cpp | 128 ++
doc/problemexamples/bits/run/java | 183 +++
doc/problemexamples/bits/tests/c | 36 +
doc/problemexamples/formiga.zip | Bin 0 -> 22321 bytes
doc/problemexamples/formiga/compare/c | 97 ++
doc/problemexamples/formiga/compare/cpp | 97 ++
doc/problemexamples/formiga/compare/java | 97 ++
doc/problemexamples/formiga/compile/c | 172 +++
doc/problemexamples/formiga/compile/cpp | 172 +++
doc/problemexamples/formiga/compile/java | 189 +++
doc/problemexamples/formiga/compile/pas | 172 +++
.../formiga/description/formiga.txt | 1 +
.../formiga/description/problem.info | 3 +
doc/problemexamples/formiga/input/formiga | 15 +
doc/problemexamples/formiga/limits/c | 15 +
doc/problemexamples/formiga/limits/cpp | 15 +
doc/problemexamples/formiga/limits/java | 15 +
doc/problemexamples/formiga/output/formiga | 14 +
doc/problemexamples/formiga/run/c | 128 ++
doc/problemexamples/formiga/run/cpp | 128 ++
doc/problemexamples/formiga/run/java | 183 +++
doc/problemexamples/formiga/tests/c | 36 +
doc/problemexamples/gen_examples.sh | 17 +
doc/problemexamples/multas.zip | Bin 0 -> 24161 bytes
doc/problemexamples/multas/compare/c | 97 ++
doc/problemexamples/multas/compare/cpp | 97 ++
doc/problemexamples/multas/compare/java | 97 ++
doc/problemexamples/multas/compile/c | 172 +++
doc/problemexamples/multas/compile/cpp | 172 +++
doc/problemexamples/multas/compile/java | 189 +++
doc/problemexamples/multas/compile/pas | 172 +++
doc/problemexamples/multas/description/m.txt | 1 +
.../multas/description/problem.info | 3 +
doc/problemexamples/multas/input/file | 518 ++++++++
doc/problemexamples/multas/limits/c | 15 +
doc/problemexamples/multas/limits/cpp | 15 +
doc/problemexamples/multas/limits/java | 15 +
doc/problemexamples/multas/output/file | 466 +++++++
doc/problemexamples/multas/run/c | 128 ++
doc/problemexamples/multas/run/cpp | 128 ++
doc/problemexamples/multas/run/java | 183 +++
doc/problemexamples/multas/tests/c | 36 +
doc/problemexamples/problemtemplate.zip | Bin 0 -> 22267 bytes
doc/problemexamples/problemtemplate/compare/c | 97 ++
doc/problemexamples/problemtemplate/compare/cpp | 97 ++
doc/problemexamples/problemtemplate/compare/java | 97 ++
doc/problemexamples/problemtemplate/compile/c | 172 +++
doc/problemexamples/problemtemplate/compile/cpp | 172 +++
doc/problemexamples/problemtemplate/compile/java | 189 +++
doc/problemexamples/problemtemplate/compile/pas | 172 +++
.../problemtemplate/description/desc.txt | 1 +
.../problemtemplate/description/problem.info | 3 +
doc/problemexamples/problemtemplate/input/file1 | 1 +
doc/problemexamples/problemtemplate/limits/c | 15 +
doc/problemexamples/problemtemplate/limits/cpp | 15 +
doc/problemexamples/problemtemplate/limits/java | 15 +
doc/problemexamples/problemtemplate/output/file1 | 1 +
doc/problemexamples/problemtemplate/run/c | 128 ++
doc/problemexamples/problemtemplate/run/cpp | 128 ++
doc/problemexamples/problemtemplate/run/java | 183 +++
doc/problemexamples/problemtemplate/tests/c | 36 +
doc/tests/fontes/abacaxi-yes.c | 48 +
doc/tests/fontes/bits-compile.c | 5 +
doc/tests/fontes/bits-compile.cpp | 5 +
doc/tests/fontes/bits-compile.java | 23 +
doc/tests/fontes/bits-compile.pas | 27 +
doc/tests/fontes/bits-diffbug.c | 25 +
doc/tests/fontes/bits-incorrect.c | 17 +
doc/tests/fontes/bits-incorrect.cpp | 18 +
doc/tests/fontes/bits-incorrect.java | 23 +
doc/tests/fontes/bits-incorrect.pas | 27 +
doc/tests/fontes/bits-outputformat.c | 17 +
doc/tests/fontes/bits-outputformat.cpp | 17 +
doc/tests/fontes/bits-outputformat.java | 23 +
doc/tests/fontes/bits-outputformat.pas | 27 +
doc/tests/fontes/bits-runtime.c | 5 +
doc/tests/fontes/bits-runtime.cpp | 5 +
doc/tests/fontes/bits-runtime.java | 24 +
doc/tests/fontes/bits-runtime.pas | 27 +
doc/tests/fontes/bits-timelimit.c | 8 +
doc/tests/fontes/bits-timelimit.cpp | 8 +
doc/tests/fontes/bits-timelimit.java | 10 +
doc/tests/fontes/bits-timelimit.pas | 8 +
doc/tests/fontes/bits-yes.c | 17 +
doc/tests/fontes/bits-yes.cpp | 18 +
doc/tests/fontes/bits-yes.java | 23 +
doc/tests/fontes/bits-yes.pas | 27 +
doc/tests/fontes/formiga-yes.c | 68 ++
doc/tests/fontes/grid.java | 10 +
doc/tests/fontes/multas-yes.c | 85 ++
doc/tests/in_out/abacaxi.in | 25 +
doc/tests/in_out/abacaxi.sol | 24 +
doc/tests/in_out/bits.in | 9 +
doc/tests/in_out/bits.sol | 24 +
doc/tests/in_out/formiga.in | 15 +
doc/tests/in_out/formiga.sol | 14 +
doc/tests/in_out/multas.in | 518 ++++++++
doc/tests/in_out/multas.sol | 466 +++++++
index.html | 0
old/C.compare | 129 ++
old/C.run | 141 +++
old/Cpp.compare | 129 ++
old/Cpp.run | 142 +++
old/Java.compare | 129 ++
old/Java.run | 160 +++
old/Pascal.compare | 129 ++
old/Pascal.run | 107 ++
old/compare.sh | 129 ++
old/connect.php | 44 +
old/create-import-file.sh | 197 +++
old/getextdata.old | 931 ++++++++++++++
old/getextdata.php | 931 ++++++++++++++
old/import-system.txt | 78 ++
old/import.php | 280 +++++
old/import.txt | 1143 +++++++++++++++++
old/run.sh | 164 +++
old/updatescore.sh | 118 ++
old/webcast/config.php | 25 +
old/webcast/contest/index.php | 61 +
old/webcast/index.php | 1 +
old/webcast/runs/index.php | 41 +
old/webcast/time/index.php | 12 +
old/webcast/version/index.php | 10 +
src/.htaccess | 5 +
src/Css.php | 71 ++
src/Md5.js | 226 ++++
src/admin/answer.php | 134 ++
src/admin/buildproblem.php | 108 ++
src/admin/clar.php | 112 ++
src/admin/claredit.php | 171 +++
src/admin/contest.php | 256 ++++
src/admin/export.php | 121 ++
src/admin/files.php | 78 ++
src/admin/header.php | 88 ++
src/admin/index.php | 22 +
src/admin/language.php | 124 ++
src/admin/log.php | 76 ++
src/admin/option.php | 21 +
src/admin/problem.php | 414 +++++++
src/admin/report.php | 93 ++
src/admin/report/clar.php | 82 ++
src/admin/report/header.php | 65 +
src/admin/report/icpc.php | 46 +
src/admin/report/linechart.php | 45 +
src/admin/report/piechart.php | 68 ++
src/admin/report/run.php | 93 ++
src/admin/report/score.php | 43 +
src/admin/report/site.php | 128 ++
src/admin/report/stat.php | 343 ++++++
src/admin/report/task.php | 68 ++
src/admin/report/webcast.php | 190 +++
src/admin/run.php | 187 +++
src/admin/runedit.php | 320 +++++
src/admin/score.php | 21 +
src/admin/site.php | 605 +++++++++
src/admin/task.php | 147 +++
src/admin/user.php | 469 +++++++
src/balloon.php | 37 +
src/balloons/index.html | 0
src/db.php | 311 +++++
src/fanswer.php | 151 +++
src/favicon.ico | Bin 0 -> 894 bytes
src/fballoon.php | 60 +
src/fbkp.php | 172 +++
src/fclar.php | 490 ++++++++
src/fcontest.php | 1290 ++++++++++++++++++++
src/fextdata.php | 580 +++++++++
src/filedownload.php | 114 ++
src/filewindow.php | 120 ++
src/flanguage.php | 170 +++
src/flog.php | 229 ++++
src/footnote.php | 26 +
src/fproblem.php | 496 ++++++++
src/freport.php | 154 +++
src/frun.php | 1027 ++++++++++++++++
src/fscore.php | 357 ++++++
src/ftask.php | 515 ++++++++
src/fzip.php | 78 ++
src/globals.php | 331 +++++
src/hex.js | 98 ++
src/hex.php | 150 +++
src/hide.js | 28 +
src/images/12x16.ico | Bin 0 -> 894 bytes
src/images/a.png | Bin 0 -> 1319 bytes
src/images/balloon.jpeg | Bin 0 -> 1615 bytes
src/images/balloon.png | Bin 0 -> 5952 bytes
src/images/balloon1.png | Bin 0 -> 6593 bytes
src/images/balloon2.png | Bin 0 -> 4813 bytes
src/images/balloon3.png | Bin 0 -> 1350 bytes
src/images/balloon4.png | Bin 0 -> 1350 bytes
src/images/balloon5.bmp | Bin 0 -> 3474 bytes
src/images/bigballoon.png | Bin 0 -> 4338 bytes
src/images/bigballoon2.png | Bin 0 -> 2786 bytes
src/images/bigballoonboca.png | Bin 0 -> 6620 bytes
src/images/bigballoonboca1.png | Bin 0 -> 6011 bytes
src/images/bigballoontransp-blink.gif | Bin 0 -> 2578 bytes
src/images/bigballoontransp-hash.png | Bin 0 -> 3169 bytes
src/images/bigballoontransp-md5.png | Bin 0 -> 3450 bytes
src/images/bigballoontransp-md52.png | Bin 0 -> 3237 bytes
src/images/bigballoontransp.png | Bin 0 -> 2837 bytes
src/images/poweredbyboca.png | Bin 0 -> 1147 bytes
src/images/smallballoon.png | Bin 0 -> 811 bytes
src/images/smallballoontransp.png | Bin 0 -> 346 bytes
src/images/tst.php | 11 +
src/index.php | 143 +++
src/judge/clar.php | 124 ++
src/judge/claredit.php | 155 +++
src/judge/header.php | 98 ++
src/judge/history.php | 129 ++
src/judge/index.php | 22 +
src/judge/option.php | 21 +
src/judge/run.php | 84 ++
src/judge/runchief.php | 187 +++
src/judge/runedit.php | 250 ++++
src/judge/runeditchief.php | 320 +++++
src/judge/score.php | 21 +
src/judge/team.php | 195 +++
src/libchart/COPYING | 510 ++++++++
src/libchart/ChangeLog | 24 +
src/libchart/README | 45 +
src/libchart/classes/Axis.php | 167 +++
src/libchart/classes/BarChart.php | 172 +++
src/libchart/classes/Chart.php | 213 ++++
src/libchart/classes/Color.php | 74 ++
src/libchart/classes/HorizontalChart.php | 169 +++
src/libchart/classes/LineChart.php | 171 +++
src/libchart/classes/PieChart.php | 386 ++++++
src/libchart/classes/Point.php | 83 ++
src/libchart/classes/Primitive.php | 59 +
src/libchart/classes/Text.php | 139 +++
src/libchart/classes/VerticalChart.php | 169 +++
src/libchart/fonts/DejaVuSansCondensed-Bold.ttf | Bin 0 -> 62716 bytes
src/libchart/fonts/DejaVuSansCondensed.ttf | Bin 0 -> 73144 bytes
src/libchart/images/PoweredBy.png | Bin 0 -> 1608 bytes
src/libchart/libchart.php | 33 +
src/optionlower.php | 122 ++
src/php.php | 1 +
src/private/.htaccess | 1 +
src/private/autojudging.php | 490 ++++++++
src/private/conf.php | 60 +
src/private/createdb.php | 77 ++
src/private/createproblemzip.php | 111 ++
src/private/index.html | 0
src/private/insertlanguages.php | 57 +
src/private/problemtmp/.htaccess | 1 +
src/private/remotescores/otherservers | 4 +
src/private/runtmp/index.html | 0
src/private/score.sep | 23 +
src/private/scoretmp/index.html | 0
src/reload.js | 57 +
src/score/header.php | 72 ++
src/score/index.php | 21 +
src/score/score.php | 21 +
src/scorelower.php | 45 +
src/scoretable.php | 387 ++++++
src/sha256.js | 339 +++++
src/site/get.php | 167 +++
src/site/header.php | 88 ++
src/site/index.php | 312 +++++
src/site/putfile.php | 190 +++
src/staff/header.php | 74 ++
src/staff/index.php | 22 +
src/staff/option.php | 21 +
src/staff/score.php | 21 +
src/staff/task.php | 129 ++
src/system/contest.php | 214 ++++
src/system/header.php | 63 +
src/system/importxml.php | 245 ++++
src/system/index.php | 22 +
src/system/option.php | 21 +
src/team/clar.php | 113 ++
src/team/files.php | 123 ++
src/team/getfile.php | 47 +
src/team/header.php | 143 +++
src/team/index.php | 22 +
src/team/option.php | 21 +
src/team/problem.php | 58 +
src/team/run.php | 196 +++
src/team/score.php | 21 +
src/team/task.php | 121 ++
src/test.php | 16 +
src/version | 1 +
src/version.php | 30 +
src/versionnum.php | 5 +
tools/.htaccess | 1 +
tools/READMEubuntu.txt | 33 +
tools/READMEvm.txt | 163 +++
tools/autojudge.sh | 26 +
tools/etc/apache2/conf.d/boca | 15 +
tools/etc/cron.hourly/.placeholder | 2 +
tools/etc/cron.hourly/ntp | 2 +
tools/etc/icpc/becomeserver.sh | 213 ++++
tools/etc/icpc/bocaserver.sh | 1 +
tools/etc/icpc/cleandisk.sh | 4 +
tools/etc/icpc/createbocajail.sh | 122 ++
tools/etc/icpc/doclean.sh | 29 +
tools/etc/icpc/installboca.sh | 190 +++
tools/etc/icpc/restart.sh | 31 +
tools/etc/icpc/setup.sh | 91 ++
tools/etc/icpc/update.sh | 14 +
tools/etc/icpc/update.sh.tmp | 40 +
tools/etc/icpc/updatedbpass.sh | 84 ++
tools/etc/network/if-pre-up.d/boca | 25 +
tools/etc/network/if-up.d/boca | 17 +
tools/etc/rc.local | 34 +
tools/etc/sysctl.d/10-shmmax.conf | 2 +
tools/etc/sysctl.d/10-vm-swappiness.conf | 1 +
tools/fcontest.php | 1278 +++++++++++++++++++
tools/genpackage.sh | 51 +
tools/icpc.etc.tgz | Bin 0 -> 9525 bytes
tools/installv2.sh | 354 ++++++
tools/makebkp.sh | 32 +
tools/postgresql.conf.diffs | 5 +
tools/safeexec.c | 523 ++++++++
tools/sendscore.sh | 69 ++
tools/singlefilebkp.sh | 46 +
tools/updatescore.sh | 141 +++
372 files changed, 42920 insertions(+)
create mode 100644 README
create mode 100644 doc/.htaccess
create mode 100644 doc/ADMIN.txt
create mode 100644 doc/APACHE.txt
create mode 100644 doc/AUTOJUDGING.txt
create mode 100644 doc/INSTALL.txt
create mode 100644 doc/LICENSE.txt
create mode 100755 doc/PC2_Team.tab
create mode 100644 doc/READMEubuntu.txt
create mode 100644 doc/READMEvm.txt
create mode 100755 doc/Teams.tsv
create mode 100644 doc/acknowledgments.txt
create mode 100644 doc/changelog.txt
create mode 100755 doc/dump.sh
create mode 100644 doc/html/.htaccess
create mode 100644 doc/html/manualjudge.en.html
create mode 100644 doc/html/manualjudge.pt_br.html
create mode 100644 doc/html/manualteam.en.html
create mode 100644 doc/html/manualteam.pt_br.html
create mode 100644 doc/import-user.txt
create mode 100644 doc/problemexamples/abacaxi.zip
create mode 100755 doc/problemexamples/abacaxi/compare/c
create mode 100755 doc/problemexamples/abacaxi/compare/cpp
create mode 100755 doc/problemexamples/abacaxi/compare/java
create mode 100644 doc/problemexamples/abacaxi/compile/c
create mode 100644 doc/problemexamples/abacaxi/compile/cpp
create mode 100644 doc/problemexamples/abacaxi/compile/java
create mode 100644 doc/problemexamples/abacaxi/compile/pas
create mode 100644 doc/problemexamples/abacaxi/description/abacaxi.txt
create mode 100644 doc/problemexamples/abacaxi/description/problem.info
create mode 100644 doc/problemexamples/abacaxi/input/abacaxi
create mode 100644 doc/problemexamples/abacaxi/limits/c
create mode 100644 doc/problemexamples/abacaxi/limits/cpp
create mode 100644 doc/problemexamples/abacaxi/limits/java
create mode 100644 doc/problemexamples/abacaxi/output/abacaxi
create mode 100755 doc/problemexamples/abacaxi/run/c
create mode 100755 doc/problemexamples/abacaxi/run/cpp
create mode 100755 doc/problemexamples/abacaxi/run/java
create mode 100755 doc/problemexamples/abacaxi/tests/c
create mode 100644 doc/problemexamples/bits.zip
create mode 100755 doc/problemexamples/bits/compare/c
create mode 100755 doc/problemexamples/bits/compare/cpp
create mode 100755 doc/problemexamples/bits/compare/java
create mode 100644 doc/problemexamples/bits/compile/c
create mode 100644 doc/problemexamples/bits/compile/cpp
create mode 100644 doc/problemexamples/bits/compile/java
create mode 100644 doc/problemexamples/bits/compile/pas
create mode 100644 doc/problemexamples/bits/description/bits.txt
create mode 100644 doc/problemexamples/bits/description/problem.info
create mode 100644 doc/problemexamples/bits/input/bits
create mode 100644 doc/problemexamples/bits/limits/c
create mode 100644 doc/problemexamples/bits/limits/cpp
create mode 100644 doc/problemexamples/bits/limits/java
create mode 100644 doc/problemexamples/bits/output/bits
create mode 100755 doc/problemexamples/bits/run/c
create mode 100755 doc/problemexamples/bits/run/cpp
create mode 100755 doc/problemexamples/bits/run/java
create mode 100755 doc/problemexamples/bits/tests/c
create mode 100644 doc/problemexamples/formiga.zip
create mode 100755 doc/problemexamples/formiga/compare/c
create mode 100755 doc/problemexamples/formiga/compare/cpp
create mode 100755 doc/problemexamples/formiga/compare/java
create mode 100644 doc/problemexamples/formiga/compile/c
create mode 100644 doc/problemexamples/formiga/compile/cpp
create mode 100644 doc/problemexamples/formiga/compile/java
create mode 100644 doc/problemexamples/formiga/compile/pas
create mode 100644 doc/problemexamples/formiga/description/formiga.txt
create mode 100644 doc/problemexamples/formiga/description/problem.info
create mode 100644 doc/problemexamples/formiga/input/formiga
create mode 100644 doc/problemexamples/formiga/limits/c
create mode 100644 doc/problemexamples/formiga/limits/cpp
create mode 100644 doc/problemexamples/formiga/limits/java
create mode 100644 doc/problemexamples/formiga/output/formiga
create mode 100755 doc/problemexamples/formiga/run/c
create mode 100755 doc/problemexamples/formiga/run/cpp
create mode 100755 doc/problemexamples/formiga/run/java
create mode 100755 doc/problemexamples/formiga/tests/c
create mode 100755 doc/problemexamples/gen_examples.sh
create mode 100644 doc/problemexamples/multas.zip
create mode 100755 doc/problemexamples/multas/compare/c
create mode 100755 doc/problemexamples/multas/compare/cpp
create mode 100755 doc/problemexamples/multas/compare/java
create mode 100644 doc/problemexamples/multas/compile/c
create mode 100644 doc/problemexamples/multas/compile/cpp
create mode 100644 doc/problemexamples/multas/compile/java
create mode 100644 doc/problemexamples/multas/compile/pas
create mode 100644 doc/problemexamples/multas/description/m.txt
create mode 100644 doc/problemexamples/multas/description/problem.info
create mode 100644 doc/problemexamples/multas/input/file
create mode 100644 doc/problemexamples/multas/limits/c
create mode 100644 doc/problemexamples/multas/limits/cpp
create mode 100644 doc/problemexamples/multas/limits/java
create mode 100644 doc/problemexamples/multas/output/file
create mode 100755 doc/problemexamples/multas/run/c
create mode 100755 doc/problemexamples/multas/run/cpp
create mode 100755 doc/problemexamples/multas/run/java
create mode 100755 doc/problemexamples/multas/tests/c
create mode 100644 doc/problemexamples/problemtemplate.zip
create mode 100755 doc/problemexamples/problemtemplate/compare/c
create mode 100755 doc/problemexamples/problemtemplate/compare/cpp
create mode 100755 doc/problemexamples/problemtemplate/compare/java
create mode 100644 doc/problemexamples/problemtemplate/compile/c
create mode 100644 doc/problemexamples/problemtemplate/compile/cpp
create mode 100644 doc/problemexamples/problemtemplate/compile/java
create mode 100644 doc/problemexamples/problemtemplate/compile/pas
create mode 100644 doc/problemexamples/problemtemplate/description/desc.txt
create mode 100644 doc/problemexamples/problemtemplate/description/problem.info
create mode 100644 doc/problemexamples/problemtemplate/input/file1
create mode 100644 doc/problemexamples/problemtemplate/limits/c
create mode 100644 doc/problemexamples/problemtemplate/limits/cpp
create mode 100644 doc/problemexamples/problemtemplate/limits/java
create mode 100644 doc/problemexamples/problemtemplate/output/file1
create mode 100755 doc/problemexamples/problemtemplate/run/c
create mode 100755 doc/problemexamples/problemtemplate/run/cpp
create mode 100755 doc/problemexamples/problemtemplate/run/java
create mode 100755 doc/problemexamples/problemtemplate/tests/c
create mode 100644 doc/tests/fontes/abacaxi-yes.c
create mode 100644 doc/tests/fontes/bits-compile.c
create mode 100644 doc/tests/fontes/bits-compile.cpp
create mode 100644 doc/tests/fontes/bits-compile.java
create mode 100644 doc/tests/fontes/bits-compile.pas
create mode 100644 doc/tests/fontes/bits-diffbug.c
create mode 100644 doc/tests/fontes/bits-incorrect.c
create mode 100644 doc/tests/fontes/bits-incorrect.cpp
create mode 100644 doc/tests/fontes/bits-incorrect.java
create mode 100644 doc/tests/fontes/bits-incorrect.pas
create mode 100644 doc/tests/fontes/bits-outputformat.c
create mode 100644 doc/tests/fontes/bits-outputformat.cpp
create mode 100644 doc/tests/fontes/bits-outputformat.java
create mode 100644 doc/tests/fontes/bits-outputformat.pas
create mode 100644 doc/tests/fontes/bits-runtime.c
create mode 100644 doc/tests/fontes/bits-runtime.cpp
create mode 100644 doc/tests/fontes/bits-runtime.java
create mode 100644 doc/tests/fontes/bits-runtime.pas
create mode 100644 doc/tests/fontes/bits-timelimit.c
create mode 100644 doc/tests/fontes/bits-timelimit.cpp
create mode 100644 doc/tests/fontes/bits-timelimit.java
create mode 100644 doc/tests/fontes/bits-timelimit.pas
create mode 100644 doc/tests/fontes/bits-yes.c
create mode 100644 doc/tests/fontes/bits-yes.cpp
create mode 100644 doc/tests/fontes/bits-yes.java
create mode 100644 doc/tests/fontes/bits-yes.pas
create mode 100644 doc/tests/fontes/formiga-yes.c
create mode 100644 doc/tests/fontes/grid.java
create mode 100644 doc/tests/fontes/multas-yes.c
create mode 100644 doc/tests/in_out/abacaxi.in
create mode 100644 doc/tests/in_out/abacaxi.sol
create mode 100644 doc/tests/in_out/bits.in
create mode 100644 doc/tests/in_out/bits.sol
create mode 100644 doc/tests/in_out/formiga.in
create mode 100644 doc/tests/in_out/formiga.sol
create mode 100644 doc/tests/in_out/multas.in
create mode 100644 doc/tests/in_out/multas.sol
create mode 100644 index.html
create mode 100755 old/C.compare
create mode 100755 old/C.run
create mode 100755 old/Cpp.compare
create mode 100755 old/Cpp.run
create mode 100755 old/Java.compare
create mode 100755 old/Java.run
create mode 100755 old/Pascal.compare
create mode 100755 old/Pascal.run
create mode 100755 old/compare.sh
create mode 100644 old/connect.php
create mode 100755 old/create-import-file.sh
create mode 100644 old/getextdata.old
create mode 100644 old/getextdata.php
create mode 100644 old/import-system.txt
create mode 100644 old/import.php
create mode 100644 old/import.txt
create mode 100755 old/run.sh
create mode 100755 old/updatescore.sh
create mode 100644 old/webcast/config.php
create mode 100644 old/webcast/contest/index.php
create mode 120000 old/webcast/index.php
create mode 100644 old/webcast/runs/index.php
create mode 100644 old/webcast/time/index.php
create mode 100644 old/webcast/version/index.php
create mode 100644 src/.htaccess
create mode 100644 src/Css.php
create mode 100644 src/Md5.js
create mode 100644 src/admin/answer.php
create mode 100644 src/admin/buildproblem.php
create mode 100644 src/admin/clar.php
create mode 100644 src/admin/claredit.php
create mode 100644 src/admin/contest.php
create mode 100644 src/admin/export.php
create mode 100644 src/admin/files.php
create mode 100644 src/admin/header.php
create mode 100644 src/admin/index.php
create mode 100644 src/admin/language.php
create mode 100644 src/admin/log.php
create mode 100644 src/admin/option.php
create mode 100644 src/admin/problem.php
create mode 100644 src/admin/report.php
create mode 100644 src/admin/report/clar.php
create mode 100644 src/admin/report/header.php
create mode 100644 src/admin/report/icpc.php
create mode 100644 src/admin/report/linechart.php
create mode 100644 src/admin/report/piechart.php
create mode 100644 src/admin/report/run.php
create mode 100644 src/admin/report/score.php
create mode 100644 src/admin/report/site.php
create mode 100644 src/admin/report/stat.php
create mode 100644 src/admin/report/task.php
create mode 100644 src/admin/report/webcast.php
create mode 100644 src/admin/run.php
create mode 100644 src/admin/runedit.php
create mode 100644 src/admin/score.php
create mode 100644 src/admin/site.php
create mode 100644 src/admin/task.php
create mode 100644 src/admin/user.php
create mode 100644 src/balloon.php
create mode 100644 src/balloons/index.html
create mode 100644 src/db.php
create mode 100644 src/fanswer.php
create mode 100644 src/favicon.ico
create mode 100644 src/fballoon.php
create mode 100644 src/fbkp.php
create mode 100644 src/fclar.php
create mode 100644 src/fcontest.php
create mode 100644 src/fextdata.php
create mode 100644 src/filedownload.php
create mode 100644 src/filewindow.php
create mode 100644 src/flanguage.php
create mode 100644 src/flog.php
create mode 100644 src/footnote.php
create mode 100644 src/fproblem.php
create mode 100644 src/freport.php
create mode 100644 src/frun.php
create mode 100644 src/fscore.php
create mode 100644 src/ftask.php
create mode 100644 src/fzip.php
create mode 100755 src/globals.php
create mode 100644 src/hex.js
create mode 100644 src/hex.php
create mode 100644 src/hide.js
create mode 100644 src/images/12x16.ico
create mode 100644 src/images/a.png
create mode 100644 src/images/balloon.jpeg
create mode 100644 src/images/balloon.png
create mode 100644 src/images/balloon1.png
create mode 100644 src/images/balloon2.png
create mode 100644 src/images/balloon3.png
create mode 100644 src/images/balloon4.png
create mode 100644 src/images/balloon5.bmp
create mode 100644 src/images/bigballoon.png
create mode 100644 src/images/bigballoon2.png
create mode 100644 src/images/bigballoonboca.png
create mode 100644 src/images/bigballoonboca1.png
create mode 100644 src/images/bigballoontransp-blink.gif
create mode 100644 src/images/bigballoontransp-hash.png
create mode 100644 src/images/bigballoontransp-md5.png
create mode 100644 src/images/bigballoontransp-md52.png
create mode 100644 src/images/bigballoontransp.png
create mode 100644 src/images/poweredbyboca.png
create mode 100644 src/images/smallballoon.png
create mode 100644 src/images/smallballoontransp.png
create mode 100644 src/images/tst.php
create mode 100644 src/index.php
create mode 100644 src/judge/clar.php
create mode 100644 src/judge/claredit.php
create mode 100644 src/judge/header.php
create mode 100644 src/judge/history.php
create mode 100644 src/judge/index.php
create mode 100644 src/judge/option.php
create mode 100644 src/judge/run.php
create mode 100644 src/judge/runchief.php
create mode 100644 src/judge/runedit.php
create mode 100644 src/judge/runeditchief.php
create mode 100644 src/judge/score.php
create mode 100644 src/judge/team.php
create mode 100644 src/libchart/COPYING
create mode 100644 src/libchart/ChangeLog
create mode 100644 src/libchart/README
create mode 100644 src/libchart/classes/Axis.php
create mode 100644 src/libchart/classes/BarChart.php
create mode 100644 src/libchart/classes/Chart.php
create mode 100644 src/libchart/classes/Color.php
create mode 100644 src/libchart/classes/HorizontalChart.php
create mode 100644 src/libchart/classes/LineChart.php
create mode 100644 src/libchart/classes/PieChart.php
create mode 100644 src/libchart/classes/Point.php
create mode 100644 src/libchart/classes/Primitive.php
create mode 100644 src/libchart/classes/Text.php
create mode 100644 src/libchart/classes/VerticalChart.php
create mode 100644 src/libchart/fonts/DejaVuSansCondensed-Bold.ttf
create mode 100644 src/libchart/fonts/DejaVuSansCondensed.ttf
create mode 100644 src/libchart/images/PoweredBy.png
create mode 100644 src/libchart/libchart.php
create mode 100644 src/optionlower.php
create mode 100644 src/php.php
create mode 100644 src/private/.htaccess
create mode 100755 src/private/autojudging.php
create mode 100644 src/private/conf.php
create mode 100644 src/private/createdb.php
create mode 100755 src/private/createproblemzip.php
create mode 100644 src/private/index.html
create mode 100644 src/private/insertlanguages.php
create mode 100644 src/private/problemtmp/.htaccess
create mode 100644 src/private/remotescores/otherservers
create mode 100644 src/private/runtmp/index.html
create mode 100644 src/private/score.sep
create mode 100644 src/private/scoretmp/index.html
create mode 100644 src/reload.js
create mode 100644 src/score/header.php
create mode 100644 src/score/index.php
create mode 100644 src/score/score.php
create mode 100644 src/scorelower.php
create mode 100644 src/scoretable.php
create mode 100644 src/sha256.js
create mode 100644 src/site/get.php
create mode 100644 src/site/header.php
create mode 100644 src/site/index.php
create mode 100644 src/site/putfile.php
create mode 100644 src/staff/header.php
create mode 100644 src/staff/index.php
create mode 100644 src/staff/option.php
create mode 100644 src/staff/score.php
create mode 100644 src/staff/task.php
create mode 100644 src/system/contest.php
create mode 100644 src/system/header.php
create mode 100644 src/system/importxml.php
create mode 100644 src/system/index.php
create mode 100644 src/system/option.php
create mode 100644 src/team/clar.php
create mode 100644 src/team/files.php
create mode 100644 src/team/getfile.php
create mode 100644 src/team/header.php
create mode 100644 src/team/index.php
create mode 100644 src/team/option.php
create mode 100644 src/team/problem.php
create mode 100644 src/team/run.php
create mode 100644 src/team/score.php
create mode 100644 src/team/task.php
create mode 100644 src/test.php
create mode 100644 src/version
create mode 100644 src/version.php
create mode 100644 src/versionnum.php
create mode 100644 tools/.htaccess
create mode 100644 tools/READMEubuntu.txt
create mode 100644 tools/READMEvm.txt
create mode 100755 tools/autojudge.sh
create mode 100644 tools/etc/apache2/conf.d/boca
create mode 100644 tools/etc/cron.hourly/.placeholder
create mode 100755 tools/etc/cron.hourly/ntp
create mode 100755 tools/etc/icpc/becomeserver.sh
create mode 100755 tools/etc/icpc/bocaserver.sh
create mode 100755 tools/etc/icpc/cleandisk.sh
create mode 100755 tools/etc/icpc/createbocajail.sh
create mode 100755 tools/etc/icpc/doclean.sh
create mode 100755 tools/etc/icpc/installboca.sh
create mode 100755 tools/etc/icpc/restart.sh
create mode 100755 tools/etc/icpc/setup.sh
create mode 100644 tools/etc/icpc/update.sh
create mode 100644 tools/etc/icpc/update.sh.tmp
create mode 100755 tools/etc/icpc/updatedbpass.sh
create mode 100644 tools/etc/network/if-pre-up.d/boca
create mode 100644 tools/etc/network/if-up.d/boca
create mode 100755 tools/etc/rc.local
create mode 100644 tools/etc/sysctl.d/10-shmmax.conf
create mode 100644 tools/etc/sysctl.d/10-vm-swappiness.conf
create mode 100644 tools/fcontest.php
create mode 100755 tools/genpackage.sh
create mode 100644 tools/icpc.etc.tgz
create mode 100755 tools/installv2.sh
create mode 100755 tools/makebkp.sh
create mode 100644 tools/postgresql.conf.diffs
create mode 100644 tools/safeexec.c
create mode 100755 tools/sendscore.sh
create mode 100755 tools/singlefilebkp.sh
create mode 100755 tools/updatescore.sh
diff --git a/README b/README
new file mode 100644
index 0000000..ee99235
--- /dev/null
+++ b/README
@@ -0,0 +1 @@
+Please find the documentation (including the license) in the doc/ folder.
diff --git a/doc/.htaccess b/doc/.htaccess
new file mode 100644
index 0000000..3a42882
--- /dev/null
+++ b/doc/.htaccess
@@ -0,0 +1 @@
+Deny from all
diff --git a/doc/ADMIN.txt b/doc/ADMIN.txt
new file mode 100644
index 0000000..657e5fc
--- /dev/null
+++ b/doc/ADMIN.txt
@@ -0,0 +1,469 @@
+How to create a contest
+-----------------------
+(Last updated: 24/aug/2012 by cassio@ime.usp.br)
+
+(This file also explains details about problem packages, multi-site
+contests, and other relevant topics to run a contest. Please read it
+in full.)
+
+1) Log in as "system", empty password (or the password that is set in
+the file src/private/conf.php under name "basepass").
+
+2) Click on "Options" and change the password of
+the user "system" to something secret and safe.
+
+3a) (Most likely you don't want to do this item)
+If you have an import file, click on "Import",
+choose the file, click to Send it and go to step 4.
+Note that many follow steps will be already complete.
+However, take a time to look at them and verify if
+everything is ok.
+
+3b) Click on "Contest" and create a new contest
+(do it by choosing the "new" item of the combo).
+
+4) Change/Verify the information of the new created
+contest and click on "Send". Then click on
+"Activate" to make the new contest activated
+(after that you will be automatically logged off).
+Here some explanation about available fields:
+* Name: name of the contest
+* Start date: when the contest will begin
+* Duration: how many minutes the contest have
+* Stop answering: number of minutes from which
+teams don't receive the information if their
+runs were accepted or not. Usually choose 285
+for fifteen minutes without answers to teams.
+* Stop scoreboard: number of minutes from which
+the scoreboard becomes frozen (to keep the winner
+secret :-). Usual value: 240.
+* Penalty: number of minutes a team is penalized
+for each time it submits a code that is not
+accepted (this minutes are counted only if the
+team receives an YES for the corresponding problem,
+as done in ACM-ICPC like contests). Usual value: 20.
+* Max file size allowed for teams: for security reasons.
+If you know that source code files are larger, choose
+another value.
+* Contest main site number: which is the main site
+of the contest (in case of multi-site contests). Usually 1.
+IF RUNNING MULTIPLE SITES, BE SURE TO USE THE CORRECT
+NUMBERS HERE ASSIGNED BY WHOEVER IS COORDINATING
+THE MULTI-SITE CONTEST!!
+* Contest local site number: which is the number of the
+current site of the contest (in case of multi-site contests).
+IF RUNNING MULTIPLE SITES, BE SURE TO USE THE CORRECT
+NUMBERS HERE ASSIGNED BY WHOEVER IS COORDINATING
+THE MULTI-SITE CONTEST!!
+
+5) Log in as "admin", empty password (or the password that is set in
+the file src/private/conf.php under name "basepass").
+
+6) Click on "Options" and change the password of
+the user "admin" to something secret and SAFE!!
+
+7) (This can be probably skipped if they are already included, which
+is the case in the newest BOCA versions)
+Include any answers for submissions that you might
+like to have in addition to the standard ones.
+Click on "Answers" and use the two fields to input
+the answers. Already pre-included are:
+1 YES
+2 NO - Compilation error
+3 NO - Runtime error
+4 NO - Time limit exceeded
+5 NO - Presentation error
+6 NO - Wrong answer
+7 NO - If possible, contact staff
+Even the pre-included ones can be changed, but that is not
+recommended.
+
+If you make some mistake, you can re-insert the answer
+even without deleting it. Just fill up the fields again,
+repeating the answer number (first field). In this case
+the database record will be updated. But take care: any
+changes with the contest running will affect all records
+of the contest. Do not delete any record during the contest
+unless you really know what you are doing. The updates
+cascade on the database, removing or updating everywhere
+needed.
+
+8) (This can be probably skipped if they are already included, which
+is the case in the newest BOCA versions)
+Include the contest languages. Use the "Languages"
+item for it. Each language is defined by a number,
+a name and the extension of the source files in such language.
+(*** Note that BOCA versions prior to 1.5 had also the scripts for
+compiling and running the submitted codes, and one for verifying
+if the output generated is equilavent to the judge's output. Ignore
+this comments if you are running BOCA 1.5 or later.
+The scripts should be any executable file permitted
+in the computer that will run the autojudging
+environment (pay attetion on CRs or CRLFs for EOLs.
+This causes problems in some systems).
+It's also possible to import the language
+information from a file.
+The scripts are available together with BOCA in the
+"bits" example directory of the documentation. Usually
+values are:
+1 C C.run compare.sh
+2 C++ Cpp.run compare.sh
+3 Java Java.run compare.sh
+
+Remember, all these scripts are available on "bits" directory.
+Take some minutes to look into those script files, because
+they have path specifications for some executables, such as gcc,
+g++, javac, etc. These paths must be fixed (if needed) before
+uploading the file to BOCA. Usually the default values work
+just fine. This ends the part about BOCA prior to 1.5 **)
+
+For BOCA >= 1.5, all scripts to run the submission are inside the
+problem package. Please take a look into the examples in the directory
+doc/problemexamples/ and use them as basis for specifying new
+problems. Later on we discuss further how problems are specified.
+
+If you make some mistake, you can re-insert the language
+even without deleting it. Just fill up the fields again,
+repeating the language number (first field). In this case
+the database record will be updated. But take care: any
+changes with the contest running will affect all records
+of the contest. Do not delete any record during the contest
+unless you really know what you are doing. The updates
+cascade on the database, removing or updating everywhere
+necessary.
+
+
+9) Include the problems. Click on "Problems" and
+use the form available there. The fields are:
+* Number: number of the problem. Start with 1.
+* Name: nickname of the problem. Good choices are
+problem letters: A, B, C, D, etc. A good practice is to
+create the warm-up problems e.g. using letters plus a dot,
+like A., B., and then the contest problem with A, B, C, D...
+Then, to run the warm-up, one might delete all the contest
+problems, which later can be undeleted for the real contest,
+while the warm-up problem deleted. Do not forget to delete all
+clarification, runs, tasks and bkps between warump and real
+contest. This can be done from the tab Site (there are four buttons
+there, one for deleting each of these items).
+
+* Problem package (ZIP): a zip file (encrypted or not) containing
+all information about the problem. See below for a description
+of how this ZIP must be organized.
+* Color name: name of the color for this problem. It will
+be used if the balloon figure cannot be displayed.
+* Color (RGB): enter the rgb value, in the standard HTML
+format for colors, for this problem. E.g. 000000 is black,
+FFFFFF is white, FF0000 is red, 00FF00 is green and so on.
+Colors are interesting because BOCA presents the balloons
+with the problem colors. Nevertheless, they are not essential
+and can be left empty.
+
+If you make some mistake, you can re-insert the problem
+even without deleting it. Just fill up the fields again,
+repeating the problem number (first field). In this case
+the database record will be updated. But take care: any
+changes with the contest running will affect all records
+of the contest. Do not delete any record during the contest
+unless you really know what you are doing. The updates
+cascade on the database, removing or updating everywhere
+needed.
+
+===== ATTENTION: READ THIS CAREFULLY IF YOU ARE GOING
+===== TO CREATE YOUR OWN PROBLEM PACKAGE FILES. IF YOU
+===== ARE RUNNING A CONTEST THAT HAS THESE FILES ALREADY
+===== PREPARED FOR YOU, THEN THIS IS NOT SO IMPORTANT...
+PROBLEM PACKAGE: since BOCA 1.5, the problems are
+specified by a ZIP file, which shall have the following folders
+inside it:
+compare/
+compile/
+description/
+input/
+limits/
+output/
+run/
+tests/
+
+Inside compare/, compile/, limits/, runs/, there should be an
+executable (usually a shell script) with the name of each language
+extension that is configured in BOCA (within tab languages). The
+common files are c, cpp and java.
+Inside description/, there must exist a text file named problem.info,
+with the following lines:
+basename=shortfilename
+fullname=This is the problem full name
+descfile=desc.txt
+
+The left-side of this equalities are tags and must not be changed. The
+right-hand side are the values that must be specified.
+shortfilename is the name of the java class that must contain the main()
+function. This is the name that appears in the booklet of problems
+that is distributed to the teams. This is a mandatory field.
+"This is the problem full name" is to be replaced by the full name of
+the problem, as it appears in the booklet of problems. This is also a
+mandatory field. The line of descfile must contain the name of a file
+that will be made available for the teams in the BOCA interface. It is
+the description of the problem, and can have any format. Usual formats
+are .txt and .pdf files. This field is not mandatory, and this line
+can be removed if one does not want to make the problem description
+available inside BOCA.
+
+Inside input/ and output/ there must have files in a one-to-one
+correspondence and with the same filenames. Each file in input will be
+given as standard input to the code that has been submitted, and later
+the generated output will be compared to the file with same name that
+is in the output/ folder.
+
+The folder tests/ may contain any executable files that are meant to
+test the autojudge system in the first time it is run. To clarify all
+the steps, the workflow of the BOCA autojudge system, which dictates how
+the problem must be specified, is as follows:
+
+When a submission arrives for the first time for a given problem, the
+corresponding problem package is downloaded by the autojudge from the
+server. Then the autojudge reads the description/problem.info to
+obtain the basename of the problem, runs the scripts in the directory
+tests/ to check if everything is ok (the person who specified the
+problem package can include any desired code to be tested in such
+directory, and this code will be run and should return zero on success
+and non-zero otherwise), runs the scripts inside limits/ for each language
+to obtain the time-limits of the problem, and then proceeds to run the
+submission itself. If the problem had already been run by the
+autojudge, then these steps are not performed, but are cached and the
+information is reused later.
+
+To test a submission, the autojudge runs the script in the compile/
+folder corresponding to the language of the submission, which obtains
+an executable version of the code. Then the script of run/ for the
+given language is executed for each file in the input/ directory, and
+finally the script in compare/ is performed (again for the given
+language and every file in the output/ directory), checking if the
+results are correct.
+
+Take a look in the doc/problemexamples/.
+There is a script named gen_examples.sh with some command-lines
+to generated encrypted problem zip files. The main code for that is
+the script createproblemzip.php. If it is not to encrypt the problem
+file, then it is enough to zip the directory with the problem data as
+described, e.g. by doing:
+
+# cd doc/problemexamples
+# zip -r bits.zip bits/
+
+and the file bits.zip is to be included in the problem form of BOCA.
+
+
+10) Include the users. There are five types of users
+that can be used: admin, team, judge, staff and score.
+* admin: manage the contest. He(she) has access to every
+clarification, run, logs, tasks, etc of the contest.
+It is him(her) that starts and ends the competition
+(although it can be done automaticly by the system).
+You don't need to have more than one or two admin accounts. It is
+usually useful to have two admin accounts just in case you have any
+problem with one of them.
+* judge: responsible for judging the submission and
+answering the clarification. It's used to have from
+three to eight judges. Note that admins, judges and
+staff must have well formed complicated passwords.
+There is one judge, which is appointed by the admin using the tab
+"Site", which is designated as chief judge, and has some additional
+tasks such as fixing submission answers that are not in agreement
+among different judges.
+* staff: responsible for printing files, delivery
+balloons, helping teams with hardware problems, etc.
+Normally one staff account (for the chief staff person)
+is enough.
+* score: account with the scoreboard. It has no other
+privilegies. This account is good for making the coachs
+informed about the results and for making the results
+available to remote people. Usually a single score account is
+enough.
+* team: here is where the contest happens. These accounts
+are for the teams. It is safest to restrict the access of each team by
+IP addresses. The same thing may be done for the other users too
+(and it's a good practice to improve security).
+* site: the user of type site is only used as the means of
+communication between the main server and the local servers in a
+multi-site contest. On local sites, this user can be set up with
+standard data (and strong password). The details on how to step up a
+user of type site are usually given by the admin of the main site. The
+users of type "site" on the main server have an important
+characteristic: they are not allowed to directly log in to the main
+site, but connections are established from the local sites. On the
+main site, the ICPC ID (see below) of the user of type "site" must be
+a number corresponding to the site from which the connection will
+come. THIS IS AN IMPORTANT INFORMATION FOR MULTI-SITE CONTESTS ONLY.
+
+The users can be imported by a text file too. See
+IMPORT.txt for details.
+The fields presented in the "Users" item are:
+* User site number: number of the site of the user. Usually 1 in a
+single site contest. or the corresponding site number in a multi-site
+contest. PAY ATTENTION TO USE THE PROPER SITE NUMBER.
+* User number: number of the user (used internally
+by the system). Usually equals the team number, but doesn't have
+to. It only has to be a unique number among users.
+* Username: nickname of the user. Used to be
+team1, team2, team30, judge1, judge2, admin1, staff1, etc.
+It's possible to have the same usernumber and username
+in different sites. In a single site contest, all user numbers
+and usernames must be distinct.
+* ICPC ID: ID Number of team in the ICPC System. In case of users of
+type "site" for a multi-site contest, this field tells the site number
+of the user when connecting to the main server.
+* Type: type of the user (team, judge, staff, admin, score, site)
+* Enabled: is the user enabled?
+* Multilogins: can the user make more than one connection
+at the same time? It's not a problem to allow that if
+the users are restricted by IP numbers.
+* User full name: complete name of the user. In case of teams,
+it's convinient to put a short name for the team between [ ] and then
+the full name of the team. This does not include the institution
+name. E.g.
+"[Best Ever] Best team name ever created in history"
+
+* User description: some detail about the user, like institution name
+and students names. The rule of thumb is to have a short institution
+name between [ ], then the full institution name between another pair [ ],
+then any additional description that you may want to include. E.g.
+"[IME-USP][Institute of Maths and Statistics] Person1, Person2, Person3"
+
+* User IP: if set, it restricts from where the user can log in
+the system. It is recommended to restrict the logins by IP numbers.
+Check the IP numbers of the computers where the teams are supposed to
+be. If using ICPC linux, do not check the IP inside the virtual
+machine, but the IP of the actual computer where the virtual machine
+is run.
+* Password: choose strong passwords!
+
+If you make some mistake, you can alter the user fields.
+Click on the user number in the table and proceed to its
+fields below in the page. Edit them and resubmit. Note that,
+if you do not fill a new password, the old password is kept.
+IMPORTANT WARNING: for users, it is possible to click on
+a number for editting the information. All other admin flips
+regarding problems, answers, languages, etc do not follow the
+same idea. If you click on those number, the corresponding
+record will be removed, together with all database information
+related to that record. So DO NOT REMOVE ANYTHING DURING
+THE CONTEST.
+
+
+11) Configure the site data in the "Site" item. The fields
+are:
+* Site number: number of the site, with a "new" item to create
+new sites. This is not necessary for single-site contests. In
+multi-site contest, be sure to have your site number correctly
+assigned to you by whoever is running the main site.
+* Name: name of the site
+* Start date, End date, stop answering, stop score: equivalent
+to admin's contest page. Usually the default values are enough.
+* Runs/clars that will be judged here: for multi-site contest,
+it defines which runs/clars will be judged in this site. It
+is a list of site numbers, separated by commas. For a single
+site contest, just leave the site number here.
+* Tasks that will be treated here: same meaning of the
+previous field. For single contests or multi-site contest
+it's used to have each site treating its tasks. So leave here
+the number of the local site.
+* Active: is the site active? I hope yes.
+* Autoend: should the contest ends automaticly at the defined
+* time? Usually yes.
+* Globalscore: site numbers of the teams that should be included in
+the scoreboard. Not needed for single-site contests. For multi-site,
+this defines which information to include in the local scoreboard.
+* Autojudge: do not use this option for a contest unless you tested
+it and are fine with the results. It basically tell the autojudge to
+take final decisions about the submissions. In a real contest, it is
+ideal that a human judge check each of the submissions before sending
+the result to the teams.
+* Scorelevel: detail level of information on the scoreboard.
+0 means no details while 4 means maximum detail. 2 is a good
+choice, although, for single contests, 3 and 4 are also ok and
+more informative. A negative number means the same as its
+absolute value counterpart, but keeps the problem names hidden
+(useful when the same problem set is used in sites with very
+distinct start times).
+
+Furthermore, there are buttons for: start the contest,
+end the contest, delete completely (and without undo) the
+runs, clarifications and tasks of the site, disable logins,
+enable logins and force all users to log off.
+
+The start and stop buttons should not be used as the contest
+start and stop are automatic. They are just for special
+purpose, like a energy fault. In this case, you may, when
+energy supply become stable again, use the "Stop at" field and
+button to indicate when the contest should have stopped and
+then the "start now" button to re-start the contest. This will
+make the BOCA see this interval time as they never happened,
+and all penalty and time calculations will be made correctly.
+
+The "delete all" fields (delete all clars, delete all runs and
+delete all tasks, delete all bkps) are useful (AND IMPORTANT!)
+for cleaning everything up just after finished the warmup.
+Between the warmup and the real contest, you
+do not need to create another BOCA contest. Just delete all warmup
+problems, all clars, all tasks and all runs (keeping the languages,
+users and answers). Then undelete the problems of the real contest (if
+you have already included them), or enter them for the first time,
+reenter the contest information (start date and duration), and you are
+ready.
+
+12) It's all done.
+
+Important Note
+--------------
+Any deletion of problems, languages, answers, users, etc will
+promptly delete all records related. So deleting an answer
+will remove all runs with that answer. Deleting a problem
+will delete all clarifications and runs related to that
+problem. This way, it's not recommended to remove any of these
+things during the contest.
+
+===
+=== IMPORTANT INFORMATION FOR SITES WITH MANY TEAMS ===
+===
+Please read the file APACHE.txt
+
+===
+=== IMPORTANT INFORMATION FOR MULTI-SITE CONTESTS ===
+===
+If you are participating in a multi-site contest as a local site, you
+may simply wait for the main site to set up languages and problems for
+you. If you connect to the main site (by logging in with the user of
+type site you have created) and the problems are already defined
+there in the main site, then they will be downloaded to your site
+automatically. Other information, such as time of contest, inclusion
+of users, languages, etc, can all be downloaded from the main site if
+this has already been specified there. So the natural procedure is to
+create a user type "site" and log in with it, then enter the
+credentials to the main site (it will be asked after the log in) and
+see what information is already downloaded from the main site, before
+spending time included everything by yourself.
+===
+===
+
+Contacts and Copyrights
+-----------------------
+BOCA Copyright (c) 2003- Cassio Polpo de Campos (cassio@ime.usp.br)
+http://www.ime.usp.br/~cassio/boca
+
+////////////////////////////////////////////////////////////////////////////////
+//BOCA Online Contest Administrator
+// Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+////////////////////////////////////////////////////////////////////////////////
diff --git a/doc/APACHE.txt b/doc/APACHE.txt
new file mode 100644
index 0000000..998f0cf
--- /dev/null
+++ b/doc/APACHE.txt
@@ -0,0 +1,88 @@
+COMMENTS ON THE CONFIGURATION OF APACHE FOR LARGE SITES
+-----------------------------------------------------
+(File last updated on 25/October/2012)
+
+If you have a large site, for instance with more than 50 teams, then
+the best practice is to decrease the number of threads/servers that
+apache starts (yes, I said to DECREASE). The problem is that the computers
+are not so powerful, and apache is usually configured with too many of them.
+If there are too many requests, instead of queuing them, apache tries to
+answer all in parallel, and the server suffers a lot. This can be changed in the
+/etc/apache2/apache.conf file, as below (well, the exact values to use
+depend on your site, the original config has too high numbers):
+
+
+# prefork MPM
+# StartServers: number of server processes to start
+# MinSpareServers: minimum number of server processes which are kept spare
+# MaxSpareServers: maximum number of server processes which are kept spare
+# MaxClients: maximum number of server processes allowed to start
+# MaxRequestsPerChild: maximum number of requests a server process serves
+
+ StartServers 3
+ MinSpareServers 3
+ MaxSpareServers 6
+ MaxClients 40
+ MaxRequestsPerChild 0
+
+
+# worker MPM
+# StartServers: initial number of server processes to start
+# MinSpareThreads: minimum number of worker threads which are kept spare
+# MaxSpareThreads: maximum number of worker threads which are kept spare
+# ThreadLimit: ThreadsPerChild can be changed to this maximum value during a
+# graceful restart. ThreadLimit can only be changed by stopping
+# and starting Apache.
+# ThreadsPerChild: constant number of worker threads in each server process
+# MaxClients: maximum number of simultaneous client connections
+# MaxRequestsPerChild: maximum number of requests a server process serves
+
+ StartServers 2
+ MinSpareThreads 10
+ MaxSpareThreads 30
+ ThreadLimit 32
+ ThreadsPerChild 10
+ MaxClients 40
+ MaxRequestsPerChild 0
+
+
+# event MPM
+# StartServers: initial number of server processes to start
+# MinSpareThreads: minimum number of worker threads which are kept spare
+# MaxSpareThreads: maximum number of worker threads which are kept spare
+# ThreadsPerChild: constant number of worker threads in each server process
+# MaxClients: maximum number of simultaneous client connections
+# MaxRequestsPerChild: maximum number of requests a server process serves
+
+ StartServers 2
+ MinSpareThreads 10
+ MaxSpareThreads 30
+ ThreadLimit 32
+ ThreadsPerChild 10
+ MaxClients 40
+ MaxRequestsPerChild 0
+
+
+
+
+Contacts and Copyrights
+-----------------------
+BOCA Copyright (c) 2003- Cassio Polpo de Campos (cassio@ime.usp.br)
+http://www.ime.usp.br/~cassio/boca
+
+////////////////////////////////////////////////////////////////////////////////
+//BOCA Online Contest Administrator
+// Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+////////////////////////////////////////////////////////////////////////////////
diff --git a/doc/AUTOJUDGING.txt b/doc/AUTOJUDGING.txt
new file mode 100644
index 0000000..cf81f06
--- /dev/null
+++ b/doc/AUTOJUDGING.txt
@@ -0,0 +1,128 @@
+(Last updated 18/oct/2011 by cassio@ime.usp.br. See copyright notice below.)
+
+AUTOJUDGING.txt
+---------------
+
+To help the process of judging, the BOCA system provides
+a php script that is able to execute some user defined
+script in order to compile, execute and compare the output
+generated by teams with the correct output. This procedure
+is not essential to the system, since each judge is capable
+to download from BOCA all the files needed to evaluate a
+submission.
+
+The propose here is not to have a automated scheme for
+submission evaluation, but a supporting system that can
+help judges to do their job. In this way, the autojudging
+provides to the judge the data generated by the scripts
+when trying to compile, to execute and to compare the results.
+This data is presented in a formatted way during the judging
+process inside the BOCA web interface, and can help the
+judge to evaluate the submission. If the autojudging is
+not enabled in the contest, the judges will see just some
+"unavailable" texts when judging a submission, and they
+will have to execute the whole process by theirselves.
+
+To start the autojudging procedure, the only thing needed
+is to run the autojudging.php script from some commandline
+shell. Note that it may be necessary to change the permissions
+of private/conf.php file to something more readable and the php.ini
+file to turn safe_mode off (on the computer running the
+autojudging scheme). Furthermore, verify whether the private/conf.php
+options are correctly pointing to the postgresql server/users
+and if the current working directory (ie, ".") is included
+in the PATH environment variable.
+
+$ sudo /bin/bash
+# cd /var/www/boca/src
+# /var/www/boca/tools/autojudge.sh
+
+The autojudging.php will stay running until CRTL+C is
+pressed or it's killed by some other way. Autojudging waits
+for a new submission, takes it and executes the
+compiling/running/comparing scripts defined in BOCA for the
+corresponding language/problem (this information is all included
+in the problem package for each problem). More details about them
+are in the ADMIN.txt file and in the examples of the folder
+doc/problemexamples/
+
+As long as the autojudging php script will execute
+code from teams, these codes may contain malicious
+procedures. Thus it is essential that a dedicated
+computer be allocated only for the autojudging
+scheme. Furthermore, users with shell on this computer
+could eventually see important data which they should not
+be allowed. This computer must have the same requirements
+as the one running the BOCA web interface (but it
+does not need postgresql neither a running web server),
+and it needs to be configured properly. All the steps
+described in INSTALL.txt applies to this new computer,
+but three important things should be noted:
+
+(ATTENTION: IF YOU ARE USING THE ICPC LINUX VIRTUAL
+MACHINE, THEN ALL THE FOLLOWING SHOULD ALREADY
+BE DONE FOR YOU...)
+
+1) the computer must have a firewall that
+only permits connections between it and the main BOCA
+server (this is an important security issue). This is automatically
+done if you are using the ICPC linux virtual machine, which is in fact
+the best way to run the autojudging system.
+
+2) the src/private/conf.php file must be configure properly
+with the correct location of the boca database
+(probably it will be needed tcp/ip connection to
+the postgresql at the main BOCA server), the
+correct user/password for database access, the
+local IP number and the current contest number.
+
+3) the postgresql running at the main BOCA server
+will have to be configured to accept connections
+from the IP of the autojudging server. This can
+be achieved inserting the line
+
+host all all IPAUTOJUDGING 255.255.255.255 md5
+
+in the pg_hba.conf file at the main BOCA server, where IPAUTOJUDGING
+is to be replaced by the actual IP of the computer running the
+autojudging script. Note that if run within a virtual machine, one
+must take the IP of the host computer, not of the virtual machine for
+this configuration. If the postgresql server is already configured to
+accept incoming connections from all IPs, then this is not necessary.
+
+Talking a little bit more about the compiling/running
+script, it will be responsible for running the executable
+code generated from the team's source. This is exactly
+where the danger lives. To decrease the risk and to have
+control over the time spent by the team's code, the C
+source code safeexec.c (tools directory) should be used.
+It was designed to execute other programs with lower
+privilegies and with a time limit set. It is enough to
+run "gcc -O2 -o safeexec safeexec.c" for compiling and it is
+necessary to make a setuid root: "chown root.root safeexec"
+and "chmod 4555 safeexec" for running. This safeexec must be
+placed in a folder included in the path, usually copying it to
+/usr/bin will suffice: "cp -a safeexec /usr/bin" (note the -a)
+
+
+Contacts and Copyrights
+-----------------------
+BOCA Copyright (c) 2003- Cassio Polpo de Campos (cassio@ime.usp.br)
+http://www.ime.usp.br/~cassio/boca
+
+////////////////////////////////////////////////////////////////////////////////
+//BOCA Online Contest Administrator
+// Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+////////////////////////////////////////////////////////////////////////////////
diff --git a/doc/INSTALL.txt b/doc/INSTALL.txt
new file mode 100644
index 0000000..9c5fd57
--- /dev/null
+++ b/doc/INSTALL.txt
@@ -0,0 +1,197 @@
+(Last modified 24/aug/2012 by cassio@ime.usp.br. See Copyright note below.)
+
+Requirements
+------------
+The system was tested with:
+* postgresql 8.2+ / 9.1+
+* apache 2.2+
+* php 5.3+
+(Please see the specific needs below.)
+
+Installation
+------------
+
+Before following the steps, you must be sure of:
+* your php system is integrated with your web server,
+* the php extension module for the postgresql (e.g. php_pgsql.so)
+ is installed and configured,
+* the postgresql database management system is running.
+
+Usually that is true if you have installed the following ubuntu/debian
+packages, as given by an apt-get example line:
+
+apt-get install \
+postgresql postgresql-contrib postgresql-client apache2 \
+libapache2-mod-php5 php5 php5-cli php5-cgi php5-gd \
+php5-mcrypt php5-pgsql
+
+It may be needed to configure some parameters in php.ini,
+postgresql.conf and pg_hba.conf files. The following lines
+show some important attributes for BOCA:
+
+********* apache boca config file (to be created as /etc/apache2/conf.d/boca): **********
+
+ AllowOverride Options AuthConfig Limit
+ Order Allow,Deny
+ Allow from all
+ AddDefaultCharset utf-8
+
+
+ AllowOverride None
+ Deny from all
+
+
+ AllowOverride None
+ Deny from all
+
+
+ AllowOverride None
+ Deny from all
+
+
+********* /etc/postgresql/*/main/postgresql.conf: *********
+tcpip_socket = true #if using tcp to connect to database (older postgresqls)
+listen_addresses = '*' #newer postgresqls
+
+# THE FOLLOWING MAY BE GOOD FOR PERFORMANCE
+max_connections = 100
+maintenance_work_mem = 32MB
+shared_buffers = 512MB ## USE AROUND 1/3 OF YOUR RAM
+work_mem = 10MB
+effective_cache_size = 512MB ## USE AROUND 1/3 OF YOUR RAM
+
+Note that for doing these changes you will need to increase the SHMMAX
+parameter of your kernel, e.g. in file /etc/sysctl.d/10-shmmax.conf
+
+kernel.shmmax = 805416960
+kernel.shmall = 196635
+
+
+********* /etc/postgresql/*/main/pg_hba.conf: *********
+#this is the access control file
+#restricting connections from unixsocket or localhost is
+#the best choice, but it could not enough if the
+#database is not in the same machine.
+host all all 127.0.0.1 255.255.255.255 md5
+host all all 0.0.0.0 0.0.0.0 md5
+# this last line will allow connection from everywhere. If you
+# know the IP address of the machines that will serve as autojudging,
+# then you may restrict the access to only such machines. Anyway,
+# if you have a good password, that should not be a problem, as we
+# are not expecting this to be available on the internet but only on
+# the local net.
+
+***********
+*********** Steps for installing boca:
+
+1) Unpack the boca file into a internet world readable directory,
+according to the setting you chose in /etc/apache2/conf.d/boca,
+e.g.:
+# cd /var/www
+# tar xvzf boca-x.y.z.tar.gz
+# ln -s boca-x.y.z boca
+
+2) create a postgresql account with permission to create new
+databases (you need database admin privilegies to do that),
+e.g.:
+# psql -h 127.0.0.1 -U postgres -d template1
+template1=# create user bocauser with password 'boca' createdb;
+template1=# \q
+
+3) edit the file private/conf.php (placed where you unpacked boca),
+in order to set up the correct values for your system. E.g.:
+ $conf["dblocal"]="false"; // use unix socket to connect?
+ $conf["dbhost"]="localhost"; // ip address of the db
+ $conf["dbname"]="bocadb"; // name of the boca database
+ $conf["dbuser"]="bocauser"; // unpriviligied boca user
+ $conf["dbpass"]="boca"; // unpriviligied boca password
+ $conf["dbsuperuser"]="bocauser"; // priviligied boca user
+ $conf["dbsuperpass"]="boca"; // priviligied boca password
+ // note that it is just fine to use the same user for
+ // unpriv and priv access
+
+ // secret key to be used in HTTP headers
+ // you MUST set it with any random large enough sequence
+ // DONT LEAVE IT AS YOU GOT WHEN UNPACKED THE SOFTWARE
+ // CHOOSE ANOTHER NUMBER/STRING AND REPLACE BELOW
+ $conf["key"]="secretKey:23894091237589234759234723489";
+
+ // initial password that is used for the user admin -- set it
+ // to something hard to guess if the server is available
+ // online even in the moment you are creating the contest
+ // In this way, the new accounts for system and admin that are
+ // eventually created come already with the password set to this
+ // value. It is your task later to update these passwords to
+ // some other values within the BOCA web interface.
+ $conf["basepass"]="boca";
+
+ // the following field is used by the autojudging script
+ // set it with IP address (or other short description)
+ // of the computer allocated for
+ // autojudging during the competition
+ // this is only useful for debug purposes when multiple
+ // autojudges are being used
+ $conf["ip"]='10.10.10.10';
+
+4) run the php script to initialize the boca database. E.g.
+# cd /var/www/boca/src
+# php private/createdb.php
+
+5) It's all done. Now you have to manage the contest with a
+browser and boca. Proceed to the ADMIN.TXT file.
+
+========
+==> DETAIL ABOUT MIGRATING FROM POSTGRES 8.x TO 9.1
+LARGE OBJECTS GET WRONG OWNERSHIP. TO FIX, RUN WITHIN psql:
+# su - postgres
+# psql -d bocadb
+
+do $$
+declare r record;
+begin
+for r in select loid from pg_catalog.pg_largeobject loop
+execute 'ALTER LARGE OBJECT ' || r.loid || ' OWNER TO bocauser';
+end loop;
+end$$;
+\q
+========
+
+========
+Security Issue when BOCA server is not exclusively dedicated to BOCA
+--------------------------
+It is strongly recommended that BOCA be installed on a computer
+with no other users. If the computer where you are installing BOCA
+is used by others (with command line shells), it is essential
+that you change the permission of the file src/private/conf.php to be
+readable just by the user which the apache server runs and set
+safe_mode=On in the php.ini file (furthermore, the database access
+must be strictly restricted by passwords). Do it before configuring the
+src/private/conf.php file, so no one will be able to see your passwords.
+Moreover, the src/private/conf.php file must be in a directory owned by the
+bocauser or www-data or apache (all this combination implies that the only
+way to read the src/private/conf.php is from a php script owned by
+bocauser in the same directory).
+========
+
+========
+Contacts and Copyrights
+-----------------------
+BOCA Copyright (c) 2003- Cassio Polpo de Campos (cassio@ime.usp.br)
+http://www.ime.usp.br/~cassio/boca
+
+////////////////////////////////////////////////////////////////////////////////
+//BOCA Online Contest Administrator
+// Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+////////////////////////////////////////////////////////////////////////////////
diff --git a/doc/LICENSE.txt b/doc/LICENSE.txt
new file mode 100644
index 0000000..94a9ed0
--- /dev/null
+++ b/doc/LICENSE.txt
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/doc/PC2_Team.tab b/doc/PC2_Team.tab
new file mode 100755
index 0000000..ad6a1d7
--- /dev/null
+++ b/doc/PC2_Team.tab
@@ -0,0 +1,6 @@
+1783 1301 A Garotos de Programa Universidade Estadual do Norte do Paraná UENP http://www.uenp.edu.br/ Brazil Y
+1533 1301 A Calouro Verde Universidade Estadual do Norte do Paraná UENP http://www.uenp.edu.br/ Brazil Y
+1065 1289 P UGF-Coders Universidade Gama Filho UGF www.ugf.br Brazil Y
+1892 1203 P IFSC2012 IFSC - Instituto de FÃsica de São Carlos - USP IFSC-USP http://www.ifsc.usp.br Brazil Y
+1844 1286 A Team not Found Universidade Regional Integrada - Campus de Erechim URI - Erechim www.uricer.edu.br Brazil Y
+1843 1286 A Jokers Universidade Regional Integrada - Campus de Erechim URI - Erechim www.uricer.edu.br Brazil Y
diff --git a/doc/READMEubuntu.txt b/doc/READMEubuntu.txt
new file mode 100644
index 0000000..b3b1baa
--- /dev/null
+++ b/doc/READMEubuntu.txt
@@ -0,0 +1,37 @@
+ICPC Linux installation script
+----------------------------------
+Copyright (c) 2009-2012 BOCA System (bocasystem@gmail.com) and C. P. de Campos.
+Permission is granted to copy, distribute and/or modify this document
+ under the terms of the GNU Free Documentation License, Version 1.3
+ or any later version published by the Free Software Foundation;
+ with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+ A copy of the license is included in the section entitled "GNU
+ Free Documentation License".
+---------------------------------
+File last modified: 24/aug/2012
+
+==> The installv2.sh script is not necessary if you are using the virtual machine version. This is intended to those that
+want to install the system as the host of a computer, or desire to create again the virtual machine version from the beginning.
+
+The script installv2.sh available here was used to create the "ICPC Linux" image after a standard installation
+of the ubuntu (or xubuntu) distribution. This is well-suitable in case you do not want to
+use the virtualized version, for example, in the server of the contest. After using the installv2.sh script over a fresh
+install of the ubuntu, you reach the exactly same content of the virtual machine version that is available.
+Take care with the following points during the installation of the ubuntu:
+1) Use the name "icpcadmin" and password "icpcadmin" (no quotes obviously) as the standard user during the installation.
+2) Call the machine "icpc" (in the same screen where you set up the username above).
+3) Use the simplest partitioning option (that is, everything in a single partition) and choose at least 10GB for it.
+
+After installing ubuntu, the system reboots. Download the script installv2.sh to the home directory of icpcadmin,
+make it executable by chmod 755 installv2.sh, and run it as root:
+$ sudo /bin/bash
+# ./installv2.sh
+(if you already updated packages, then run ./installv2.sh alreadydone)
+
+and reboot the system to finish the configuration (such as setting passwords, IPs, etc).
+Note this is going to give you a system just like you would get from the box (the virtual machine version). If you
+want it to become a server, you must follow the same procedure that is indicated in the READMEvm.txt. This
+mainly means that you need to run the script /etc/icpc/becomeserver.sh
+
+The most recent installv2.sh script is available at http://www.ime.usp.br/~cassio/boca/ link named installv2.sh
+In case of any questions, do not hesitate to contact me: bocasystem@gmail.com. Have fun!
diff --git a/doc/READMEvm.txt b/doc/READMEvm.txt
new file mode 100644
index 0000000..7755c2d
--- /dev/null
+++ b/doc/READMEvm.txt
@@ -0,0 +1,167 @@
+READMEvm.txt file of the ICPC Linux VM (release 2012)
+=================================
+Copyright (c) 2009-2012 BOCA System (bocasystem@gmail.com) and C. P. de Campos.
+Permission is granted to copy, distribute and/or modify this document
+ under the terms of the GNU Free Documentation License, Version 1.3
+ or any later version published by the Free Software Foundation;
+ with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+ A copy of the license is included in the section entitled "GNU
+ Free Documentation License".
+=================================
+Last modified: 24/aug/2012
+
+This file concerns the ICPC Linux image available for virtualbox or vmware. It was created as a
+vmware-type hard-disk image with a system built up over a ubuntu (or xubuntu) distribution. This
+README is also relevant if you have used the installv2.sh script to build the server natively, as the
+system will have the exactly same characteristics of the VM version mentioned here.
+
+- You need the vmplayer from www.vmware.com to use this image. As far as I know, vmplayer is
+free-of-charge for linux and windows hosts. Check it. You can also use virtualbox, which
+is free and works pretty well too.
+
+- Internet access is restricted inside the box. By default, users can only access
+bombonera.ime.usp.br and bombonera.org, servers where BOCA is hosted. During the first boot time,
+you are able to choose a different IP address of your server instead of bombonera. If you are going to
+run a contest, you must do that! The system inside the virtual machine (or just VM) will
+only be able to access such server and nothing else. An alias with the name boca is created
+for such IP, so it is possible to connect to it using the name boca instead of typing the
+IP address. So, during the first initialization of each VM you should configure the IP address
+of your BOCA server. The image provided here can be used as a BOCA server too. See next bullets
+on how to do that. In the team machines, check if the internet is really blocked. If not, the
+initialization scripts might be malfunctioning, or the computer might be mistakenly set to be
+a server (this can be easily checked by verifying whether the file /etc/icpc/.isserver exists or not).
+
+- There are two linux users in the box: icpcadmin, which has right to become root using
+sudo, and the user icpc. The latter has password icpc, and more restricted access. The user
+icpc is intended to be used by the teams, judges, staff, or anyone else. The icpcadmin is
+an administrative account and the password must be known only by the sysadmin, director of the
+contest, and so on. During the first boot time, you are able to change the password of the icpcadmin
+account. DO IT and keep it safe! The default password is icpcadmin. Note that such
+users (icpcadmin and icpc) have nothing to do with users of the BOCA web system. Each
+team must have a distinct user to login on BOCA, which are configured through the BOCA web interface.
+Still, each team will logon into the linux box using the same user: icpc. As mentioned, this is
+not a security problem because the user icpc is just a local account in the linux system without
+any privileges.
+
+- To run a contest using a virtual machine, you probably need at least 384MB of RAM inside a
+"good" computer (then you can configure the VM to run with 256MB). I have tested the vm image
+configured to use 512MB. If your host has for example 1GB, you may change the vmplayer
+to use 768MB, although 512 should be fine too. Just keep some room for the underlying operating
+system. Using more memory inside the vm is better for the teams, so they can run heavier tools.
+
+- Unzipped, the image takes around 12 GB of your hard disk. You need this space in the hard
+disk of each computer. If this is a problem for you, it is possible to rebuild the vm system
+with less space (8GB for clients is enough, the server has to have more though).
+
+- It is possible to maximize the VM window so as it uses the whole screen area. The current
+image is set to 800x600 or 1024x768 pixels, but that can probably be increased depending on your
+video card and monitor settings. The keyboard config can also be changed
+inside the system configurations of ubuntu.
+
+- During the first startup, an script will ask you for the BOCA database password (after
+asking the BOCA server IP address and password of the icpcadmin). YOU MUST ONLY FILL
+SUCH PASSWORD IN THERE IF the machine being configured is NOT going to be used by a team. With
+this password, it will be possible to access the database directly (instead of by web). Teams
+shall access the system only by using the web interface. This password is intended to be used
+in the machine that will have the autojudging system, as the autojudging script needs to
+connect to the database directly (see next item about the autojudge). In fact only the
+autojudging machine (or machines, if you have more than one) need this password to be set.
+SO PAY ATTENTION TO ONLY SET THIS PASSWORD IN THE AUTOJUDGING MACHINES.
+
+- An autojugding machine is used to automatically compile and execute the codes submitted
+by the teams. DO NOT run it on the same computer as the BOCA server (the web server and the database
+server). Because teams may submit malicious code, it is only safe to run it on a separate computer.
+The worst scenario (in case a team's code hangs the computer) will require to reboot such
+computer. About the configuration, the only difference between the autojudge computer and
+team's computers is the setup of the database password, as mentioned before. You must set up
+the database password during the initialization of the autojudging computer. Then, to run the
+autojudging system, you need to login as icpcadmin (privileged user), open a command-line
+terminal (it is inside accessories), and run "sudo /var/www/boca/tools/autojudge.sh" (without quotes).
+If everything is fine, some dots will appear on the screen while the script runs an infinite
+loop waiting for submissions. Ctrl-C stops the autojudge. The autojudging shall be started
+after configuring the server to run the contest, otherwise it will eventually output an error or
+freeze. If you see the dots happening every few seconds, you are in the correct track. The dots mean
+the autojudging is running, but there are no submissions to process.
+
+- With old versions of ICPC Linux, all the team files were kept in the server. Now this is
+NOT true anymore. Everything is stored locally. So, after a warmup and before the real
+contest, it is necessary to go to each team computer, open a command-line shell (you do not
+need to change to the privileged user, the unprivilegied icpc user is enough) and run
+the command
+/etc/icpc/cleandisk.sh
+After that, reboot the system inside the virtual machine (not the host computer itself, only the VM!)
+and you are done. All files belonging to the icpc user have been erased.
+
+- Because the files are stored in the local team computers, now BOCA (by web) has an option
+to make file backups, where teams can save their files on the server. Currently this must be done
+manually by the teams (using the web interface of BOCA). There is a script available inside the
+ICPC linux (and inside the BOCA package) that teams may use to backup their files. To
+do that, they can just run "makebkp.sh". If they want to save other files, it is possible to use
+the web interface of the teams. Note that teams should submit backup files with small size only, but
+that is not a problem because source codes are really small. The script makebkp.sh is available
+(but not very tested) which sends files .c, .cpp, .java and .in (it looks for these files in the
+current directory) and send them to the server. IT IS IMPORTANT TO LET THE TEAMS KNOW ABOUT THIS
+SITUATION AND THE POSSIBILITY OF SAVING FILES TO THE SERVER, EITHER BY USING THE makebkp.sh IN
+THE COMMAND-LINE, OR BY DIRECTLY UPLOADING THE FILES IN THE WEB INTERFACE.
+
+- The most complicated thing to run the contest using a VM is that you need to restrict the
+use of the host operating system. For example, it would be possible for a team to switch
+the window (from the VM to another program), and then use the internet (in case you have
+internet available in the host, which is usually true). I believe that the simplest approach
+to restrict the system is to impose a set of packet filtering rules in the host system, using
+a firewall solution. That would make the host system useless for the team. The only permission
+that the host must have is to allow connections to the BOCA server and (possibly) to the
+authentication server of your network (in case it is needed to keep the host running. Better
+if that can be avoided too). If your host is linux, then it is easy: you just need to include some
+rules in the iptables (certainly a sysadmin knows how to do it).
+For windows (which is probably more usual and easy to deal with), there are many free-of-charge
+solutions. I do not know them well, but let me cite some: www.r-firewall.com,
+www.personalfirewall.comodo.com, tiny personal firewall (it is possible to find it online),
+perhaps the windows firewall can be enough (in some windows versions). NOW THE MOST COMMON /
+PRACTICAL WAY TO SOLVE THE PROBLEM: keep an eye on the teams all the time. Have some volunteers
+looking the teams work on the computers during the whole contest. No one is allowed to leave the
+VM and use the underlying system. If they do that, then simply expel them from the contest!
+Give a warn of the possible penalty to everyone before starting and that is it. Quick and clean :D
+
+- Any ICPC Linux VM can become a server for the contest, which in this case will be a BOCA server running
+inside a virtual machine system. To do that, you just need to login as user
+icpcadmin, become root using the command "sudo /bin/bash"
+and execute the script /etc/icpc/becomeserver.sh
+READ THE FULL TEXT BEFORE RUNNING THIS SCRIPT. THE VM, TO BECOME A SERVER, MUST BE SET TO BRIDGE
+MODE (see explanation below). At this moment, you will be prompted to define the DB password or use a
+random one. After that, the IP address of this computer must be used to configure all other VMs (during those
+startup questions).
+Some considerations about a server: more memory must be used for the server. Have a computer
+with enough memory and increase the memory of the VM. Also take care with the
+disk space. The current image has only a few gigabytes free (still, that must be more than enough).
+Finally, note that to run the VM as the server, it must be configured to run in BRIDGE mode
+with respect to the network interface, otherwise it will not be possible for other computers
+to reach it. BRIDGE mode means that you must look in your vmplayer (whatever player you are using)
+to configure the network as in BRIDGE mode. You may need to reboot the VM. If after rebooting it
+and running the command-line program "ifconfig" you can see that the IP address of your computer
+is the same inside the VM and outside, you are done. Besides that, the underlying (host) operating
+system must have NO apache or postgresql running, nor
+any other TCP server in the ports 80 (http), 443 (https) and 5432 (postgres). Otherwise this will create a
+conflict when running the BOCA server in the VM with BRIDGE mode.
+Yet I point out that running the BOCA system in a server computer (without the VM)
+is the mostly tested solution, but the VM version was used in many sites already. If you want to
+run it natively, stop here, get a ubuntu 12.04, install it, and run the installv2.sh script over it. See the
+file READMEubuntu.txt for more details. You will need a computer that you can format and reinstall.
+That is the simplest way of having a full ICPC linux server
+running apart from using the VM version itself, as explained here.
+
+- After having the server and clients running up, it is necessary to configure the BOCA
+web system. For that purpose, please follow the steps of the ADMIN.txt file in the doc/
+folder of the boca system. It is available in the BOCA package or inside the ICPC
+linux at /var/www/boca/doc/. There are some examples inside the subfolders there.
+
+- Try to use the vm without fear. In the worst case, download it again and start again
+(or even better, keep a copy of the image without changes). Any questions, please
+do not hesitate to contact me: bocasystem@gmail.com.
+
+- If you need to update the BOCA system that is running in your server (with the risk of losing
+data in the database of BOCA!), then you may run the script /etc/icpc/installboca.sh
+If you need to update general scripts that are used in the system and were installed by the
+installv2.sh procedure, you may run the script /etc/icpc/installscripts.sh
+These are easy ways to update the system in case bugs are found and fixed, without having to download
+again the whole VM image. Good luck and have fun!
diff --git a/doc/Teams.tsv b/doc/Teams.tsv
new file mode 100755
index 0000000..40476a1
--- /dev/null
+++ b/doc/Teams.tsv
@@ -0,0 +1,9 @@
+File_Version 1
+null 1488 1 The Goodfellas Universidade de São Paulo - Escola de Artes, Ciências e Humanidades EACH-USP BRA
+null 1487 2 FODUVA Universidade de São Paulo - Escola de Artes, Ciências e Humanidades EACH-USP BRA
+null 1486 2 Multi-thread Simultâneo (MTS) Universidade de São Paulo - Escola de Artes, Ciências e Humanidades EACH-USP BRA
+null 1485 2 SWR Universidade de São Paulo - Escola de Artes, Ciências e Humanidades EACH-USP BRA
+null 1484 2 USP Lost Universidade de São Paulo - Escola de Artes, Ciências e Humanidades EACH-USP BRA
+null 1483 1 UFRN-1 Universidade Federal do Rio Grande do Norte UFRN BRA
+null 1482 3 ineficiente Universidade Federal de Santa Catarina UF Santa Catarina BRA
+null 1481 1 Gargamel's team Universidade Federal de Santa Catarina UF Santa Catarina BRA
diff --git a/doc/acknowledgments.txt b/doc/acknowledgments.txt
new file mode 100644
index 0000000..c939d15
--- /dev/null
+++ b/doc/acknowledgments.txt
@@ -0,0 +1,40 @@
+BOCA Acknowledgments
+-------------------
+(last updated 25/October/2012)
+
+This is a very important file of BOCA. It gives a list of people we must acknowledge
+for having in a way or another helping BOCA reach its current development situation.
+They certainly deserve more much thanks than only this file, but it is away a begining.
+Moreover, many names are probably still missing here, so if you identify such a case,
+please let us know as soon as possible so as to include them here! This file has been
+created much after the begining of BOCA, so there will be many many missing names,
+do not be shine and do help us to fill this list! Also if you see some incoherency on the
+lists, let us know! Thanks!
+
+I will divide the list into two section: those who effectively contributed in ideas for the
+code, and those who found bugs and/or suggested modifications. Names are given in
+no particular order.
+
+CODE
+- Cassio P. de Campos
+- Fabio A. Avellaneda Pachon
+- Flavio G. C. Rocha
+- Humberto Longo
+- Fabio D. Moreira
+- Bruno C. Ribas
+- Alejandro Sazo
+- Jorge Luis R. Alvarez
+- Vinicius K. Ruoso
+
+
+REPORTERS/COMMENTATORS
+- Guillermo Solis
+- Alejandro S. de Loma
+- Cristian Ruz
+- Rodolfo J. de Azevedo
+- Carlos E. Ferreira
+- Ricardo Anido
+- Juan Pablo G. Ibarra
+- Ricardo Dahab
+- Liliane Salgado
+
diff --git a/doc/changelog.txt b/doc/changelog.txt
new file mode 100644
index 0000000..07684d4
--- /dev/null
+++ b/doc/changelog.txt
@@ -0,0 +1,197 @@
+version 1.5.2:
+(THIS VERSION IS IN DEVEL AND CAN BE CHANGED AT ANY TIME)
+- improve description of inbetween warmup and contest in ADMIN.txt
+- fix a bug that could allow an user to change their username
+- creation of an APACHE.txt doc about setting up apache configuration
+- force source files to have no spaces (warn a message in case they have)
+
+version 1.5.1:
+2012/10/20:
+- (ICPC Linux) fixed logging in issue after cleandisk.sh
+- (ICPC Linux) inclusion of some (new) suggested packages and links
+- updated safeexec (there was a timing issue between time-limit and run-time-error)
+- updated installboca.sh to account for different install directories
+- fix bug with the option that teams can't change their password. This was causing login problems.
+
+version 1.5.0:
+2012/08/24
+- (ICPC Linux) updated scripts to create ICPC linux under ubuntu
+ 12.04. Hopefully it will still work with older versions of ubuntu.
+- (ICPC Linux) java version now is openjdk6 (it is getting harder to
+ keep using sun java on new linux distributions)
+- Problems in BOCA are now defined by a problem package in ZIP format,
+ which can be encrypted.
+- private/score.sep file now allows also the specification of by-user
+ and by-site scoretables.
+- admin password need to change other users' passwords.
+- option to import users using the ICPC webpage formats (.tab and .tsv).
+- multi-site re-included in the system, with a centralized idea (one
+ main server and many local servers that connect to it). The
+ connection is done (encryptedly) via http and is handled by a new type of
+ user named type "site".
+- main site can provide redundancy in case of failure, as it has a
+ copy of everything.
+- autojudging scheme has been improved, specially in terms of
+ safety. Scripts to judge are now inside the problem package.
+- examples of problem packages are included in doc/problemexamples/
+- option to delete and undelete problems included, so one can setup
+ the warmup and contest with all problems, delete some, undelete later.
+- bug fix in updating time of contest and sites (updating contest
+ didn't update sites).
+- options to insert keys and password in the tab contest in order to
+ unlock problems in case they are encrypted.
+- documentation files updated.
+
+version 1.4.2:
+2011/11/04
+- user type site created to allow for pushing of scores from other sites
+- createdb.php moved to private/ for better safety. Option to abort its execution is included.
+- autojudging.php moved to private/ for better safety
+- possibility of multiple scores defined by the private/score.sep file
+- fix of setup.sh and rc.local scripts to properly set firewall rules (thanks Flavio GC Rocha).
+ Also some other minor script changes, such as /etc/network/if-pre-up.d/boca
+- script that creates the bocajail changed to /etc/icpc/createbocajail.sh and some
+ improvements are applied (e.g. use of debootstrap). It should now run smoother on
+ ubuntu and other debian-like systems.
+- bugfix: general clarification option was not appearing in the list of problems.
+- scripts have been updated to make it easy to replace the use of user 'www-data' by 'apache'.
+- updatescores.sh now accepts full path names for servers. This solves the case where boca
+ is not installed in the default http://SERVER/boca/
+- updatescores.sh now gets all the available information about the score of the other sites, and
+ the local boca server decides which info shall be put in the score board. This fixes issues with
+ displaying undesired info from other sites, because the responsability is given to local boca.
+- webcast directory for F. D. Moreira's fancy score included in the distro.
+
+version 1.4.1:
+2011/10/10
+- special chars and character encoding included as utf-8 in every page. This shall fix the
+ bug of dealing with special chars.
+- bug fix: max length of clars fixed.
+- bug fix: teams could not download their submitted code.
+- many changes to improve security of safeexec (including possibility of chrooting)
+- changes to improve security of conf.php
+- changes to make php configuration directly on .htaccess file of the boca folder
+- new feature: speed improvement by caching run.php of teams
+- new feature: speed improvement by caching scores of all users
+- new feature: scores can be read from files, which can be updated from other servers by a script
+- new feature: chief judge is introduced (configured at admin/site.php) and each run has to be
+ judged by two judges. In case of disagreement, chief judge or admin has to act.
+- new feature: judges can submit code to the system (even before the competition is running).
+- new feature: admin and chief judge can open multiple runs to re-judge at once in the same screen.
+- scripts to run code at doc/bits/ updated to cope with new safeexec and possible chrooting
+- directory doc/tools/ moved to tools/
+- directory doc/bits/ reorganized
+- development of install scripts and config files for making ubuntu/xubuntu be ready for running
+ a competition are included in tools/
+- simple html versions of manuals for teams and judges included in doc/html/
+
+version 1.4.0:
+2009/08/31
+- safeexec updated to include option of multiple runs of the same code (e.g. for averaging the time).
+
+version 1.3.2:
+2008/08/31
+- bug fix: div by zero at history of judges (thanks to Marcelo Cezar Pinto).
+- standard encoding changed to UTF8 to facilitate the installation on debian/ubuntu systems.
+- scripts to compile/execute runs changed to user nobody and group nogroup to fix a warning.
+
+version 1.3.1:
+2008/08/19
+- bug fix: filenames with spaces were not properly handled by filewindow.php and filedownload.php
+- delete functions of languages, problems and answers are replaced by nicer versions where the runs
+ are kept in the system (Thanks to Renato Lucindo :).
+- openrun feature now does not make the run completely reopened (the teams keep seeing the already
+ judged results, while the runs are rejudged. If a change is performed, then the new status is seen.
+- autojudging procedure now keeps a copy of input and output files in the local filesystem, so the
+ network and DB accesses are reduced (Thanks to huge files of Wanderley Guimaraes :).
+- bug fix: autojudging was not removing old directories, so that was taking extra space on disk. I
+ do not know if this was a bug or a feature.
+- script makebkp.sh added to connect to BOCA by http and send source files.
+
+version 1.3.0:
+2008/08/12
+- new backup feature. Teams can submit files to the server to keep them there. This is going to
+ replace the network mounted homes of Maratona Linux.
+
+version 1.2.3:
+2007/08/25
+- php tag changed to defined for showing clarifications.
+- bug fix: some http headers could not be sent because of misplaced
+ output buffering. This was implying in some "session expired" messages.
+
+version 1.0.6:
+2005/09/04
+- bug fix: special characters in problem names.
+
+version 1.0.5:
+2004/10/06
+- included timelimit field for problems.
+
+version 1.0.4:
+2004/08/19
+- bug fix: in the task window, the file to print was unavailable.
+- new button to view the file before printing.
+- Pascal (Free Pascal Compiler) included in the run.sh example.
+- run.sh improved to better detect errors
+- autojudging small text changes
+
+version 1.0.3:
+2004/06/18
+- bug fix: incorrect report of new balloons to staff.
+- documentation changes concerning autojugding.
+- changes on limit clauses for compatibility with postgres 7.1.x/php 4.1.x.
+
+version 1.0.2:
+2004/06/05
+- bug fix: problem to drop the database when it does not exist.
+- bug fix: duplicating new contests using mozilla browser.
+- changes on file permissions inside the tarball.
+
+version 1.0.1:
+2004/05/09
+- first public release. In 2003, boca 0.5 was used.
diff --git a/doc/dump.sh b/doc/dump.sh
new file mode 100755
index 0000000..f3f3282
--- /dev/null
+++ b/doc/dump.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+if [ "`id -u`" != "0" ]; then
+ echo "Must be run as root"
+ exit 1
+fi
+bocadir=/var/www/boca
+[ -r /etc/boca.conf ] && . /etc/boca.conf
+
+for i in pg_dump grep cut gzip date; do
+ if [ "`which $i`" == "" ]; then
+ echo "$i executable is not in the PATH. Aborting"
+ exit 1
+ fi
+done
+da=`date +%d%b%Y-%Hh%Mmin`
+echo "I will create the file `pwd`/bocadb.$da.tar.gz"
+f=$bocadir/src/private/conf.php
+[ -r $f ] || f=$bocadir/src/private/conf.php
+if [ -r $f ]; then
+ echo I believe the password is `grep "\$conf\[\"dbpass\"\]=" $bocadir/src/private/conf.php | cut -d'"' -f4`
+else
+ echo "The password can be found in private/conf.php of the boca directory"
+fi
+pg_dump -f bocadb.$da.tar -Ft -b -h 127.0.0.1 -U bocauser bocadb
+gzip -9 bocadb.$da.tar
+
+exit 0
diff --git a/doc/html/.htaccess b/doc/html/.htaccess
new file mode 100644
index 0000000..605d2f4
--- /dev/null
+++ b/doc/html/.htaccess
@@ -0,0 +1 @@
+Allow from all
diff --git a/doc/html/manualjudge.en.html b/doc/html/manualjudge.en.html
new file mode 100644
index 0000000..a7f8a0e
--- /dev/null
+++ b/doc/html/manualjudge.en.html
@@ -0,0 +1,203 @@
+
+
+
+
+BOCA Manual for the judges
+
+
+BOCA Online Contest Administrator
+BOCA Reference Manual for judges -
+version October/2011 (BOCA 1.4.1+)
+
+
+Copyright (c) 2006-2011 Cassio P. de Campos (cassio@ime.usp.br).
+Permission is granted to copy, distribute and/or modify this document under
+the terms of the GNU Free Documentation License, Version 1.2 or any later
+version published by the Free Software Foundation; with no Invariant Sections,
+no Front-Cover Texts, and no Back-Cover Texts. A copy of the license may be
+found in http://www.gnu.org/licenses/
+
+BOCA is a software created to control a contest with the ACM International Collegiate
+Programming Contest rules. It has been developed in PHP and the interaction between judges
+and the system is done through a web browser. In the following we describe
+the set of available features for a judge in the system.
+
+It is assumed here that the judge has already logged in the system with their
+username and password in a windows of their browser. Tthe URL
+to access BOCA will depend on the setup of your server. Usually this URL ends with
+/boca/, where a simple authentication form will show up.
+
+
+After a successful login, the web page contains the judge identification in the upper-left
+corner. In the upper-right corner, the clock of the contest is shown, indicating if it has
+started or not, if it has already ended, stopped, or in progress, in which case the number of
+minutes to go are displayed. Below that, there is a set of options in a vertical menu, namely
+Runs, Score, Clarifications, History, As Team, Options e Logout.
+There is still an extra option named Chief which only appear to the chief judge, who
+has to be appointed in the admin's interface (with in the Site options).
+
+
+Runs
+ In this area, the judge might visualize the runs that are still to be judged and shall be
+taken care of. In order to process a run, the judge has to click in its number (eventually a
+message might pop up here indicating the run was already taken; this happens if another judge
+got the run before you). After clicking on the run to judge, a new set of data appear about it:
+
+
+- Site: site number of the run.
+- Number: run number.
+- Time: minutes from the start of the competition until this submission.
+- Problem X: X is the name of problem. There are links
+to download the input and output files (click on the names), or simply to visualize them in the browser (click on view).
+These links are mostly used when the autojudge is turned off or is not running properly for a given problem/language.
+Instead, if the autojudge feature is working correctly, then the judge can directly to go the links in the bottom part of
+the page in order to see the expected output together with the output generated by the team.
+
+- Language Y: Y is the language chosen by the team. The scripts that are used to
+compile and execute the submission with this language are available through links.
+When using the autojudge, note that is not necessary to use this links, because the results are
+already shown in the bottom of the page.
+
+- Source code: here it is possible to view or download the submitted file. An important
+task is to check if the name and extension of this file are correct with respect to the chosen problem, language,
+and the specification in the booklet of problem descriptions.
+
+- Answer: the judge has to choose, among the options available in the system (which were configured by the admin),
+the correct answer to be sent to the team.
+
+- Autojudging answer: here it is presented the suggestion from the autojudge about this submission.
+Usually the autojudge properly identify the answer that has to be sent to the team. However, it may
+fail to do so. For example, the autojudge might indicate a wrong answer, because the
+diff procedure identified the output and expected output to be different, while the only mistake
+happened in the punctuation/accent of a letter (this is usually a case of presentation error, but
+may vary according to the contest). Other issues might happen, and the role of the judge is to check everything
+for eventual mistakes.
+
+- Autojudged by: indicates the computer that has acts as autojudge. Usually this is not
+much relevant for judging a submission.
+
+- Standard output: links for downloading and visualizing the output generated by the team's code are
+available. This is the output generated by the team, which is to be compared with the expected output of
+the given problem. It might also be possible to see some error, in case it happened.
+
+- Standard error: links for downloading and visualizing the standard error output generated by the team's code.
+When a error happens (including compilation or runtime errors, but not restricted to them), this is the most probable file to identify it.
+The judge must always check the content of this file. In the end of it, the judge also finds the output of the diff command
+that has compared the team's output and the expected one (to facilitate the visual inspection).
+
+
+
+By pressing the button named Judge, the judge submits their veredict about the run, and then
+has no access to the this run anymore. It is also possible to give up judging the run by clicking
+on Cancel, which will send the run back to the pool (and it will be eventually judged by another judge).
+
+
+In the tab Runs, the judge can see all the submissions that are yet to be judged. The colors
+represent their status, meaning that they are already been judged by others, or that they are waiting
+you to judge them (red color). You must act with respect to those in red, as only you can judge them (or
+send them back to the pool).
+
+
+
+Chief
+
+Besides acting as a normal judge, there is a designated judge with access to the tab Chief. This tab
+is used for the chief judge to resolve disputes regarding submissions that received different answers by different
+judges (they are shown in red). The prodecure is equivalent to that of a normal judge, but the decision made in the tab of the chief is
+final. The idea is to have the chief judge acting as a tie-breaker between the distinct answers that were assigned to
+a run. Hence, if the chief judge is acting as a normal judge (and they may do so), it is recommended to use
+the tab Runs instead, leaving the tab Chief only for resolving issues. (In the very special case where there
+is a single judge in the competition, then this judge has to be designated as chief and shall use the tab Chief
+to judge the runs, otherwise they will never receive the judgement of another judge and thus will not be sent to teams.)
+In this same tab, the chief judge is able to ask the autojudge to be re-executed for some submissions (selected by
+the boxes besides each of them) or to completely re-open the submission for judging again, which implies in a new round
+of autojudging and judging by actual judges. The team does not become aware of this rejudging unless the new final
+result for the run has to be changed (with respect to the first round of judgement).
+
+
+
+
+Score
+In this tab the judge can see the scoreboard of the competition. It has to be noted that the scoreboard available
+for the judges is complete and not subject to the freezing of the final part of the contest. Hence, the judge is
+expected to keep the scoreboard in secret. In case the scoreboard is consolidated among different sites, the final part
+of the other sites is not shown (*this fact is for technical reasons, to be discussed later*).
+
+
+Clarifications
+This tab allows the judge to answer clarifications submitted by team regarding
+a specific problem or any general aspect of the contest.
+In order to reply to a clarification, the judge must first click on the clarification number.
+The box available in the bottom part is meant for creating a new clarification, as judges are allowed to do
+so. The new clarification will only be meaningful if the judge that gets it to answer selected the reply to all
+option (explained in the next paragraph). This is useful for the judges to send a general information to the teams.
+
+
+After clicking on the clarification number, the judge sees information about it, such as
+site number, clarification number, time in minutes from the start of the competition, and the
+problem to which the clarification regards. There are two text boxes: one with the question (on top)
+and one to be filled with the reply. Finally, there is a selection box to indicate if the reply
+should be sent to all the teams or just the the team that posted the question.
+
+
+The system also allows the judge to select the No response button. In general
+this is used for questions that are already stated in the booklet of problem descriptions, or
+that has already been replied, or even that should not be answered at all (for example, about
+the timelimit of a problem, or about some sensitive information of the input/output).
+
+
+History
+This tab shows the history of Clarifications and
+Runs that were processed by the judge so far.
+
+
+Options
+This tab shows the information of the judge, such as Username,
+User full name , User description. It is possible
+for the judge to update their password, although this is not necessary neither
+recommended. Instead it is recommended that the admin who created the users already
+specifies secret and safe password for all users.
+
+
+
+
+Logout
+Button to log out from the judge interface.
+
+Important hints for judges
+ While judging a submission, it is necessary to be very careful. Even if it is possible
+to alter the judgement of a run afterwards, this has to be avoided as much as possible, because
+the team might suffer an undesired situation.
+
+Every time a judge is about to answer a problem for its first time (that is, the problem has not
+been submitted before, or has not received yet any YESes), when possible it is interesting to have other judges
+also checking the submission, which should be analyzed with even greater care. Sometimes this is the
+moment when an unfortunate issue with the autojudge or with inputs or outputs is discovered
+(obviously nobody wants it to happen, but it might).
+
+In order to reply to clarifications, it is important that the judge has read and understood
+the question and the problem to which it concerns. When possible, it is interesting to have the opinion
+of the person or group that created the problem description, its input and output. After that,
+it is necessary to think if such reply has to be sent only
+to this user or to all teams in the contest. If it is a relevant issue and the contest is also offered in
+other sites, then the judge shall find a way to contact other sites about the clarification.
+Some examples of clarifications that are not disclosured (that is, are replied with a no response)
+are
+What is the timelimit for this problem?,
+Given this input, which is the correct output?,
+questions that are already explained in the problem description,
+etc.
+In case the judge is not certain about it, they must contact the chief judge of the site or the
+chief judge of the contest for help.
+
+
+About BOCA and this document
+BOCA System and this document have been created by Cassio Polpo de Campos and can be found at
+http://www.ime.usp.br/~cassio/boca/.
+
+
+
+
+
+
+
diff --git a/doc/html/manualjudge.pt_br.html b/doc/html/manualjudge.pt_br.html
new file mode 100644
index 0000000..eabeecc
--- /dev/null
+++ b/doc/html/manualjudge.pt_br.html
@@ -0,0 +1,219 @@
+
+
+
+
+Manual do BOCA para as equipes
+
+
+BOCA Online Contest Administrator - Sistema de Submissão
+Manual de Referência para os juízes -
+versão setembro/2010 (para o BOCA versão 1.4.x)
+
+
+Copyright (c) 2006-2010 Cassio P. de Campos (cassio@ime.usp.br).
+Permission is granted to copy, distribute and/or modify this document under
+the terms of the GNU Free Documentation License, Version 1.2 or any later
+version published by the Free Software Foundation; with no Invariant Sections,
+no Front-Cover Texts, and no Back-Cover Texts. A copy of the license may be
+found in http://www.gnu.org/licenses/
+
+O BOCA é um software criado para controlar uma competição nos moldes
+da Maratona de Programação da SBC. Foi feito em PHP e a interação dos juízes
+com o sistema é feita usando-se um browser. A seguir descrevemos a
+interface disponível no BOCA para os juízes e suas principais funções.
+
+Neste texto será assumido que o juiz já realizou o seu
+login na máquina e abriu uma janela do navegador (leia
+as instruções sobre o Maratona Linux ou sobre o sistema que
+estiver sendo utilizado). O BOCA é acessado através de uma
+URL (usualmente a página se chama
+http://mainserver/boca ou http://bocaserver/boca).
+Ao carregar a página, o juiz deverá ver a
+tela de login do BOCA. Basta digitar o login do
+BOCA fornecido ao juiz e a sua senha correspondente.
+
+Após realizar o login com sucesso, uma página deverá ser aberta
+contendo a identificação do juiz no canto superior esquerdo.
+No canto superior
+direito haverá a informação sobre o estado da competição: ou ainda não
+começou, ou já acabou, ou está parada, ou a competição está em andamento e a
+quantidade de minutos restantes será mostrada. Mais abaixo dessas primeiras
+linhas estarão seis opções, que representam a interface propriamente dita do
+BOCA. Estas seis opções são: Runs,
+Score, Clarifications, History, Options e Logout.
+Existe ainda uma opção extra para o juiz chefe (que deve ser previamente apontado através da
+interface do admin no sistema): Chief. Ela não está disponível para os demais juízes.
+
+
+Runs
+Ao entrar nessa opção, o juiz poderá visualizar as submissões que ainda
+não foram corrigidas e devem ser processadas. Para corrigir uma submissão,
+o juiz deve clicar sobre seu número (como é feito o tratamento de concorrência
+para que dois ou mais juízes não peguem a mesma Run, neste momento o juiz pode
+ser avisado que a Run acaba de ser pega por outro juiz). Ao clicar em uma
+submissão, o juiz verá os seguintes campos:
+
+- Site: número do site atual.
+- Number: número da Run sendo julgada.
+- Time: minutos decorridos da competição para esta submissão.
+- Problem X: X é o nome do problema. Ao lado, existem
+links para fazer o download (clicando sobre o nome) ou simplesmente visualizar
+os arquivos de entrada e saída (clicando em view). Usando o esquema de
+autojudging, o importante é ficar atento à saída esperada, comparando-a com a
+saída que o programa da equipe gerou.
+- Language Y: Y é a linguagem escolhida pela equipe. Ao
+lado aparece o script para compilação e execução nesta linguagem. Note que,
+utilizando o esquema de autojudging, não é necessário olhar para esse arquivo.
+- Source code: Aqui é possível visualizar (view) ou fazer o
+download do arquivo submetido. Um ponto importante para o juiz é verificar se
+o nome e a extensão desse arquivo estão de acordo com o problema e a linguagem
+escolhidos.
+- Answer: Neste campo o juiz escolherá qual a resposta que será enviada
+para a equipe. Para tomar essa decisão, ele tem à disposição os arquivos e botões
+já mencionados e também, logo abaixo, os dados gerados pelo esquema de autojudging
+(se esse esquema estiver sendo utilizado).
+- Autojudging answer: Resposta sugerida pelo esquema de autojudging.
+Usualmente o autojudging acerta o que deve ser respondido às equipes, mas pode
+falhar. Por exemplo, ele pode dizer que a resposta está errada (Incorrect Output),
+pois comparou os arquivos e não eram iguais, mas o único erro do programa da
+equipe foi na digitação de um acento em uma palavra (usualmente isso é simplesmente
+um Output format error). Outros detalhes podem ocorrer, e o juiz deve
+estar atento aos próximos demais dados fornecidos pelo autojudging.
+- Autojudged by: indica qual computador fez o autojudging, no
+caso de diversos autojudgings estarem sendo utilizados. Usualmente não essencial
+na correção.
+- Standard output: links para fazer o download ou visualizar a saída
+padrão gerada pelo programa da equipe. Usualmente neste lugar deve estar a
+saída que foi gerada pela equipe e que deve ser comparada com a saída esperada,
+disponível no item Problem. Caso haja algum problema, eventualmente
+pode ser possível visualizar o erro aqui.
+- Standard error: links para fazer o download ou visualizar a saída de
+erro padrão gerada pelo programa da equipe. Quando um problema acontece, por
+exemplo um erro em tempo de execução por causa de um acesso ilegal, a informação
+sobre o erro torna-se disponível nesta saída de erro. Além de sempre
+analisar essa saída, o juiz deve estar atento à saída padrão, pois máquinas virtuais
+como da linguagem Java podem escrever os erros na saída padrão e/ou na saída
+de erro. Na saída de erro está ainda o resultado do diff feito entre o arquivo
+ esperado e o arquivo gerado pelo programa submetido.
+
+
+
+Utilizando o botão Judge o juiz faz o julgamento da Run, e após
+isso não tem mais acesso para alterar seu julgamento. É possível ainda devolver
+a Run para o pool de submissões a serem julgadas, utilizando o
+botão Cancel.
+
+Na tela de Runs, o juiz visualiza todas as submissões, mesmo aquelas que
+estão sendo julgadas por outros juízes. Tais submissões aparecem com a cor
+azul. As submissões sendo julgados por ele próprio aparecem em vermelho, e somente
+ele tem acesso para julgá-las (ou o admin, claro).
+
+
+Chief
+
+Além de poder atuar como um juiz normal, um juiz pode ser designado como chief. Nesta aba
+o juiz chefe tem a opção de julgar runs que foram previamente julgadas mas obtiveram resultados
+diferentes dos diferentes juízes. A tela é similar àquela do juiz normal, só que runs
+julgadas aqui são dadas como resposta final ao time, sem a necessidade de intervenção de outro juiz.
+Por esse motivo, é aconselhável que mesmo o juiz chefe, quando estiver julgando runs sem conflito, apenas
+utilize a aba Runs, e deixe para utilizar esta aba apenas para resolver os casos de runs que foram julgadas de
+forma diferente por diferente juízes. Além das informações da run, o juiz chefe possui
+(ao clicar sobre a run) as resposta contraditórias que foram dados pelos juízes, de forma a desempatar
+a questão e enviar a resposta mais adequada ao time.
+
+
+
+
+Score
+Nessa opção será mostrado o placar atualizado da competição. Vale a pena
+lembrar que o placar disponível para os juízes é completo, e portanto
+deve ser mantido em sigilo até a divulgação dos resultados finais da competição
+(para manter o suspense :-).
+
+Clarifications
+Essa opção permite que o juiz responda as clarifications enviadas
+pelas equipes a cerca de um problema específico ou de algum aspecto geral da
+prova. Para responder uma clarification, o juiz deve clicar sobre seu
+número Cuidado: a caixa de texto disponível na parte inferior não é para
+responder perguntas, mas para elaborar uma pergunta. Isso serve para que um juiz
+crie uma pergunta, que então poderá ser respondida por ele mesmo (ou por outros
+juízes) e enviada para todas as equipes, funcionando assim como uma forma de
+aviso geral.
+
+Neste instante ele poderá visualizar informações sobre a clarification,
+como número do site, número da clarification, tempo em minutos desde o
+início da competição e problema sobre o qual
+a pergunta está relacionada, além de duas caixas de texto: uma com a
+pergunta e outra onde será preenchida a resposta. Se julgar relevante, o juiz
+pode clicar nas seleções answer to all users in the site para que esta pergunta seja
+respondida (enviada) para todas as equipes no site ou answer to all users in all sites
+para que a resposta seja enviada para todas as equipes em todos os sites (no caso de
+uma competição executada no BOCA em um único site, não há diferença entre estas seleções).
+
+O sistema também permite que o juiz utilize um botão chamado
+No response. Isso ocorre
+em geral porque a pergunta feita não deve ser respondida, pois sua resposta faz parte do
+entendimento da questão ou da prova, ou já foi respondida anteriormente.
+Por fim, existe um botão onde o juiz pode devolver a clarification para que
+outro juiz a responda.
+
+
+History
+Ao entrar nessa opção, o juiz poderá visualizar as Clarifications e
+Runs que foram respondidas/corrigidas até o momento.
+Não é possível alterar nada, apenas visualizar.
+
+History
+Nesta aba o juiz pode atuar como uma equipe, submetendo runs para serem julgadas.
+O uso deste item se dá no momento de testar o sistema e o conjunto de problemas. Juízes
+podem submeter runs mesmo antes de iniciada a competição.
+
+
+Options
+Entrando nessa opção poderão ser vistas as informações: Username,
+User full name e User description do juiz. Também
+será possível trocar a senha do juiz no BOCA digitando-se a senha antiga e a
+nova (duas vezes). Para efetuar a troca da senha, basta preencher os campos
+corretamente e clicar no botão Send. É importante ter uma senha
+segura para um juiz.
+
+
+Logout
+Essa opção permite sair do BOCA.
+
+Dicas importantes
+Ao corrigir problemas, devemos tomar extremo cuidado. Ainda que seja possível
+alterar a correção posteriormente (através do ambiente do administrador da competição),
+isso implica que a equipe receberá uma resposta e, depois de certo tempo, outra.
+Obviamente esse tipo de situação não é agradável.
+Sempre que um dos juízes está corrigindo um problema pela primeira vez (ou ainda nas
+demais vezes iniciais, isto é, até o momento foram feitas poucas submissões
+desde problema),
+é interessante que todos participem e tenham cuidados especiais, analisando a
+submissão com calma. É possível que na primeira
+submissão de um dado problema possamos descobrir um defeito no
+sistema ou nos arquivos de entrada e saída (claro que torcemos para isso nunca aconteça :-).
+
+Para responder às clarifications, é necessário que o juiz tenha lido com
+calma as questões e identifique se a pergunta é válida e deve ser respondida. Além disso,
+é necessário considerar se a resposta deve ser enviada para todas as equipes ou apenas
+para aquela que fez a pergunta. Perguntas típicas que não são respondidas são:
+Qual o tempo limite desse problema?, Dada essa entrada, qual a saída correta?,
+etc. Além disso, perguntas cujas respostas estão definidas nos enunciados normalmente
+não são respondidas.
+Caso haja uma dúvida sobre o que se deve responder, o juiz deve procurar o juiz-chefe
+responsável pela prova.
+
+
+Sobre o BOCA e este documento
+O sistema BOCA foi criado por Cassio Polpo de Campos
+e pode ser encontrado em
+http://www.ime.usp.br/~cassio/boca/.
+Este manual foi feito por Cassio Polpo de Campos.
+
+
+
+
+
+
+
diff --git a/doc/html/manualteam.en.html b/doc/html/manualteam.en.html
new file mode 100644
index 0000000..815eda0
--- /dev/null
+++ b/doc/html/manualteam.en.html
@@ -0,0 +1,198 @@
+
+
+
+
+
+BOCA Team's Manual
+
+
+
+BOCA Online Contest Administrator
+Reference Manual for teams - version
+October/2011 (BOCA version 1.4.1+)
+
+Copyright (c) 2003-2010 Ulisses F. F. da Silva and Cassio
+P. de Campos.
+Permission is granted to copy, distribute and/or modify this document under
+the terms of the GNU Free Documentation License, Version 1.2 or any later
+version published by the Free Software Foundation; with no Invariant Sections,
+no Front-Cover Texts, and no Back-Cover Texts. A copy of the license may be
+found in http://www.gnu.org/licenses/
+
+BOCA is a software for controlling a competition in the scope of the ACM International
+Collegiate Programming Contest. It has been developed in PHP and the interaction between teams
+and the system is performed using a web browser. In the following it is described
+this interface and its main functions.
+
+It is important that teams tested the system during the warmup session, before
+the official contest, so any issue can be addressed in time. The warmup has exactly this
+purpose. It is expected that teams submit correct and incorrect runs, as long as they do not
+try to perform malicious operations in the system. It is also expected that clarifications be
+submitted, and a small file to print.
+
+
+It is assumed here that the team has already logged in using the web browser and
+the URL address provided to access the BOCA system. The URL varies from contest to contest,
+so you have to ask the staff of your site about it. The login page contains the fields
+username and password, which are provided by the staff of the contest. Usually the
+username follows the format teamX, where X is the team number, but that is
+not mandatory (again, check with the staff). If not speficied, the initial password is empty.
+
+After the successful login, a page opens with the team identification in the upper-left
+corner, and the clock of the contest in the upper-right corner. During the contest,
+as the team gets YESes as balloons appear besides the team name.
+Just below this information, a vertical menu has the following options:
+Problems, Runs, Score, Clarifications, Tasks, Backups, Options e Logout.
+
+Problems
+In this tab, the team sees the problems of the contest, together with the book of problem
+descriptions (if available online). In in-loco contests, this tab is less important
+given that a printed version of the booklet is distributed to the teams. Still, the column
+named Basename provides to teams the name of the file that has to be used for each problem.
+This is the name that has to be followed by the extension (depending on the language) and
+also as the name of the class containing the public main procedure in Java.
+Usually this information is also available in the booklet. Nevertheless, here the team can
+check if their name is correct.
+
+
+Runs
+This tab represents the actual information about the team's submissions, as well as provides
+the interface to submit new runs. It is important for the team to select the correct
+problem, language, and to choose the correct file for the submission. Note that the file name
+must follow the specification in the booklet, and which shall also be available in the tab Problems.
+Hence,
+
+ - Use in the source-code the filename defined in the column Basename of the tab Problems.
+ Take care with small typos and the proper extension according to the chosen language.
+
+ - Choose the correct language and problem. It is not uncommon to happen submissions with wrong filename, language or problem.
+
+ - Make sure your code reads the input from the standard input and writes the output to the
+ standard output. Avoid writing anything to the standard error. Furthermore, make your
+ program exit the code zero in the final return or exit(.) call. By default, this indicates that no
+ error has happened during its execution.
+
+
+
+In order to see the judgements of runs, the team must click on
+the tab Runs and watch the list of submitted runs.
+However, do not stop working while waiting for the answers. Even if the judges
+are in the backstage working hard to reply to all submissions, this might take some time.
+In the last part of the competition, the scoreboard is not updated, neither the runs are answered back
+(the number of minutes from the end when this happens depends on the contest; usually it is something around
+15 minutes, but this is informed by the staff). For each run, there is a set of standard answers that
+exist in each contest (and they may vary depending on the contest). Still the common options are shown below:
+
+
+ | Answer | Description |
+
+
+ | YES |
+ Your code was properly compiled, run, and correctly generated the expected output for the problem. |
+
+ | NO: Wrong answer |
+ Some times known as Incorrect output. It indicates that the code compiled and ran, however it
+ did not generated the expected output for the problem, given the input of the judges (which most certainly
+ is different from yours and is not available to you). |
+
+
+ | NO: Time-limit Exceeded |
+ The code compiled properly but spent more than the maximum amount of time defined for the given problem.
+ This time-limit is defined by the judges for each problem and is not disclosed to the teams. |
+
+
+ | NO: Runtime Error |
+ The code compiled properly but achieved an error during its run, given the input of the judges. Some examples
+ of runtime error are: illegal memory access (seg. fault), illegal file access, excess of memory usage, etc. |
+
+ | NO: Compilation Error |
+ The code has not compiled properly in the judges' computers. Note that you are expected to have compiled in your
+ own computer before submitting the code. So check the compilation options and versions in your
+ computer, and if you do not have a problem compiling it locally, ask a member of the staff for help. |
+
+
+ | NO: presentation Error |
+ Also known as output format error, it means that your code compiled, ran, and generated the
+ expected output apart from some minor presentation issue, such as upper/lower-cases, acents or punctuations (the
+ definition of presentation error may vary in each contest and is defined by the judges who created the test set). |
+
+
+ | NO: If possible, contact staff |
+ This reply tells you to contact your local staff for help/asking about the issue, if at all possible. |
+
+
+
+
+
+Score
+This tab shows the scoreboard of the contest. If running as a multi-site competition, the scoreboard might also
+contain teams from other sites, which can be identified by the /X after the team name, where X is the
+site number of the corresponding team. Note that the scoreboard is not updated during the last part of the competition.
+This is indicated accordingly.
+
+
+Clarifications
+This tab can be used by the team to submit questions to the judges concerning the problems, their descriptions,
+or any other aspect of the contest. If the question is specific to a problem of the test set, the team must select
+the problem from the combo list. Otherwise, the option General is to be used. The text box is used to
+write the question. It is also available in this tab all the replies to questions that were formulated by the
+team, as well as questions formulated by other teams but that judges decided that the reply should be made
+available to all the teams. Some facts:
+
+
+ - Teams must make questions regarding the problems and test set using only this interface, and not directly
+ to the staff or judges.
+
+ - It is the team's responsibility to check the tab about clarifications during the contest
+ to check for new replies. Judges may also send general clarifications to teams, and they will appear in this tab.
+
+
+
+BOCA allows judges to use a particular button named No response. If you receive this
+reply it means that the question may not be answered by the judges, for instance because it is against
+the rules to disclose such information, or because the judges understand that the
+information asked is already available in the booklet of problem descriptions.
+
+Tasks
+This tab allows the team to send files for printing, as well as ask for help from a staff member (using
+the button S.O.S.. To print a file, just select it from the disk and click on Send.
+The help provided by the staff has to be only related to issues with the computers or other
+physical problem, while questions about the test set, problem descriptions, etc must be send to the
+judges using the tab Clarifications.
+
+Backups
+It is possible to send small files to BOCA in order to keep them safe in the server. This is
+particularly useful if some drastic issue happens with your computer. This tab provides a way
+for the teams to send and query back files that are stored in the server. Only very small files
+are allowed, so it is recommended that you backup only plain text files (source code, inputs, etc)
+and use a zip or tar.gz format to create a single file.
+
+
+
+Options
+This tab shows the information of the team, such as Username,
+User full name , User description. It is possible
+for the team to update their password, although this is not necessary neither
+recommended. Instead it is recommended that the admin who created the users already
+specifies secret and safe password for all users.
+
+
+
+
+Logout
+Button to log out from the team interface.
+
+About BOCA and this document
+BOCA System and this document have been created by Cassio Polpo de Campos and can be found at
+http://www.ime.usp.br/~cassio/boca/.
+An initial version of this document was made by Ulisses Furquim Freire da Silva.
+
+
+
+
+
+
+
diff --git a/doc/html/manualteam.pt_br.html b/doc/html/manualteam.pt_br.html
new file mode 100644
index 0000000..efa3871
--- /dev/null
+++ b/doc/html/manualteam.pt_br.html
@@ -0,0 +1,227 @@
+
+
+
+
+
+Manual do BOCA para as equipes
+
+
+
+BOCA Online Contest Administrator - Sistema de Submissão
+Manual de Referência para as equipes - versão
+setembro/2010 (para o BOCA versão 1.4.x)
+
+Copyright (c) 2003-2010 Ulisses F. F. da Silva and Cassio
+P. de Campos.
+Permission is granted to copy, distribute and/or modify this document under
+the terms of the GNU Free Documentation License, Version 1.2 or any later
+version published by the Free Software Foundation; with no Invariant Sections,
+no Front-Cover Texts, and no Back-Cover Texts. A copy of the license may be
+found in http://www.gnu.org/licenses/
+
+O BOCA é um software criado para controlar uma competição nos moldes
+da Maratona de Programação da SBC. Foi feito em PHP e a interação dos times
+com o sistema é feita usando-se um browser. A seguir descrevemos a
+interface disponível no BOCA para as equipes e suas principais funções.
+
+É interessante que todos os times testem essas opções durante a
+sessão de aquecimento (warmup) que antecede a competição. O
+warmup tem exatamente esta função, e assim espera-se que cada equipe submeta
+um problema correto, submeta um problema errado, faça perguntas aos juízes
+através do sistema de clarifications e até submeta um arquivo pequeno
+para impressão.
+
+Neste texto será assumido que o time já realizou o seu
+login na máquina e abriu uma janela do navegador (leia
+as instruções sobre o Maratona Linux ou sobre o sistema que
+estiver sendo utilizado). O BOCA é acessado através de uma
+URL (endereços comuns são
+http://mainserver/boca/ ou http://bocaserver/boca/). Ao carregar a página, o time deverá ver a
+tela de login do BOCA. Basta digitar o login do
+BOCA fornecido ao time e a sua senha correspondente (usualmente
+algo como teamX, onde X
+deve ser substituído pelo número da equipe. A senha inicial é
+vazia caso não escolhida diferentemente).
+
+Após realizar o login com sucesso, uma página deverá ser aberta
+contendo a identificação do time no canto superior esquerdo. Durante a
+competição, conforme o time acerta os problemas, pequenos balões coloridos
+são apresentados próximos ao nome do time.
+No canto superior
+direito haverá a informação sobre o estado da competição: ou ainda não
+começou, ou já acabou, ou está parada, ou a competição está em andamento e a
+quantidade de minutos restantes será mostrada. Mais abaixo dessas primeiras
+linhas estarão sete opções, que representam a interface propriamente dita do
+BOCA. Estas sete opções são: Problems, Runs,
+Score, Clarifications, Tasks, Backups, Options e Logout.
+
+Problems
+Ao entrar nessa opção, o time poderá visualizar as questões da prova. Para
+cada questão, estará disponível um arquivo con sua descrição (muitas vezes
+apenas um arquivo de descrição é dado, contendo todas as questões da prova).
+Esta opção é normalmente utilizada para competições não-presenciais como forma de
+distribuir a prova. Em competições presenciais, sua utilidade é reduzida.
+Ainda nesta tela é possível visualizar as cores dos balões de cada problema.
+
+Runs
+Ao entrar nessa opção, o time poderá submeter as suas soluções e receber as
+respostas dos juízes. Para submeter uma solução, o time deverá selecionar o
+problema para o qual a solução foi feita, a linguagem utilizada e depois
+carregar o arquivo contendo a solução. Depois disso, basta clicar no botão
+Send para enviar sua solução. O botão Clear permite apagar os
+dados selecionados. Algumas observações importantes na hora de criar e
+submeter uma solução:
+
+
+ - Crie o seu arquivo-fonte contendo a solução de um problema com o nome
+ indicado no enunciado. Cuidado com pequenos erros no nome e em sua extensão.
+
+ - Escolha a linguagem correta. Note que seu fonte deverá ter a
+ extensão correspondente para cada uma das linguagens aceitas (veja a folha
+ de questões da prova).
+
+ - Lembre-se de que sua solução deve ler os dados da entrada padrão e
+ escrever os resultados na saída padrão. Nada deve ser
+ escrito na saída padrão de erro. Além disso, programas escritos em
+ linguagens que possibilitam o retorno de algum valor para o sistema
+ operacional devem retornar o valor 0 (zero), que por convenção indica que
+ nenhum problema ocorreu na execução.
+
+
+
+Para receber as respostas dos juízes, o time deverá clicar em Runs e
+esperar que a lista contendo as respostas recebidas para cada solução
+submetida seja atualizada (ainda assim, não perca tempo esperando. Você pode
+produzir enquanto a resposta dos juízes não chega). Vale a pena lembrar que
+nos últimos minutos os times que submeterem soluções não receberão
+mais as respostas dos juízes
+(assim o suspense fica melhor, não? :-). Esse prazo é informado na
+competição. Cada competição tem seu conjunto de respostas possível que as
+equipes podem receber. A seguir apresentamos apenas uma tabela exemplo com as
+respostas tradicionais. Verifique as especialidades da sua
+competição.
+
+
+
+ | Resposta | Descrição |
+
+
+ | YES |
+ Seu programa foi aceito, e você receberá um balão da cor correspondente ao problema. |
+
+ | NO: Incorrect Output |
+ Também conhecido como Wrong Answer. Indica que seu programa
+ respondeu incorretamente a algum(ns) dos testes dos juízes. |
+
+
+ | NO: Time-limit Exceeded |
+ A execução do seu programa excedeu o tempo permitido pelos
+ juízes. Esse limite de tempo usualmente não é divulgado aos times e pode variar
+ para cada problema. |
+
+
+ | NO: Runtime Error |
+ Durante o teste ocorreu um erro de execução (causado pelo seu
+ programa) na máquina dos juízes. Acesso a posições irregulares de
+ memória ou estouro dos limites da máquina são os erros mais comuns. |
+
+ | NO: Compilation Error |
+ Seu programa tem erros de sintaxe. Pode ser ainda que você errou o
+ nome do problema ou linguagem no momento da submissão. |
+
+
+ | NO: Output Format Error |
+ Também conhecido como Presentation Error, indica que a saída
+ do seu programa não segue a especificação exigida na folha de
+ questões, apesar do "resultado" estar correto. Corrija para se
+ adequar à especificação do problema. |
+
+
+ | NO: Contact Staff |
+ Você deve pedir a presença do pessoal de staff, pois algum
+ erro incomum aconteceu. |
+
+
+
+
+
+Score
+Nessa opção será mostrado o placar atualizado da competição. Vale a pena
+lembrar que o placar será congelado antes do final da competição
+(suspense mantido :-). Esse prazo também é informado na competição, e o placar
+quando estiver congelado mostra um aviso sobre seu estado.
+
+Clarifications
+Essa opção permite que o time faça perguntas aos juízes a cerca de um
+problema específico ou de algum aspecto geral da prova. O time deverá
+selecionar o problema relacionado à sua pergunta ou selecionar General,
+caso a pergunta não seja específica. Logo abaixo deverá ser escrito o texto da
+clarification. Para enviar a clarification basta clicar no botão
+Send. O botão Clear apaga os dados selecionados. Para visualizar
+a resposta da clarification, o time deverá estar na opção
+Clarifications e olhar na lista das clarifications submetidas se
+a resposta já foi dada. Como já foi mencionado, uma lista contendo as
+clarifications pertinentes a cada time será sempre mostrada nessa
+opção. Algumas observações importantes sobre clarifications:
+
+
+ - Os times devem fazer perguntas sobre a prova utilizando apenas essa
+ interface disponível no BOCA!
+
+ - O time deverá ficar atento às clarifications durante toda a
+ prova, pois uma clarification feita por um time poderá ser respondida
+ para todos os outros. Os juízes também podem enviar clarifications a todos
+ os times se julgarem conveniente. Fiquem atentos.
+
+ - As respostas de clarifications não surgem na tela. Você deve consultar esta página para vê-las.
+
+
+
+O sistema permite que o juiz respondendo uma dúvida utilize um botão chamado No response. Isso ocorre
+em geral porque a pergunta feita não deve ser respondida, pois sua resposta faz parte do
+entendimento da questão ou da prova. Neste caso sugerimos ler com cuidado as questões e as
+possíveis clarifications relacionadas.
+
+Tasks
+Ao entrar nessa opção, o time poderá enviar arquivos para impressão. Para
+isso o arquivo deve ser selecionado e então basta clicar no botão
+Send. O botão Clear permite apagar os dados selecionados. Outra
+opção neste item é o botão S.O.S. que pode ser usado para chamar a
+ajuda do pessoal de staff. Essa ajuda deve estar relacionada apenas com
+problemas do computador ou semelhantes, já que dúvidas sobre a prova devem ser
+enviadas pelo sistema BOCA na opção Clarifications.
+
+Backups
+No sistema BOCA é possível enviar pequenos arquivos para que sejam
+guardados no servidor em case de uma interrupção do funcionamento do computador
+do time. Entrando nessa opção poderão ser vistos os arquivos já enviados
+e mantidos no servidor, assim como enviar novos arquivos. Note que existe um limite usualmente
+pequeno na capacidade de armazenamento para que não hajam abusos. Um arquivo compactado é
+geralmente a melhor forma de guardar dados no servidor.
+
+
Options
+Entrando nessa opção poderão ser vistas as informações: Username,
+User full name e User description do time. Também
+será possível trocar a senha do time no BOCA digitando-se a senha antiga e a
+nova (duas vezes). Para efetuar a troca da senha, basta preencher os campos
+corretamente e clicar no botão Send.
+
+
+Logout
+Essa opção permite sair do BOCA.
+
+Sobre o BOCA e este documento
+O sistema BOCA foi criado por Cassio Polpo de Campos
+e pode ser encontrado em
+http://www.ime.usp.br/~cassio/boca.
+Este manual, em sua versão inicial, foi feito por Ulisses Furquim Freire da Silva e
+complementado e atualizado por Cassio Polpo de Campos.
+
+
+
+
+
+
diff --git a/doc/import-user.txt b/doc/import-user.txt
new file mode 100644
index 0000000..ea16d82
--- /dev/null
+++ b/doc/import-user.txt
@@ -0,0 +1,114 @@
+import-user.txt
+---------------
+Last modified 24/aug/2012 by cassio@ime.usp.br
+See Copyright below.
+
+To simplify the input of user's data, it is
+possible to put all information in a text
+file, according to three different formats. Two
+of them are based on the files generated from the
+ICPC website system, usually in TAB separated format. Examples of such
+files are in this folder, named PC2_Team.tab and Teams.tsv
+The third possible format follows the example below:
+
+************ users.txt: *************
+[user]
+usernumber=2000
+usersitenumber=1
+username=cassio
+userfullname=Cassio P. de Campos
+usertype=admin
+userpassword=secret
+
+usernumber=2001
+usersitenumber=1
+username=judge1
+usertype=judge
+userfullname=First judge name
+userenabled=f
+usermultilogin=t
+userip=10.0.0.5
+
+usernumber=2002
+usersitenumber=1
+username=staff1
+usertype=staff
+userfullname=Staff person name
+userpassword=aBcDe
+
+usernumber=1
+usersitenumber=1
+userfullname=[PUC-SP A] Team A
+userdesc=[PUC-SP][Pontificial Universidade Catolica de SP] Nome1, Nome2, Nome3
+userip=192.168.0.1
+usericpcid=1234
+
+usernumber=2
+usersitenumber=1
+userfullname=[Team B] Full team B name
+userdesc=[InstitutionShortName] Long institution name
+userip=192.168.0.2
+usericpcid=1111
+
+usernumber=3
+usersitenumber=1
+userfullname=[Shortname] Long team name
+userip=192.168.0.3
+
+**************************************
+Note that the "****" lines should not
+be included in the text file, only what is between them. Consider
+using the ICPC data format, downloaded from the ICPC site, to input
+the information about the teams. Note that passwords will be
+automatically generated for the teams in such case, and you have to
+take note of those passwords. If you re-include the teams using those
+file formats, new passwords will be generated, and you must take note again.
+
+The users are defined per block of lines.
+Blank lines separate the definitions of the
+users. The parameters not specified for a
+given user inside its block are set to
+the default values.
+
+The parameters in the user's file are:
+usernumber: number of the user in the site
+usersitenumber: number of the user's site
+username: nickname of the user. If not
+ specified, it's generated from
+ the usernumber, ie, "team"+usernumber
+userfullname: institution name and team name or
+ just the user name.
+userdesc: detailed description about the user.
+usertype: type of the user. If not specified,
+ it's set to "team".
+userpassword: if not specified, it's left emtpy.
+userenabled: if not specified, the user is enabled.
+usericpcid: ID of user in the ICPC system. Not required.
+usermultilogin: if not specified, the user cannot
+ make simultaneous logins form distinct IPs.
+userip: from which IP number the user may connect. A list
+ of IPs separated by comma may be specified. IPs may
+ have netmasks, such as 10.0.0.0/16, or negations,
+ such as !143.107.0.0/16.
+
+Contacts and Copyrights
+-----------------------
+BOCA Copyright (c) 2003- Cassio Polpo de Campos (cassio@ime.usp.br)
+http://www.ime.usp.br/~cassio/boca
+
+////////////////////////////////////////////////////////////////////////////////
+//BOCA Online Contest Administrator
+// Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+////////////////////////////////////////////////////////////////////////////////
diff --git a/doc/problemexamples/abacaxi.zip b/doc/problemexamples/abacaxi.zip
new file mode 100644
index 0000000..2dcf701
Binary files /dev/null and b/doc/problemexamples/abacaxi.zip differ
diff --git a/doc/problemexamples/abacaxi/compare/c b/doc/problemexamples/abacaxi/compare/c
new file mode 100755
index 0000000..4998be3
--- /dev/null
+++ b/doc/problemexamples/abacaxi/compare/c
@@ -0,0 +1,97 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+# // Last modified 21/jul/2012 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 problem_input (might be used by some specific checkers, here it is not)
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/doc/problemexamples/abacaxi/compare/cpp b/doc/problemexamples/abacaxi/compare/cpp
new file mode 100755
index 0000000..4998be3
--- /dev/null
+++ b/doc/problemexamples/abacaxi/compare/cpp
@@ -0,0 +1,97 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+# // Last modified 21/jul/2012 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 problem_input (might be used by some specific checkers, here it is not)
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/doc/problemexamples/abacaxi/compare/java b/doc/problemexamples/abacaxi/compare/java
new file mode 100755
index 0000000..4998be3
--- /dev/null
+++ b/doc/problemexamples/abacaxi/compare/java
@@ -0,0 +1,97 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+# // Last modified 21/jul/2012 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 problem_input (might be used by some specific checkers, here it is not)
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/doc/problemexamples/abacaxi/compile/c b/doc/problemexamples/abacaxi/compile/c
new file mode 100644
index 0000000..5376708
--- /dev/null
+++ b/doc/problemexamples/abacaxi/compile/c
@@ -0,0 +1,172 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 21/july/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.exe)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes, default 512M)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ name="*.c"
+else
+ cp "$name" src
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+maxm=512000
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ maxm=${4}000
+ fi
+fi
+
+# setting up the timelimit according to the problem
+if [ "$3" == "" ]; then
+time=5
+else
+time=$3
+fi
+let "ttime = $time + 30"
+
+if [ "$2" == "" ]; then
+ exe=run.exe
+else
+ exe=$2
+fi
+
+rm -f $exe compileit.retcode runit.retcode 2>/dev/null
+cat < compileit.sh
+#!/bin/bash
+cc=\`which gcc\`
+[ -x "\$cc" ] || cc=/usr/bin/gcc
+if [ ! -x "\$cc" ]; then
+ echo "\$cc not found or it's not executable"
+ exit 47
+fi
+cd src
+"\$cc" -static -O2 -o ../$exe $name -lm
+echo \$? > ../compileit.retcode
+exit 0
+EOF
+chmod 755 compileit.sh
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ echo "Internal directory is $cdir"
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+ $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/abacaxi/compile/cpp b/doc/problemexamples/abacaxi/compile/cpp
new file mode 100644
index 0000000..6a61bc1
--- /dev/null
+++ b/doc/problemexamples/abacaxi/compile/cpp
@@ -0,0 +1,172 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 21/july/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.exe)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ name="*.c"
+else
+ cp "$name" src
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+maxm=512000
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ maxm=${4}000
+ fi
+fi
+
+# setting up the timelimit according to the problem
+if [ "$3" == "" ]; then
+time=5
+else
+time=$3
+fi
+let "ttime = $time + 30"
+
+if [ "$2" == "" ]; then
+ exe=run.exe
+else
+ exe=$2
+fi
+
+rm -f $exe compileit.retcode runit.retcode 2>/dev/null
+cat < compileit.sh
+#!/bin/bash
+cc=\`which g++\`
+[ -x "\$cc" ] || cc=/usr/bin/g++
+if [ ! -x "\$cc" ]; then
+ echo "\$cc not found or it's not executable"
+ exit 47
+fi
+cd src
+"\$cc" -static -O2 -o ../$exe $name -lm
+echo \$? > ../compileit.retcode
+exit 0
+EOF
+chmod 755 compileit.sh
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ echo "Internal directory is $cdir"
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+ $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/abacaxi/compile/java b/doc/problemexamples/abacaxi/compile/java
new file mode 100644
index 0000000..f62215b
--- /dev/null
+++ b/doc/problemexamples/abacaxi/compile/java
@@ -0,0 +1,189 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 21/july/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.jar)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ if [ "${name##*.}" == "zip" ]; then
+ name=`basename $name .zip`
+ else
+ name=`basename $name .ZIP`
+ fi
+else
+ cp $name src
+fi
+chown -R $bocau src
+chmod -R 700 src
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$4
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+maxm=512
+if [ "$4" != "" -a "$4" -gt "0" ]; then
+maxm=$4
+fi
+
+if [ "$2" == "" ]; then
+ jarfile=run.jar
+else
+ jarfile=$2
+fi
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+
+cat < compileit.sh
+#!/bin/bash
+javac=`which javac`
+[ -x "\$javac" ] || javac=/usr/bin/javac
+if [ ! -x \$javac ]; then
+ echo "\$javac not found or it's not executable"
+ exit 47
+fi
+jar=`which jar`
+[ -x "\$jar" ] || jar=/usr/bin/jar
+if [ ! -x \$jar ]; then
+ echo "\$jar not found or it's not executable"
+ exit 47
+fi
+export CLASSPATH=.:\$CLASSPATH
+cd src
+if [ -r "$name" ]; then
+ \$javac "$name"
+ echo \$? > ../compileit.retcode
+fi
+find . -name "*.java" | while read lin; do
+ \$javac "\$lin"
+ echo \$? > ../compileit.retcode
+done
+rm -f ../$jarfile
+\$jar cvf ../$jarfile *
+exit 0
+EOF
+chmod 755 compileit.sh
+
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+
+$sf -r1 -t$time -T$ttime -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+# $javac "$name"
+ $sf -r1 -t$time -T$ttime -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/abacaxi/compile/pas b/doc/problemexamples/abacaxi/compile/pas
new file mode 100644
index 0000000..e0b73ca
--- /dev/null
+++ b/doc/problemexamples/abacaxi/compile/pas
@@ -0,0 +1,172 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 28/aug/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.exe)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes, default 512M)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ name="*.c"
+else
+ cp "$name" src
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+maxm=512000
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ maxm=${4}000
+ fi
+fi
+
+# setting up the timelimit according to the problem
+if [ "$3" == "" ]; then
+time=5
+else
+time=$3
+fi
+let "ttime = $time + 30"
+
+if [ "$2" == "" ]; then
+ exe=run.exe
+else
+ exe=$2
+fi
+
+rm -f $exe compileit.retcode runit.retcode 2>/dev/null
+cat < compileit.sh
+#!/bin/bash
+cc=\`which fpc\`
+[ -x "\$cc" ] || cc=/usr/bin/fpc
+if [ ! -x "\$cc" ]; then
+ echo "\$cc not found or it's not executable"
+ exit 47
+fi
+cd src
+"\$cc" -Xt -XS -O2 -o../$exe $name
+echo \$? > ../compileit.retcode
+exit 0
+EOF
+chmod 755 compileit.sh
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ echo "Internal directory is $cdir"
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+ $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/abacaxi/description/abacaxi.txt b/doc/problemexamples/abacaxi/description/abacaxi.txt
new file mode 100644
index 0000000..4cd89f0
--- /dev/null
+++ b/doc/problemexamples/abacaxi/description/abacaxi.txt
@@ -0,0 +1 @@
+THIS IS THE FILE DESCRIBING THE PROBLEM! IT CAN BE A PDF OR ANY OTHER FORMAT...
diff --git a/doc/problemexamples/abacaxi/description/problem.info b/doc/problemexamples/abacaxi/description/problem.info
new file mode 100644
index 0000000..b4b6af8
--- /dev/null
+++ b/doc/problemexamples/abacaxi/description/problem.info
@@ -0,0 +1,3 @@
+basename=abacaxi
+fullname=The abacaxi problem
+descfile=abacaxi.txt
diff --git a/doc/problemexamples/abacaxi/input/abacaxi b/doc/problemexamples/abacaxi/input/abacaxi
new file mode 100644
index 0000000..26d3afe
--- /dev/null
+++ b/doc/problemexamples/abacaxi/input/abacaxi
@@ -0,0 +1,25 @@
+5
+32 37 82 46 32
+13 40 75 62 19
+8
+14 22 29 41 72 25 68 90
+22 19 21 45 70 46 66 80
+3
+2 4 5
+8 8 8
+8
+12 1 0 8 5 0 9 4
+0 0 13 0 0 13 0 0
+8
+8 8 8 8 8 8 8 8
+7 9 5 8 9 5 9 7
+1
+0
+0
+999
+1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+999
+ 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0
diff --git a/doc/problemexamples/abacaxi/limits/c b/doc/problemexamples/abacaxi/limits/c
new file mode 100644
index 0000000..b5aec73
--- /dev/null
+++ b/doc/problemexamples/abacaxi/limits/c
@@ -0,0 +1,15 @@
+#!/bin/bash
+# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename
+echo 4
+# and the number of repetitions to run within the given timelimit in the second line
+echo 10
+# and the maximum amount of memory per repetition in the third line (in Mbytes)
+echo 512
+# and the maximum file size in the fourth line (in kbytes)
+echo 1024
+# and shall return zero to indicate no failure
+exit 0
+# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be
+# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is
+# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs
+# the value.
diff --git a/doc/problemexamples/abacaxi/limits/cpp b/doc/problemexamples/abacaxi/limits/cpp
new file mode 100644
index 0000000..b5aec73
--- /dev/null
+++ b/doc/problemexamples/abacaxi/limits/cpp
@@ -0,0 +1,15 @@
+#!/bin/bash
+# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename
+echo 4
+# and the number of repetitions to run within the given timelimit in the second line
+echo 10
+# and the maximum amount of memory per repetition in the third line (in Mbytes)
+echo 512
+# and the maximum file size in the fourth line (in kbytes)
+echo 1024
+# and shall return zero to indicate no failure
+exit 0
+# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be
+# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is
+# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs
+# the value.
diff --git a/doc/problemexamples/abacaxi/limits/java b/doc/problemexamples/abacaxi/limits/java
new file mode 100644
index 0000000..b5aec73
--- /dev/null
+++ b/doc/problemexamples/abacaxi/limits/java
@@ -0,0 +1,15 @@
+#!/bin/bash
+# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename
+echo 4
+# and the number of repetitions to run within the given timelimit in the second line
+echo 10
+# and the maximum amount of memory per repetition in the third line (in Mbytes)
+echo 512
+# and the maximum file size in the fourth line (in kbytes)
+echo 1024
+# and shall return zero to indicate no failure
+exit 0
+# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be
+# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is
+# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs
+# the value.
diff --git a/doc/problemexamples/abacaxi/output/abacaxi b/doc/problemexamples/abacaxi/output/abacaxi
new file mode 100644
index 0000000..2e9fd8b
--- /dev/null
+++ b/doc/problemexamples/abacaxi/output/abacaxi
@@ -0,0 +1,24 @@
+Fazenda 1
+Inicio 1 Fim 3
+
+Fazenda 2
+Inicio 7 Fim 8
+
+Fazenda 3
+O produtor so teve prejuizo nesta fazenda
+
+Fazenda 4
+Inicio 1 Fim 2
+
+Fazenda 5
+Inicio 1 Fim 6
+
+Fazenda 6
+Inicio 1 Fim 1
+
+Fazenda 7
+Inicio 1 Fim 999
+
+Fazenda 8
+Inicio 1 Fim 999
+
diff --git a/doc/problemexamples/abacaxi/run/c b/doc/problemexamples/abacaxi/run/c
new file mode 100755
index 0000000..b46e5f9
--- /dev/null
+++ b/doc/problemexamples/abacaxi/run/c
@@ -0,0 +1,128 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 22/aug/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 exe_file
+# $2 input_file
+# $3 timelimit (limit to run all the repetitions, by default only one repetition)
+# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit)
+# $5 maximum allowed memory (in MBytes)
+# $6 maximum allowed output size (in KBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -x "$1" ]; then
+ echo "$1 not found (or is not in the current dir) or it's not executable"
+ exit 44
+fi
+if [ ! -r "$2" ]; then
+ echo "$2 not found (or is not in the current dir) or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$3
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+nruns=1
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ nruns=$4
+ fi
+fi
+maxm=512000
+if [ "$5" != "" ]; then
+ if [ "$5" -gt "0" ]; then
+ maxm=${5}000
+ fi
+fi
+maxf=1024
+if [ "$6" != "" ]; then
+ if [ "$6" -gt "0" ]; then
+ maxf=${6}
+ fi
+fi
+
+cp "$2" stdin0 2>/dev/null
+cp "$1" run.exe 2>/dev/null
+
+file run.exe | grep -iq "statically linked"
+if [ "$?" != "0" ]; then
+ echo "Aborting because $1 is not statically linked"
+ exit 47
+fi
+
+cdir=`pwd`
+echo "Current directory is $cdir -- chrooting on it" >&2
+$sf -F10 -f$maxf -r$nruns -n1 -R$cdir -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d$maxm -m$maxm -t$time -T$ttime -istdin0 ./run.exe
+ret=$?
+if [ $ret -gt 10 ]; then
+ ret=0
+fi
+if [ -f stdout0 ]; then
+ cat stdout0
+fi
+exit $ret
diff --git a/doc/problemexamples/abacaxi/run/cpp b/doc/problemexamples/abacaxi/run/cpp
new file mode 100755
index 0000000..b46e5f9
--- /dev/null
+++ b/doc/problemexamples/abacaxi/run/cpp
@@ -0,0 +1,128 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 22/aug/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 exe_file
+# $2 input_file
+# $3 timelimit (limit to run all the repetitions, by default only one repetition)
+# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit)
+# $5 maximum allowed memory (in MBytes)
+# $6 maximum allowed output size (in KBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -x "$1" ]; then
+ echo "$1 not found (or is not in the current dir) or it's not executable"
+ exit 44
+fi
+if [ ! -r "$2" ]; then
+ echo "$2 not found (or is not in the current dir) or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$3
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+nruns=1
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ nruns=$4
+ fi
+fi
+maxm=512000
+if [ "$5" != "" ]; then
+ if [ "$5" -gt "0" ]; then
+ maxm=${5}000
+ fi
+fi
+maxf=1024
+if [ "$6" != "" ]; then
+ if [ "$6" -gt "0" ]; then
+ maxf=${6}
+ fi
+fi
+
+cp "$2" stdin0 2>/dev/null
+cp "$1" run.exe 2>/dev/null
+
+file run.exe | grep -iq "statically linked"
+if [ "$?" != "0" ]; then
+ echo "Aborting because $1 is not statically linked"
+ exit 47
+fi
+
+cdir=`pwd`
+echo "Current directory is $cdir -- chrooting on it" >&2
+$sf -F10 -f$maxf -r$nruns -n1 -R$cdir -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d$maxm -m$maxm -t$time -T$ttime -istdin0 ./run.exe
+ret=$?
+if [ $ret -gt 10 ]; then
+ ret=0
+fi
+if [ -f stdout0 ]; then
+ cat stdout0
+fi
+exit $ret
diff --git a/doc/problemexamples/abacaxi/run/java b/doc/problemexamples/abacaxi/run/java
new file mode 100755
index 0000000..d6a73a5
--- /dev/null
+++ b/doc/problemexamples/abacaxi/run/java
@@ -0,0 +1,183 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 14/sept/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 main_class
+# $2 input_file
+# $3 timelimit (limit to run all the repetitions, by default only one repetition)
+# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit)
+# $5 maximum allowed memory (in MBytes)
+# $6 maximum allowed output size (in KBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ -r run.exe ]; then
+ mv run.exe run.jar
+fi
+if [ -r "$1" ]; then
+ mv "$1" run.jar
+fi
+if [ ! -r run.jar ]; then
+ echo "ERROR: file run.jar not found - possible error during compilation"
+ exit 1
+fi
+name="$1"
+if [ "${name##*.}" == "class" -a "${name##*.}" == "CLASS" ]; then
+ echo "WARNING: removing .class file extension"
+fi
+if [ "${name##*.}" == "class" ]; then
+ name=`basename "$1" .class`
+fi
+if [ "${name##*.}" == "CLASS" ]; then
+ name=`basename "$1" .CLASS`
+fi
+if [ ! -r "$2" ]; then
+ echo "$2 not found (or is not in the current dir) or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$3
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+nruns=1
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ nruns=$4
+ fi
+fi
+maxm=512000
+if [ "$5" != "" ]; then
+ if [ "$5" -gt "0" ]; then
+ maxm=${5}000
+ fi
+fi
+maxf=1024
+if [ "$6" != "" ]; then
+ if [ "$6" -gt "0" ]; then
+ maxf=${6}
+ fi
+fi
+
+rm -f runit.retcode 2>/dev/null
+cp "$2" stdin0 2>/dev/null
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+java=`which java`
+[ -x "\$java" ] || java=/usr/bin/java
+if [ ! -x \$java ]; then
+ echo "\$java not found or it's not executable"
+ exit 47
+fi
+export CLASSPATH=.:./run.jar:$CLASSPATH
+$sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 -- \$java -Xmx${maxm}K -Xms${maxm}K "$name"
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ fi
+ if [ "$ret" == "" ]; then
+ echo "Execution error - check autojudging"
+ exit 49
+ fi
+else
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ java=`which java`
+ [ -x "$java" ] || java=/usr/bin/java
+ if [ ! -x $java ]; then
+ echo "$java not found or it's not executable"
+ exit 47
+ fi
+ $sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 -- $java -cp run.jar -Xmx${maxm}K -Xms${maxm}K "$name"
+ ret=$?
+fi
+if [ $ret -gt 10 ]; then
+ echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <"
+ ret=9
+fi
+if [ -f stdout0 ]; then
+ cat stdout0
+fi
+exit $ret
diff --git a/doc/problemexamples/abacaxi/tests/c b/doc/problemexamples/abacaxi/tests/c
new file mode 100755
index 0000000..de0a9c5
--- /dev/null
+++ b/doc/problemexamples/abacaxi/tests/c
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# This file performs a test of the autojudge system. It can run whatever you feel important to test the autojudge
+# and the script files that are included in the problem package
+
+cat > test.c <
+int main() {
+ char s[100];
+ scanf("%s", s);
+ printf("%s\n",s);
+ return 0;
+}
+EOF
+cat > test.in <.
+# ////////////////////////////////////////////////////////////////////////////////
+# // Last modified 21/jul/2012 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 problem_input (might be used by some specific checkers, here it is not)
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/doc/problemexamples/bits/compare/cpp b/doc/problemexamples/bits/compare/cpp
new file mode 100755
index 0000000..4998be3
--- /dev/null
+++ b/doc/problemexamples/bits/compare/cpp
@@ -0,0 +1,97 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+# // Last modified 21/jul/2012 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 problem_input (might be used by some specific checkers, here it is not)
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/doc/problemexamples/bits/compare/java b/doc/problemexamples/bits/compare/java
new file mode 100755
index 0000000..4998be3
--- /dev/null
+++ b/doc/problemexamples/bits/compare/java
@@ -0,0 +1,97 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+# // Last modified 21/jul/2012 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 problem_input (might be used by some specific checkers, here it is not)
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/doc/problemexamples/bits/compile/c b/doc/problemexamples/bits/compile/c
new file mode 100644
index 0000000..5376708
--- /dev/null
+++ b/doc/problemexamples/bits/compile/c
@@ -0,0 +1,172 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 21/july/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.exe)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes, default 512M)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ name="*.c"
+else
+ cp "$name" src
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+maxm=512000
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ maxm=${4}000
+ fi
+fi
+
+# setting up the timelimit according to the problem
+if [ "$3" == "" ]; then
+time=5
+else
+time=$3
+fi
+let "ttime = $time + 30"
+
+if [ "$2" == "" ]; then
+ exe=run.exe
+else
+ exe=$2
+fi
+
+rm -f $exe compileit.retcode runit.retcode 2>/dev/null
+cat < compileit.sh
+#!/bin/bash
+cc=\`which gcc\`
+[ -x "\$cc" ] || cc=/usr/bin/gcc
+if [ ! -x "\$cc" ]; then
+ echo "\$cc not found or it's not executable"
+ exit 47
+fi
+cd src
+"\$cc" -static -O2 -o ../$exe $name -lm
+echo \$? > ../compileit.retcode
+exit 0
+EOF
+chmod 755 compileit.sh
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ echo "Internal directory is $cdir"
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+ $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/bits/compile/cpp b/doc/problemexamples/bits/compile/cpp
new file mode 100644
index 0000000..6a61bc1
--- /dev/null
+++ b/doc/problemexamples/bits/compile/cpp
@@ -0,0 +1,172 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 21/july/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.exe)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ name="*.c"
+else
+ cp "$name" src
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+maxm=512000
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ maxm=${4}000
+ fi
+fi
+
+# setting up the timelimit according to the problem
+if [ "$3" == "" ]; then
+time=5
+else
+time=$3
+fi
+let "ttime = $time + 30"
+
+if [ "$2" == "" ]; then
+ exe=run.exe
+else
+ exe=$2
+fi
+
+rm -f $exe compileit.retcode runit.retcode 2>/dev/null
+cat < compileit.sh
+#!/bin/bash
+cc=\`which g++\`
+[ -x "\$cc" ] || cc=/usr/bin/g++
+if [ ! -x "\$cc" ]; then
+ echo "\$cc not found or it's not executable"
+ exit 47
+fi
+cd src
+"\$cc" -static -O2 -o ../$exe $name -lm
+echo \$? > ../compileit.retcode
+exit 0
+EOF
+chmod 755 compileit.sh
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ echo "Internal directory is $cdir"
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+ $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/bits/compile/java b/doc/problemexamples/bits/compile/java
new file mode 100644
index 0000000..f62215b
--- /dev/null
+++ b/doc/problemexamples/bits/compile/java
@@ -0,0 +1,189 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 21/july/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.jar)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ if [ "${name##*.}" == "zip" ]; then
+ name=`basename $name .zip`
+ else
+ name=`basename $name .ZIP`
+ fi
+else
+ cp $name src
+fi
+chown -R $bocau src
+chmod -R 700 src
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$4
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+maxm=512
+if [ "$4" != "" -a "$4" -gt "0" ]; then
+maxm=$4
+fi
+
+if [ "$2" == "" ]; then
+ jarfile=run.jar
+else
+ jarfile=$2
+fi
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+
+cat < compileit.sh
+#!/bin/bash
+javac=`which javac`
+[ -x "\$javac" ] || javac=/usr/bin/javac
+if [ ! -x \$javac ]; then
+ echo "\$javac not found or it's not executable"
+ exit 47
+fi
+jar=`which jar`
+[ -x "\$jar" ] || jar=/usr/bin/jar
+if [ ! -x \$jar ]; then
+ echo "\$jar not found or it's not executable"
+ exit 47
+fi
+export CLASSPATH=.:\$CLASSPATH
+cd src
+if [ -r "$name" ]; then
+ \$javac "$name"
+ echo \$? > ../compileit.retcode
+fi
+find . -name "*.java" | while read lin; do
+ \$javac "\$lin"
+ echo \$? > ../compileit.retcode
+done
+rm -f ../$jarfile
+\$jar cvf ../$jarfile *
+exit 0
+EOF
+chmod 755 compileit.sh
+
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+
+$sf -r1 -t$time -T$ttime -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+# $javac "$name"
+ $sf -r1 -t$time -T$ttime -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/bits/compile/pas b/doc/problemexamples/bits/compile/pas
new file mode 100644
index 0000000..e0b73ca
--- /dev/null
+++ b/doc/problemexamples/bits/compile/pas
@@ -0,0 +1,172 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 28/aug/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.exe)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes, default 512M)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ name="*.c"
+else
+ cp "$name" src
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+maxm=512000
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ maxm=${4}000
+ fi
+fi
+
+# setting up the timelimit according to the problem
+if [ "$3" == "" ]; then
+time=5
+else
+time=$3
+fi
+let "ttime = $time + 30"
+
+if [ "$2" == "" ]; then
+ exe=run.exe
+else
+ exe=$2
+fi
+
+rm -f $exe compileit.retcode runit.retcode 2>/dev/null
+cat < compileit.sh
+#!/bin/bash
+cc=\`which fpc\`
+[ -x "\$cc" ] || cc=/usr/bin/fpc
+if [ ! -x "\$cc" ]; then
+ echo "\$cc not found or it's not executable"
+ exit 47
+fi
+cd src
+"\$cc" -Xt -XS -O2 -o../$exe $name
+echo \$? > ../compileit.retcode
+exit 0
+EOF
+chmod 755 compileit.sh
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ echo "Internal directory is $cdir"
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+ $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/bits/description/bits.txt b/doc/problemexamples/bits/description/bits.txt
new file mode 100644
index 0000000..4cd89f0
--- /dev/null
+++ b/doc/problemexamples/bits/description/bits.txt
@@ -0,0 +1 @@
+THIS IS THE FILE DESCRIBING THE PROBLEM! IT CAN BE A PDF OR ANY OTHER FORMAT...
diff --git a/doc/problemexamples/bits/description/problem.info b/doc/problemexamples/bits/description/problem.info
new file mode 100644
index 0000000..e1bc487
--- /dev/null
+++ b/doc/problemexamples/bits/description/problem.info
@@ -0,0 +1,3 @@
+basename=bits
+fullname=The Problem of bits
+descfile=bits.txt
diff --git a/doc/problemexamples/bits/input/bits b/doc/problemexamples/bits/input/bits
new file mode 100644
index 0000000..ef548be
--- /dev/null
+++ b/doc/problemexamples/bits/input/bits
@@ -0,0 +1,9 @@
+1 7
+4 1 10 20 30
+2 2000 999
+3 0 0 0
+2 1 1000
+1000 1073741824 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 0
+1 8
+0
diff --git a/doc/problemexamples/bits/limits/c b/doc/problemexamples/bits/limits/c
new file mode 100644
index 0000000..b5aec73
--- /dev/null
+++ b/doc/problemexamples/bits/limits/c
@@ -0,0 +1,15 @@
+#!/bin/bash
+# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename
+echo 4
+# and the number of repetitions to run within the given timelimit in the second line
+echo 10
+# and the maximum amount of memory per repetition in the third line (in Mbytes)
+echo 512
+# and the maximum file size in the fourth line (in kbytes)
+echo 1024
+# and shall return zero to indicate no failure
+exit 0
+# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be
+# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is
+# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs
+# the value.
diff --git a/doc/problemexamples/bits/limits/cpp b/doc/problemexamples/bits/limits/cpp
new file mode 100644
index 0000000..b5aec73
--- /dev/null
+++ b/doc/problemexamples/bits/limits/cpp
@@ -0,0 +1,15 @@
+#!/bin/bash
+# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename
+echo 4
+# and the number of repetitions to run within the given timelimit in the second line
+echo 10
+# and the maximum amount of memory per repetition in the third line (in Mbytes)
+echo 512
+# and the maximum file size in the fourth line (in kbytes)
+echo 1024
+# and shall return zero to indicate no failure
+exit 0
+# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be
+# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is
+# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs
+# the value.
diff --git a/doc/problemexamples/bits/limits/java b/doc/problemexamples/bits/limits/java
new file mode 100644
index 0000000..b5aec73
--- /dev/null
+++ b/doc/problemexamples/bits/limits/java
@@ -0,0 +1,15 @@
+#!/bin/bash
+# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename
+echo 4
+# and the number of repetitions to run within the given timelimit in the second line
+echo 10
+# and the maximum amount of memory per repetition in the third line (in Mbytes)
+echo 512
+# and the maximum file size in the fourth line (in kbytes)
+echo 1024
+# and shall return zero to indicate no failure
+exit 0
+# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be
+# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is
+# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs
+# the value.
diff --git a/doc/problemexamples/bits/output/bits b/doc/problemexamples/bits/output/bits
new file mode 100644
index 0000000..7749442
--- /dev/null
+++ b/doc/problemexamples/bits/output/bits
@@ -0,0 +1,24 @@
+Instancia 1
+3
+
+Instancia 2
+20
+
+Instancia 3
+22
+
+Instancia 4
+3
+
+Instancia 5
+20
+
+Instancia 6
+31000
+
+Instancia 7
+1
+
+Instancia 8
+4
+
diff --git a/doc/problemexamples/bits/run/c b/doc/problemexamples/bits/run/c
new file mode 100755
index 0000000..b46e5f9
--- /dev/null
+++ b/doc/problemexamples/bits/run/c
@@ -0,0 +1,128 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 22/aug/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 exe_file
+# $2 input_file
+# $3 timelimit (limit to run all the repetitions, by default only one repetition)
+# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit)
+# $5 maximum allowed memory (in MBytes)
+# $6 maximum allowed output size (in KBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -x "$1" ]; then
+ echo "$1 not found (or is not in the current dir) or it's not executable"
+ exit 44
+fi
+if [ ! -r "$2" ]; then
+ echo "$2 not found (or is not in the current dir) or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$3
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+nruns=1
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ nruns=$4
+ fi
+fi
+maxm=512000
+if [ "$5" != "" ]; then
+ if [ "$5" -gt "0" ]; then
+ maxm=${5}000
+ fi
+fi
+maxf=1024
+if [ "$6" != "" ]; then
+ if [ "$6" -gt "0" ]; then
+ maxf=${6}
+ fi
+fi
+
+cp "$2" stdin0 2>/dev/null
+cp "$1" run.exe 2>/dev/null
+
+file run.exe | grep -iq "statically linked"
+if [ "$?" != "0" ]; then
+ echo "Aborting because $1 is not statically linked"
+ exit 47
+fi
+
+cdir=`pwd`
+echo "Current directory is $cdir -- chrooting on it" >&2
+$sf -F10 -f$maxf -r$nruns -n1 -R$cdir -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d$maxm -m$maxm -t$time -T$ttime -istdin0 ./run.exe
+ret=$?
+if [ $ret -gt 10 ]; then
+ ret=0
+fi
+if [ -f stdout0 ]; then
+ cat stdout0
+fi
+exit $ret
diff --git a/doc/problemexamples/bits/run/cpp b/doc/problemexamples/bits/run/cpp
new file mode 100755
index 0000000..b46e5f9
--- /dev/null
+++ b/doc/problemexamples/bits/run/cpp
@@ -0,0 +1,128 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 22/aug/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 exe_file
+# $2 input_file
+# $3 timelimit (limit to run all the repetitions, by default only one repetition)
+# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit)
+# $5 maximum allowed memory (in MBytes)
+# $6 maximum allowed output size (in KBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -x "$1" ]; then
+ echo "$1 not found (or is not in the current dir) or it's not executable"
+ exit 44
+fi
+if [ ! -r "$2" ]; then
+ echo "$2 not found (or is not in the current dir) or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$3
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+nruns=1
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ nruns=$4
+ fi
+fi
+maxm=512000
+if [ "$5" != "" ]; then
+ if [ "$5" -gt "0" ]; then
+ maxm=${5}000
+ fi
+fi
+maxf=1024
+if [ "$6" != "" ]; then
+ if [ "$6" -gt "0" ]; then
+ maxf=${6}
+ fi
+fi
+
+cp "$2" stdin0 2>/dev/null
+cp "$1" run.exe 2>/dev/null
+
+file run.exe | grep -iq "statically linked"
+if [ "$?" != "0" ]; then
+ echo "Aborting because $1 is not statically linked"
+ exit 47
+fi
+
+cdir=`pwd`
+echo "Current directory is $cdir -- chrooting on it" >&2
+$sf -F10 -f$maxf -r$nruns -n1 -R$cdir -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d$maxm -m$maxm -t$time -T$ttime -istdin0 ./run.exe
+ret=$?
+if [ $ret -gt 10 ]; then
+ ret=0
+fi
+if [ -f stdout0 ]; then
+ cat stdout0
+fi
+exit $ret
diff --git a/doc/problemexamples/bits/run/java b/doc/problemexamples/bits/run/java
new file mode 100755
index 0000000..d6a73a5
--- /dev/null
+++ b/doc/problemexamples/bits/run/java
@@ -0,0 +1,183 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 14/sept/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 main_class
+# $2 input_file
+# $3 timelimit (limit to run all the repetitions, by default only one repetition)
+# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit)
+# $5 maximum allowed memory (in MBytes)
+# $6 maximum allowed output size (in KBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ -r run.exe ]; then
+ mv run.exe run.jar
+fi
+if [ -r "$1" ]; then
+ mv "$1" run.jar
+fi
+if [ ! -r run.jar ]; then
+ echo "ERROR: file run.jar not found - possible error during compilation"
+ exit 1
+fi
+name="$1"
+if [ "${name##*.}" == "class" -a "${name##*.}" == "CLASS" ]; then
+ echo "WARNING: removing .class file extension"
+fi
+if [ "${name##*.}" == "class" ]; then
+ name=`basename "$1" .class`
+fi
+if [ "${name##*.}" == "CLASS" ]; then
+ name=`basename "$1" .CLASS`
+fi
+if [ ! -r "$2" ]; then
+ echo "$2 not found (or is not in the current dir) or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$3
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+nruns=1
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ nruns=$4
+ fi
+fi
+maxm=512000
+if [ "$5" != "" ]; then
+ if [ "$5" -gt "0" ]; then
+ maxm=${5}000
+ fi
+fi
+maxf=1024
+if [ "$6" != "" ]; then
+ if [ "$6" -gt "0" ]; then
+ maxf=${6}
+ fi
+fi
+
+rm -f runit.retcode 2>/dev/null
+cp "$2" stdin0 2>/dev/null
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+java=`which java`
+[ -x "\$java" ] || java=/usr/bin/java
+if [ ! -x \$java ]; then
+ echo "\$java not found or it's not executable"
+ exit 47
+fi
+export CLASSPATH=.:./run.jar:$CLASSPATH
+$sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 -- \$java -Xmx${maxm}K -Xms${maxm}K "$name"
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ fi
+ if [ "$ret" == "" ]; then
+ echo "Execution error - check autojudging"
+ exit 49
+ fi
+else
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ java=`which java`
+ [ -x "$java" ] || java=/usr/bin/java
+ if [ ! -x $java ]; then
+ echo "$java not found or it's not executable"
+ exit 47
+ fi
+ $sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 -- $java -cp run.jar -Xmx${maxm}K -Xms${maxm}K "$name"
+ ret=$?
+fi
+if [ $ret -gt 10 ]; then
+ echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <"
+ ret=9
+fi
+if [ -f stdout0 ]; then
+ cat stdout0
+fi
+exit $ret
diff --git a/doc/problemexamples/bits/tests/c b/doc/problemexamples/bits/tests/c
new file mode 100755
index 0000000..de0a9c5
--- /dev/null
+++ b/doc/problemexamples/bits/tests/c
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# This file performs a test of the autojudge system. It can run whatever you feel important to test the autojudge
+# and the script files that are included in the problem package
+
+cat > test.c <
+int main() {
+ char s[100];
+ scanf("%s", s);
+ printf("%s\n",s);
+ return 0;
+}
+EOF
+cat > test.in <.
+# ////////////////////////////////////////////////////////////////////////////////
+# // Last modified 21/jul/2012 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 problem_input (might be used by some specific checkers, here it is not)
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/doc/problemexamples/formiga/compare/cpp b/doc/problemexamples/formiga/compare/cpp
new file mode 100755
index 0000000..4998be3
--- /dev/null
+++ b/doc/problemexamples/formiga/compare/cpp
@@ -0,0 +1,97 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+# // Last modified 21/jul/2012 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 problem_input (might be used by some specific checkers, here it is not)
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/doc/problemexamples/formiga/compare/java b/doc/problemexamples/formiga/compare/java
new file mode 100755
index 0000000..4998be3
--- /dev/null
+++ b/doc/problemexamples/formiga/compare/java
@@ -0,0 +1,97 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+# // Last modified 21/jul/2012 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 problem_input (might be used by some specific checkers, here it is not)
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/doc/problemexamples/formiga/compile/c b/doc/problemexamples/formiga/compile/c
new file mode 100644
index 0000000..5376708
--- /dev/null
+++ b/doc/problemexamples/formiga/compile/c
@@ -0,0 +1,172 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 21/july/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.exe)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes, default 512M)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ name="*.c"
+else
+ cp "$name" src
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+maxm=512000
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ maxm=${4}000
+ fi
+fi
+
+# setting up the timelimit according to the problem
+if [ "$3" == "" ]; then
+time=5
+else
+time=$3
+fi
+let "ttime = $time + 30"
+
+if [ "$2" == "" ]; then
+ exe=run.exe
+else
+ exe=$2
+fi
+
+rm -f $exe compileit.retcode runit.retcode 2>/dev/null
+cat < compileit.sh
+#!/bin/bash
+cc=\`which gcc\`
+[ -x "\$cc" ] || cc=/usr/bin/gcc
+if [ ! -x "\$cc" ]; then
+ echo "\$cc not found or it's not executable"
+ exit 47
+fi
+cd src
+"\$cc" -static -O2 -o ../$exe $name -lm
+echo \$? > ../compileit.retcode
+exit 0
+EOF
+chmod 755 compileit.sh
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ echo "Internal directory is $cdir"
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+ $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/formiga/compile/cpp b/doc/problemexamples/formiga/compile/cpp
new file mode 100644
index 0000000..6a61bc1
--- /dev/null
+++ b/doc/problemexamples/formiga/compile/cpp
@@ -0,0 +1,172 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 21/july/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.exe)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ name="*.c"
+else
+ cp "$name" src
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+maxm=512000
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ maxm=${4}000
+ fi
+fi
+
+# setting up the timelimit according to the problem
+if [ "$3" == "" ]; then
+time=5
+else
+time=$3
+fi
+let "ttime = $time + 30"
+
+if [ "$2" == "" ]; then
+ exe=run.exe
+else
+ exe=$2
+fi
+
+rm -f $exe compileit.retcode runit.retcode 2>/dev/null
+cat < compileit.sh
+#!/bin/bash
+cc=\`which g++\`
+[ -x "\$cc" ] || cc=/usr/bin/g++
+if [ ! -x "\$cc" ]; then
+ echo "\$cc not found or it's not executable"
+ exit 47
+fi
+cd src
+"\$cc" -static -O2 -o ../$exe $name -lm
+echo \$? > ../compileit.retcode
+exit 0
+EOF
+chmod 755 compileit.sh
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ echo "Internal directory is $cdir"
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+ $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/formiga/compile/java b/doc/problemexamples/formiga/compile/java
new file mode 100644
index 0000000..f62215b
--- /dev/null
+++ b/doc/problemexamples/formiga/compile/java
@@ -0,0 +1,189 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 21/july/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.jar)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ if [ "${name##*.}" == "zip" ]; then
+ name=`basename $name .zip`
+ else
+ name=`basename $name .ZIP`
+ fi
+else
+ cp $name src
+fi
+chown -R $bocau src
+chmod -R 700 src
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$4
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+maxm=512
+if [ "$4" != "" -a "$4" -gt "0" ]; then
+maxm=$4
+fi
+
+if [ "$2" == "" ]; then
+ jarfile=run.jar
+else
+ jarfile=$2
+fi
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+
+cat < compileit.sh
+#!/bin/bash
+javac=`which javac`
+[ -x "\$javac" ] || javac=/usr/bin/javac
+if [ ! -x \$javac ]; then
+ echo "\$javac not found or it's not executable"
+ exit 47
+fi
+jar=`which jar`
+[ -x "\$jar" ] || jar=/usr/bin/jar
+if [ ! -x \$jar ]; then
+ echo "\$jar not found or it's not executable"
+ exit 47
+fi
+export CLASSPATH=.:\$CLASSPATH
+cd src
+if [ -r "$name" ]; then
+ \$javac "$name"
+ echo \$? > ../compileit.retcode
+fi
+find . -name "*.java" | while read lin; do
+ \$javac "\$lin"
+ echo \$? > ../compileit.retcode
+done
+rm -f ../$jarfile
+\$jar cvf ../$jarfile *
+exit 0
+EOF
+chmod 755 compileit.sh
+
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+
+$sf -r1 -t$time -T$ttime -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+# $javac "$name"
+ $sf -r1 -t$time -T$ttime -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/formiga/compile/pas b/doc/problemexamples/formiga/compile/pas
new file mode 100644
index 0000000..e0b73ca
--- /dev/null
+++ b/doc/problemexamples/formiga/compile/pas
@@ -0,0 +1,172 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 28/aug/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.exe)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes, default 512M)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ name="*.c"
+else
+ cp "$name" src
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+maxm=512000
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ maxm=${4}000
+ fi
+fi
+
+# setting up the timelimit according to the problem
+if [ "$3" == "" ]; then
+time=5
+else
+time=$3
+fi
+let "ttime = $time + 30"
+
+if [ "$2" == "" ]; then
+ exe=run.exe
+else
+ exe=$2
+fi
+
+rm -f $exe compileit.retcode runit.retcode 2>/dev/null
+cat < compileit.sh
+#!/bin/bash
+cc=\`which fpc\`
+[ -x "\$cc" ] || cc=/usr/bin/fpc
+if [ ! -x "\$cc" ]; then
+ echo "\$cc not found or it's not executable"
+ exit 47
+fi
+cd src
+"\$cc" -Xt -XS -O2 -o../$exe $name
+echo \$? > ../compileit.retcode
+exit 0
+EOF
+chmod 755 compileit.sh
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ echo "Internal directory is $cdir"
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+ $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/formiga/description/formiga.txt b/doc/problemexamples/formiga/description/formiga.txt
new file mode 100644
index 0000000..4cd89f0
--- /dev/null
+++ b/doc/problemexamples/formiga/description/formiga.txt
@@ -0,0 +1 @@
+THIS IS THE FILE DESCRIBING THE PROBLEM! IT CAN BE A PDF OR ANY OTHER FORMAT...
diff --git a/doc/problemexamples/formiga/description/problem.info b/doc/problemexamples/formiga/description/problem.info
new file mode 100644
index 0000000..0bd73c3
--- /dev/null
+++ b/doc/problemexamples/formiga/description/problem.info
@@ -0,0 +1,3 @@
+basename=formiga
+fullname=The formiga test problem
+descfile=formiga.txt
diff --git a/doc/problemexamples/formiga/input/formiga b/doc/problemexamples/formiga/input/formiga
new file mode 100644
index 0000000..c9a59b2
--- /dev/null
+++ b/doc/problemexamples/formiga/input/formiga
@@ -0,0 +1,15 @@
+1 1 Norte
+4 8 Norte
+3 2 Sul
+100000 100000 Oeste
+6 6 Sul
+4 13 Oeste
+4 14 Sul
+4 13 Leste
+640 648 Norte
+45 99998 Leste
+45 99995 Oeste
+99999 99998 Norte
+99999 99996 Oeste
+445 1157 Sul
+100000 0 Qqlixo
diff --git a/doc/problemexamples/formiga/limits/c b/doc/problemexamples/formiga/limits/c
new file mode 100644
index 0000000..b5aec73
--- /dev/null
+++ b/doc/problemexamples/formiga/limits/c
@@ -0,0 +1,15 @@
+#!/bin/bash
+# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename
+echo 4
+# and the number of repetitions to run within the given timelimit in the second line
+echo 10
+# and the maximum amount of memory per repetition in the third line (in Mbytes)
+echo 512
+# and the maximum file size in the fourth line (in kbytes)
+echo 1024
+# and shall return zero to indicate no failure
+exit 0
+# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be
+# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is
+# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs
+# the value.
diff --git a/doc/problemexamples/formiga/limits/cpp b/doc/problemexamples/formiga/limits/cpp
new file mode 100644
index 0000000..b5aec73
--- /dev/null
+++ b/doc/problemexamples/formiga/limits/cpp
@@ -0,0 +1,15 @@
+#!/bin/bash
+# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename
+echo 4
+# and the number of repetitions to run within the given timelimit in the second line
+echo 10
+# and the maximum amount of memory per repetition in the third line (in Mbytes)
+echo 512
+# and the maximum file size in the fourth line (in kbytes)
+echo 1024
+# and shall return zero to indicate no failure
+exit 0
+# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be
+# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is
+# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs
+# the value.
diff --git a/doc/problemexamples/formiga/limits/java b/doc/problemexamples/formiga/limits/java
new file mode 100644
index 0000000..b5aec73
--- /dev/null
+++ b/doc/problemexamples/formiga/limits/java
@@ -0,0 +1,15 @@
+#!/bin/bash
+# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename
+echo 4
+# and the number of repetitions to run within the given timelimit in the second line
+echo 10
+# and the maximum amount of memory per repetition in the third line (in Mbytes)
+echo 512
+# and the maximum file size in the fourth line (in kbytes)
+echo 1024
+# and shall return zero to indicate no failure
+exit 0
+# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be
+# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is
+# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs
+# the value.
diff --git a/doc/problemexamples/formiga/output/formiga b/doc/problemexamples/formiga/output/formiga
new file mode 100644
index 0000000..499641c
--- /dev/null
+++ b/doc/problemexamples/formiga/output/formiga
@@ -0,0 +1,14 @@
+100% 0 Sul
+ 25% 1 Leste
+100% 3 Oeste
+ 0% 0 Leste
+ 17% 0 Norte
+100% 15 Norte
+ 50% 7 Leste
+100% 15 Sul
+ 12% 159 Oeste
+100% 100041 Norte
+ 20% 20006 Leste
+100% 199995 Leste
+ 33% 66663 Sul
+ 1% 16 Norte
diff --git a/doc/problemexamples/formiga/run/c b/doc/problemexamples/formiga/run/c
new file mode 100755
index 0000000..b46e5f9
--- /dev/null
+++ b/doc/problemexamples/formiga/run/c
@@ -0,0 +1,128 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 22/aug/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 exe_file
+# $2 input_file
+# $3 timelimit (limit to run all the repetitions, by default only one repetition)
+# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit)
+# $5 maximum allowed memory (in MBytes)
+# $6 maximum allowed output size (in KBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -x "$1" ]; then
+ echo "$1 not found (or is not in the current dir) or it's not executable"
+ exit 44
+fi
+if [ ! -r "$2" ]; then
+ echo "$2 not found (or is not in the current dir) or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$3
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+nruns=1
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ nruns=$4
+ fi
+fi
+maxm=512000
+if [ "$5" != "" ]; then
+ if [ "$5" -gt "0" ]; then
+ maxm=${5}000
+ fi
+fi
+maxf=1024
+if [ "$6" != "" ]; then
+ if [ "$6" -gt "0" ]; then
+ maxf=${6}
+ fi
+fi
+
+cp "$2" stdin0 2>/dev/null
+cp "$1" run.exe 2>/dev/null
+
+file run.exe | grep -iq "statically linked"
+if [ "$?" != "0" ]; then
+ echo "Aborting because $1 is not statically linked"
+ exit 47
+fi
+
+cdir=`pwd`
+echo "Current directory is $cdir -- chrooting on it" >&2
+$sf -F10 -f$maxf -r$nruns -n1 -R$cdir -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d$maxm -m$maxm -t$time -T$ttime -istdin0 ./run.exe
+ret=$?
+if [ $ret -gt 10 ]; then
+ ret=0
+fi
+if [ -f stdout0 ]; then
+ cat stdout0
+fi
+exit $ret
diff --git a/doc/problemexamples/formiga/run/cpp b/doc/problemexamples/formiga/run/cpp
new file mode 100755
index 0000000..b46e5f9
--- /dev/null
+++ b/doc/problemexamples/formiga/run/cpp
@@ -0,0 +1,128 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 22/aug/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 exe_file
+# $2 input_file
+# $3 timelimit (limit to run all the repetitions, by default only one repetition)
+# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit)
+# $5 maximum allowed memory (in MBytes)
+# $6 maximum allowed output size (in KBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -x "$1" ]; then
+ echo "$1 not found (or is not in the current dir) or it's not executable"
+ exit 44
+fi
+if [ ! -r "$2" ]; then
+ echo "$2 not found (or is not in the current dir) or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$3
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+nruns=1
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ nruns=$4
+ fi
+fi
+maxm=512000
+if [ "$5" != "" ]; then
+ if [ "$5" -gt "0" ]; then
+ maxm=${5}000
+ fi
+fi
+maxf=1024
+if [ "$6" != "" ]; then
+ if [ "$6" -gt "0" ]; then
+ maxf=${6}
+ fi
+fi
+
+cp "$2" stdin0 2>/dev/null
+cp "$1" run.exe 2>/dev/null
+
+file run.exe | grep -iq "statically linked"
+if [ "$?" != "0" ]; then
+ echo "Aborting because $1 is not statically linked"
+ exit 47
+fi
+
+cdir=`pwd`
+echo "Current directory is $cdir -- chrooting on it" >&2
+$sf -F10 -f$maxf -r$nruns -n1 -R$cdir -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d$maxm -m$maxm -t$time -T$ttime -istdin0 ./run.exe
+ret=$?
+if [ $ret -gt 10 ]; then
+ ret=0
+fi
+if [ -f stdout0 ]; then
+ cat stdout0
+fi
+exit $ret
diff --git a/doc/problemexamples/formiga/run/java b/doc/problemexamples/formiga/run/java
new file mode 100755
index 0000000..d6a73a5
--- /dev/null
+++ b/doc/problemexamples/formiga/run/java
@@ -0,0 +1,183 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 14/sept/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 main_class
+# $2 input_file
+# $3 timelimit (limit to run all the repetitions, by default only one repetition)
+# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit)
+# $5 maximum allowed memory (in MBytes)
+# $6 maximum allowed output size (in KBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ -r run.exe ]; then
+ mv run.exe run.jar
+fi
+if [ -r "$1" ]; then
+ mv "$1" run.jar
+fi
+if [ ! -r run.jar ]; then
+ echo "ERROR: file run.jar not found - possible error during compilation"
+ exit 1
+fi
+name="$1"
+if [ "${name##*.}" == "class" -a "${name##*.}" == "CLASS" ]; then
+ echo "WARNING: removing .class file extension"
+fi
+if [ "${name##*.}" == "class" ]; then
+ name=`basename "$1" .class`
+fi
+if [ "${name##*.}" == "CLASS" ]; then
+ name=`basename "$1" .CLASS`
+fi
+if [ ! -r "$2" ]; then
+ echo "$2 not found (or is not in the current dir) or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$3
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+nruns=1
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ nruns=$4
+ fi
+fi
+maxm=512000
+if [ "$5" != "" ]; then
+ if [ "$5" -gt "0" ]; then
+ maxm=${5}000
+ fi
+fi
+maxf=1024
+if [ "$6" != "" ]; then
+ if [ "$6" -gt "0" ]; then
+ maxf=${6}
+ fi
+fi
+
+rm -f runit.retcode 2>/dev/null
+cp "$2" stdin0 2>/dev/null
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+java=`which java`
+[ -x "\$java" ] || java=/usr/bin/java
+if [ ! -x \$java ]; then
+ echo "\$java not found or it's not executable"
+ exit 47
+fi
+export CLASSPATH=.:./run.jar:$CLASSPATH
+$sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 -- \$java -Xmx${maxm}K -Xms${maxm}K "$name"
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ fi
+ if [ "$ret" == "" ]; then
+ echo "Execution error - check autojudging"
+ exit 49
+ fi
+else
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ java=`which java`
+ [ -x "$java" ] || java=/usr/bin/java
+ if [ ! -x $java ]; then
+ echo "$java not found or it's not executable"
+ exit 47
+ fi
+ $sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 -- $java -cp run.jar -Xmx${maxm}K -Xms${maxm}K "$name"
+ ret=$?
+fi
+if [ $ret -gt 10 ]; then
+ echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <"
+ ret=9
+fi
+if [ -f stdout0 ]; then
+ cat stdout0
+fi
+exit $ret
diff --git a/doc/problemexamples/formiga/tests/c b/doc/problemexamples/formiga/tests/c
new file mode 100755
index 0000000..de0a9c5
--- /dev/null
+++ b/doc/problemexamples/formiga/tests/c
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# This file performs a test of the autojudge system. It can run whatever you feel important to test the autojudge
+# and the script files that are included in the problem package
+
+cat > test.c <
+int main() {
+ char s[100];
+ scanf("%s", s);
+ printf("%s\n",s);
+ return 0;
+}
+EOF
+cat > test.in <> keys.txt
+ fi
+ done
+fi
diff --git a/doc/problemexamples/multas.zip b/doc/problemexamples/multas.zip
new file mode 100644
index 0000000..8bc6f1d
Binary files /dev/null and b/doc/problemexamples/multas.zip differ
diff --git a/doc/problemexamples/multas/compare/c b/doc/problemexamples/multas/compare/c
new file mode 100755
index 0000000..4998be3
--- /dev/null
+++ b/doc/problemexamples/multas/compare/c
@@ -0,0 +1,97 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+# // Last modified 21/jul/2012 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 problem_input (might be used by some specific checkers, here it is not)
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/doc/problemexamples/multas/compare/cpp b/doc/problemexamples/multas/compare/cpp
new file mode 100755
index 0000000..4998be3
--- /dev/null
+++ b/doc/problemexamples/multas/compare/cpp
@@ -0,0 +1,97 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+# // Last modified 21/jul/2012 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 problem_input (might be used by some specific checkers, here it is not)
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/doc/problemexamples/multas/compare/java b/doc/problemexamples/multas/compare/java
new file mode 100755
index 0000000..4998be3
--- /dev/null
+++ b/doc/problemexamples/multas/compare/java
@@ -0,0 +1,97 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+# // Last modified 21/jul/2012 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 problem_input (might be used by some specific checkers, here it is not)
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/doc/problemexamples/multas/compile/c b/doc/problemexamples/multas/compile/c
new file mode 100644
index 0000000..5376708
--- /dev/null
+++ b/doc/problemexamples/multas/compile/c
@@ -0,0 +1,172 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 21/july/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.exe)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes, default 512M)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ name="*.c"
+else
+ cp "$name" src
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+maxm=512000
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ maxm=${4}000
+ fi
+fi
+
+# setting up the timelimit according to the problem
+if [ "$3" == "" ]; then
+time=5
+else
+time=$3
+fi
+let "ttime = $time + 30"
+
+if [ "$2" == "" ]; then
+ exe=run.exe
+else
+ exe=$2
+fi
+
+rm -f $exe compileit.retcode runit.retcode 2>/dev/null
+cat < compileit.sh
+#!/bin/bash
+cc=\`which gcc\`
+[ -x "\$cc" ] || cc=/usr/bin/gcc
+if [ ! -x "\$cc" ]; then
+ echo "\$cc not found or it's not executable"
+ exit 47
+fi
+cd src
+"\$cc" -static -O2 -o ../$exe $name -lm
+echo \$? > ../compileit.retcode
+exit 0
+EOF
+chmod 755 compileit.sh
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ echo "Internal directory is $cdir"
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+ $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/multas/compile/cpp b/doc/problemexamples/multas/compile/cpp
new file mode 100644
index 0000000..6a61bc1
--- /dev/null
+++ b/doc/problemexamples/multas/compile/cpp
@@ -0,0 +1,172 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 21/july/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.exe)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ name="*.c"
+else
+ cp "$name" src
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+maxm=512000
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ maxm=${4}000
+ fi
+fi
+
+# setting up the timelimit according to the problem
+if [ "$3" == "" ]; then
+time=5
+else
+time=$3
+fi
+let "ttime = $time + 30"
+
+if [ "$2" == "" ]; then
+ exe=run.exe
+else
+ exe=$2
+fi
+
+rm -f $exe compileit.retcode runit.retcode 2>/dev/null
+cat < compileit.sh
+#!/bin/bash
+cc=\`which g++\`
+[ -x "\$cc" ] || cc=/usr/bin/g++
+if [ ! -x "\$cc" ]; then
+ echo "\$cc not found or it's not executable"
+ exit 47
+fi
+cd src
+"\$cc" -static -O2 -o ../$exe $name -lm
+echo \$? > ../compileit.retcode
+exit 0
+EOF
+chmod 755 compileit.sh
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ echo "Internal directory is $cdir"
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+ $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/multas/compile/java b/doc/problemexamples/multas/compile/java
new file mode 100644
index 0000000..f62215b
--- /dev/null
+++ b/doc/problemexamples/multas/compile/java
@@ -0,0 +1,189 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 21/july/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.jar)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ if [ "${name##*.}" == "zip" ]; then
+ name=`basename $name .zip`
+ else
+ name=`basename $name .ZIP`
+ fi
+else
+ cp $name src
+fi
+chown -R $bocau src
+chmod -R 700 src
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$4
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+maxm=512
+if [ "$4" != "" -a "$4" -gt "0" ]; then
+maxm=$4
+fi
+
+if [ "$2" == "" ]; then
+ jarfile=run.jar
+else
+ jarfile=$2
+fi
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+
+cat < compileit.sh
+#!/bin/bash
+javac=`which javac`
+[ -x "\$javac" ] || javac=/usr/bin/javac
+if [ ! -x \$javac ]; then
+ echo "\$javac not found or it's not executable"
+ exit 47
+fi
+jar=`which jar`
+[ -x "\$jar" ] || jar=/usr/bin/jar
+if [ ! -x \$jar ]; then
+ echo "\$jar not found or it's not executable"
+ exit 47
+fi
+export CLASSPATH=.:\$CLASSPATH
+cd src
+if [ -r "$name" ]; then
+ \$javac "$name"
+ echo \$? > ../compileit.retcode
+fi
+find . -name "*.java" | while read lin; do
+ \$javac "\$lin"
+ echo \$? > ../compileit.retcode
+done
+rm -f ../$jarfile
+\$jar cvf ../$jarfile *
+exit 0
+EOF
+chmod 755 compileit.sh
+
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+
+$sf -r1 -t$time -T$ttime -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+# $javac "$name"
+ $sf -r1 -t$time -T$ttime -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/multas/compile/pas b/doc/problemexamples/multas/compile/pas
new file mode 100644
index 0000000..e0b73ca
--- /dev/null
+++ b/doc/problemexamples/multas/compile/pas
@@ -0,0 +1,172 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 28/aug/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.exe)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes, default 512M)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ name="*.c"
+else
+ cp "$name" src
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+maxm=512000
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ maxm=${4}000
+ fi
+fi
+
+# setting up the timelimit according to the problem
+if [ "$3" == "" ]; then
+time=5
+else
+time=$3
+fi
+let "ttime = $time + 30"
+
+if [ "$2" == "" ]; then
+ exe=run.exe
+else
+ exe=$2
+fi
+
+rm -f $exe compileit.retcode runit.retcode 2>/dev/null
+cat < compileit.sh
+#!/bin/bash
+cc=\`which fpc\`
+[ -x "\$cc" ] || cc=/usr/bin/fpc
+if [ ! -x "\$cc" ]; then
+ echo "\$cc not found or it's not executable"
+ exit 47
+fi
+cd src
+"\$cc" -Xt -XS -O2 -o../$exe $name
+echo \$? > ../compileit.retcode
+exit 0
+EOF
+chmod 755 compileit.sh
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ echo "Internal directory is $cdir"
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+ $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/multas/description/m.txt b/doc/problemexamples/multas/description/m.txt
new file mode 100644
index 0000000..4cd89f0
--- /dev/null
+++ b/doc/problemexamples/multas/description/m.txt
@@ -0,0 +1 @@
+THIS IS THE FILE DESCRIBING THE PROBLEM! IT CAN BE A PDF OR ANY OTHER FORMAT...
diff --git a/doc/problemexamples/multas/description/problem.info b/doc/problemexamples/multas/description/problem.info
new file mode 100644
index 0000000..45944fc
--- /dev/null
+++ b/doc/problemexamples/multas/description/problem.info
@@ -0,0 +1,3 @@
+basename=multas
+fullname=The Poblem of multas
+descfile=m.txt
diff --git a/doc/problemexamples/multas/input/file b/doc/problemexamples/multas/input/file
new file mode 100644
index 0000000..bb947cd
--- /dev/null
+++ b/doc/problemexamples/multas/input/file
@@ -0,0 +1,518 @@
+5
+john
+mary
+bob
+rick
+donna
+4
+4
+5
+7
+7
+7
+-2
+3
+paul
+irene
+charlie
+5
+5
+5
+5
+5
+4
+7
+7
+4
+4
+4
+4
+-3
+19
+Zzzzzzzzzzzzzzzzzzzs
+zzzzzzzzzzzzzzzzzzzr
+zzzzzzzzzzzzzzzzzzzq
+zzzzzzzzzzzzzzzzzzzpzzzzzzzzzzzzzzzzzzzpzzzzzzzzzzzzzzzzzzzpzzzzzzzzzzzzzzzzzzzp
+zzzzzzzzzzzzzzzzzzzo
+zzzzzzzzzzzzzzzzzzzn
+zzzzzzzzzzzzzzzzzzzm
+zzzzzzzzzzzzzzzzzzzl
+zzzzzzzzzzzzzzzzzzzk
+zzzzzzzzzzzzzzzzzzzj
+zzzzzzzzzzzzzzzzzzzi
+zzzzzzzzzzzzzzzzzzzh
+zzzzzzzzzzzzzzzzzzzg
+zzzzzzzzzzzzzzzzzzzf
+zzzzzzzzzzzzzzzzzzze
+zzzzzzzzzzzzzzzzzzzd
+zzzzzzzzzzzzzzzzzzzc
+zzzzzzzzzzzzzzzzzzzb
+Zzzzzzzzzzzzzzzzzzza
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+-50
+19
+Zzzzzzzzzzzzzzzzzzzs
+zzzzzzzzzzzzzzzzzzzr
+zzzzzzzzzzzzzzzzzzzq
+zzzzzzzzzzzzzzzzzzzp
+zzzzzzzzzzzzzzzzzzzo
+zzzzzzzzzzzzzzzzzzzn
+zzzzzzzzzzzzzzzzzzzm
+zzzzzzzzzzzzzzzzzzzl
+zzzzzzzzzzzzzzzzzzzk
+zzzzzzzzzzzzzzzzzzzj
+zzzzzzzzzzzzzzzzzzzi
+zzzzzzzzzzzzzzzzzzzh
+zzzzzzzzzzzzzzzzzzzg
+zzzzzzzzzzzzzzzzzzzf
+zzzzzzzzzzzzzzzzzzze
+zzzzzzzzzzzzzzzzzzzd
+zzzzzzzzzzzzzzzzzzzc
+zzzzzzzzzzzzzzzzzzzb
+Zzzzzzzzzzzzzzzzzzza
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+-50
+5
+a
+b
+c
+d
+e
+5
+4
+3
+2
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+-3
+0
diff --git a/doc/problemexamples/multas/limits/c b/doc/problemexamples/multas/limits/c
new file mode 100644
index 0000000..b5aec73
--- /dev/null
+++ b/doc/problemexamples/multas/limits/c
@@ -0,0 +1,15 @@
+#!/bin/bash
+# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename
+echo 4
+# and the number of repetitions to run within the given timelimit in the second line
+echo 10
+# and the maximum amount of memory per repetition in the third line (in Mbytes)
+echo 512
+# and the maximum file size in the fourth line (in kbytes)
+echo 1024
+# and shall return zero to indicate no failure
+exit 0
+# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be
+# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is
+# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs
+# the value.
diff --git a/doc/problemexamples/multas/limits/cpp b/doc/problemexamples/multas/limits/cpp
new file mode 100644
index 0000000..b5aec73
--- /dev/null
+++ b/doc/problemexamples/multas/limits/cpp
@@ -0,0 +1,15 @@
+#!/bin/bash
+# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename
+echo 4
+# and the number of repetitions to run within the given timelimit in the second line
+echo 10
+# and the maximum amount of memory per repetition in the third line (in Mbytes)
+echo 512
+# and the maximum file size in the fourth line (in kbytes)
+echo 1024
+# and shall return zero to indicate no failure
+exit 0
+# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be
+# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is
+# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs
+# the value.
diff --git a/doc/problemexamples/multas/limits/java b/doc/problemexamples/multas/limits/java
new file mode 100644
index 0000000..b5aec73
--- /dev/null
+++ b/doc/problemexamples/multas/limits/java
@@ -0,0 +1,15 @@
+#!/bin/bash
+# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename
+echo 4
+# and the number of repetitions to run within the given timelimit in the second line
+echo 10
+# and the maximum amount of memory per repetition in the third line (in Mbytes)
+echo 512
+# and the maximum file size in the fourth line (in kbytes)
+echo 1024
+# and shall return zero to indicate no failure
+exit 0
+# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be
+# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is
+# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs
+# the value.
diff --git a/doc/problemexamples/multas/output/file b/doc/problemexamples/multas/output/file
new file mode 100644
index 0000000..5855c90
--- /dev/null
+++ b/doc/problemexamples/multas/output/file
@@ -0,0 +1,466 @@
+Familia 1
+Multa 1 bob
+Multa 2 donna
+Multa 3 john
+Multa 4 mary
+Multa 5 rick
+Multa 6 bob
+
+Familia 2
+Multa 1 charlie
+Multa 2 irene
+Multa 3 paul
+Multa 4 charlie
+Multa 5 irene
+Multa 6 paul
+Multa 7 paul
+Multa 8 charlie
+Multa 9 irene
+Multa 10 irene
+Multa 11 paul
+Multa 12 charlie carteira suspensa
+
+Familia 3
+Multa 1 Zzzzzzzzzzzzzzzzzzza carteira suspensa
+Multa 2 zzzzzzzzzzzzzzzzzzzb carteira suspensa
+Multa 3 zzzzzzzzzzzzzzzzzzzc carteira suspensa
+Multa 4 zzzzzzzzzzzzzzzzzzzd carteira suspensa
+Multa 5 zzzzzzzzzzzzzzzzzzze carteira suspensa
+Multa 6 zzzzzzzzzzzzzzzzzzzf carteira suspensa
+Multa 7 zzzzzzzzzzzzzzzzzzzg carteira suspensa
+Multa 8 zzzzzzzzzzzzzzzzzzzh carteira suspensa
+Multa 9 zzzzzzzzzzzzzzzzzzzi carteira suspensa
+Multa 10 zzzzzzzzzzzzzzzzzzzj carteira suspensa
+Multa 11 zzzzzzzzzzzzzzzzzzzk carteira suspensa
+Multa 12 zzzzzzzzzzzzzzzzzzzl carteira suspensa
+Multa 13 zzzzzzzzzzzzzzzzzzzm carteira suspensa
+Multa 14 zzzzzzzzzzzzzzzzzzzn carteira suspensa
+Multa 15 zzzzzzzzzzzzzzzzzzzo carteira suspensa
+Multa 16 zzzzzzzzzzzzzzzzzzzpzzzzzzzzzzzzzzzzzzzpzzzzzzzzzzzzzzzzzzzpzzzzzzzzzzzzzzzzzzzp carteira suspensa
+Multa 17 zzzzzzzzzzzzzzzzzzzq carteira suspensa
+Multa 18 zzzzzzzzzzzzzzzzzzzr carteira suspensa
+Multa 19 Zzzzzzzzzzzzzzzzzzzs carteira suspensa
+
+Familia 4
+Multa 1 Zzzzzzzzzzzzzzzzzzza
+Multa 2 zzzzzzzzzzzzzzzzzzzb
+Multa 3 zzzzzzzzzzzzzzzzzzzc
+Multa 4 zzzzzzzzzzzzzzzzzzzd
+Multa 5 zzzzzzzzzzzzzzzzzzze
+Multa 6 zzzzzzzzzzzzzzzzzzzf
+Multa 7 zzzzzzzzzzzzzzzzzzzg
+Multa 8 zzzzzzzzzzzzzzzzzzzh
+Multa 9 zzzzzzzzzzzzzzzzzzzi
+Multa 10 zzzzzzzzzzzzzzzzzzzj
+Multa 11 zzzzzzzzzzzzzzzzzzzk
+Multa 12 zzzzzzzzzzzzzzzzzzzl
+Multa 13 zzzzzzzzzzzzzzzzzzzm
+Multa 14 zzzzzzzzzzzzzzzzzzzn
+Multa 15 zzzzzzzzzzzzzzzzzzzo
+Multa 16 zzzzzzzzzzzzzzzzzzzp
+Multa 17 zzzzzzzzzzzzzzzzzzzq
+Multa 18 zzzzzzzzzzzzzzzzzzzr
+Multa 19 Zzzzzzzzzzzzzzzzzzzs
+Multa 20 Zzzzzzzzzzzzzzzzzzza
+Multa 21 zzzzzzzzzzzzzzzzzzzb
+Multa 22 zzzzzzzzzzzzzzzzzzzc
+Multa 23 zzzzzzzzzzzzzzzzzzzd
+Multa 24 zzzzzzzzzzzzzzzzzzze
+Multa 25 zzzzzzzzzzzzzzzzzzzf
+Multa 26 zzzzzzzzzzzzzzzzzzzg
+Multa 27 zzzzzzzzzzzzzzzzzzzh
+Multa 28 zzzzzzzzzzzzzzzzzzzi
+Multa 29 zzzzzzzzzzzzzzzzzzzj
+Multa 30 zzzzzzzzzzzzzzzzzzzk
+Multa 31 zzzzzzzzzzzzzzzzzzzl
+Multa 32 zzzzzzzzzzzzzzzzzzzm
+Multa 33 zzzzzzzzzzzzzzzzzzzn
+Multa 34 zzzzzzzzzzzzzzzzzzzo
+Multa 35 zzzzzzzzzzzzzzzzzzzp
+Multa 36 zzzzzzzzzzzzzzzzzzzq
+Multa 37 zzzzzzzzzzzzzzzzzzzr
+Multa 38 Zzzzzzzzzzzzzzzzzzzs
+Multa 39 Zzzzzzzzzzzzzzzzzzza
+Multa 40 zzzzzzzzzzzzzzzzzzzb
+Multa 41 zzzzzzzzzzzzzzzzzzzc
+Multa 42 zzzzzzzzzzzzzzzzzzzd
+Multa 43 zzzzzzzzzzzzzzzzzzze
+Multa 44 zzzzzzzzzzzzzzzzzzzf
+Multa 45 zzzzzzzzzzzzzzzzzzzg
+Multa 46 zzzzzzzzzzzzzzzzzzzh
+Multa 47 zzzzzzzzzzzzzzzzzzzi
+Multa 48 zzzzzzzzzzzzzzzzzzzj
+Multa 49 zzzzzzzzzzzzzzzzzzzk
+Multa 50 zzzzzzzzzzzzzzzzzzzl
+Multa 51 zzzzzzzzzzzzzzzzzzzm
+Multa 52 zzzzzzzzzzzzzzzzzzzn
+Multa 53 zzzzzzzzzzzzzzzzzzzo
+Multa 54 zzzzzzzzzzzzzzzzzzzp
+Multa 55 zzzzzzzzzzzzzzzzzzzq
+Multa 56 zzzzzzzzzzzzzzzzzzzr
+Multa 57 Zzzzzzzzzzzzzzzzzzzs
+Multa 58 Zzzzzzzzzzzzzzzzzzza
+Multa 59 zzzzzzzzzzzzzzzzzzzb
+Multa 60 zzzzzzzzzzzzzzzzzzzc
+Multa 61 zzzzzzzzzzzzzzzzzzzd
+Multa 62 zzzzzzzzzzzzzzzzzzze
+Multa 63 zzzzzzzzzzzzzzzzzzzf
+Multa 64 zzzzzzzzzzzzzzzzzzzg
+Multa 65 zzzzzzzzzzzzzzzzzzzh
+Multa 66 zzzzzzzzzzzzzzzzzzzi
+Multa 67 zzzzzzzzzzzzzzzzzzzj
+Multa 68 zzzzzzzzzzzzzzzzzzzk
+Multa 69 zzzzzzzzzzzzzzzzzzzl
+Multa 70 zzzzzzzzzzzzzzzzzzzm
+Multa 71 zzzzzzzzzzzzzzzzzzzn
+Multa 72 zzzzzzzzzzzzzzzzzzzo
+Multa 73 zzzzzzzzzzzzzzzzzzzp
+Multa 74 zzzzzzzzzzzzzzzzzzzq
+Multa 75 zzzzzzzzzzzzzzzzzzzr
+Multa 76 Zzzzzzzzzzzzzzzzzzzs
+Multa 77 Zzzzzzzzzzzzzzzzzzza
+Multa 78 zzzzzzzzzzzzzzzzzzzb
+Multa 79 zzzzzzzzzzzzzzzzzzzc
+Multa 80 zzzzzzzzzzzzzzzzzzzd
+Multa 81 zzzzzzzzzzzzzzzzzzze
+Multa 82 zzzzzzzzzzzzzzzzzzzf
+Multa 83 zzzzzzzzzzzzzzzzzzzg
+Multa 84 zzzzzzzzzzzzzzzzzzzh
+Multa 85 zzzzzzzzzzzzzzzzzzzi
+Multa 86 zzzzzzzzzzzzzzzzzzzj
+Multa 87 zzzzzzzzzzzzzzzzzzzk
+Multa 88 zzzzzzzzzzzzzzzzzzzl
+Multa 89 zzzzzzzzzzzzzzzzzzzm
+Multa 90 zzzzzzzzzzzzzzzzzzzn
+Multa 91 zzzzzzzzzzzzzzzzzzzo
+Multa 92 zzzzzzzzzzzzzzzzzzzp
+Multa 93 zzzzzzzzzzzzzzzzzzzq
+Multa 94 zzzzzzzzzzzzzzzzzzzr
+Multa 95 Zzzzzzzzzzzzzzzzzzzs
+Multa 96 Zzzzzzzzzzzzzzzzzzza
+Multa 97 zzzzzzzzzzzzzzzzzzzb
+Multa 98 zzzzzzzzzzzzzzzzzzzc
+Multa 99 zzzzzzzzzzzzzzzzzzzd
+Multa 100 zzzzzzzzzzzzzzzzzzze
+Multa 101 zzzzzzzzzzzzzzzzzzzf
+Multa 102 zzzzzzzzzzzzzzzzzzzg
+Multa 103 zzzzzzzzzzzzzzzzzzzh
+Multa 104 zzzzzzzzzzzzzzzzzzzi
+Multa 105 zzzzzzzzzzzzzzzzzzzj
+Multa 106 zzzzzzzzzzzzzzzzzzzk
+Multa 107 zzzzzzzzzzzzzzzzzzzl
+Multa 108 zzzzzzzzzzzzzzzzzzzm
+Multa 109 zzzzzzzzzzzzzzzzzzzn
+Multa 110 zzzzzzzzzzzzzzzzzzzo
+Multa 111 zzzzzzzzzzzzzzzzzzzp
+Multa 112 zzzzzzzzzzzzzzzzzzzq
+Multa 113 zzzzzzzzzzzzzzzzzzzr
+Multa 114 Zzzzzzzzzzzzzzzzzzzs
+Multa 115 Zzzzzzzzzzzzzzzzzzza
+Multa 116 zzzzzzzzzzzzzzzzzzzb
+Multa 117 zzzzzzzzzzzzzzzzzzzc
+Multa 118 zzzzzzzzzzzzzzzzzzzd
+Multa 119 zzzzzzzzzzzzzzzzzzze
+Multa 120 zzzzzzzzzzzzzzzzzzzf
+Multa 121 zzzzzzzzzzzzzzzzzzzg
+Multa 122 zzzzzzzzzzzzzzzzzzzh
+Multa 123 zzzzzzzzzzzzzzzzzzzi
+Multa 124 zzzzzzzzzzzzzzzzzzzj
+Multa 125 zzzzzzzzzzzzzzzzzzzk
+Multa 126 zzzzzzzzzzzzzzzzzzzl
+Multa 127 zzzzzzzzzzzzzzzzzzzm
+Multa 128 zzzzzzzzzzzzzzzzzzzn
+Multa 129 zzzzzzzzzzzzzzzzzzzo
+Multa 130 zzzzzzzzzzzzzzzzzzzp
+Multa 131 zzzzzzzzzzzzzzzzzzzq
+Multa 132 zzzzzzzzzzzzzzzzzzzr
+Multa 133 Zzzzzzzzzzzzzzzzzzzs
+Multa 134 Zzzzzzzzzzzzzzzzzzza
+Multa 135 zzzzzzzzzzzzzzzzzzzb
+Multa 136 zzzzzzzzzzzzzzzzzzzc
+Multa 137 zzzzzzzzzzzzzzzzzzzd
+Multa 138 zzzzzzzzzzzzzzzzzzze
+Multa 139 zzzzzzzzzzzzzzzzzzzf
+Multa 140 zzzzzzzzzzzzzzzzzzzg
+Multa 141 zzzzzzzzzzzzzzzzzzzh
+Multa 142 zzzzzzzzzzzzzzzzzzzi
+Multa 143 zzzzzzzzzzzzzzzzzzzj
+Multa 144 zzzzzzzzzzzzzzzzzzzk
+Multa 145 zzzzzzzzzzzzzzzzzzzl
+Multa 146 zzzzzzzzzzzzzzzzzzzm
+Multa 147 zzzzzzzzzzzzzzzzzzzn
+Multa 148 zzzzzzzzzzzzzzzzzzzo
+Multa 149 zzzzzzzzzzzzzzzzzzzp
+Multa 150 zzzzzzzzzzzzzzzzzzzq
+Multa 151 zzzzzzzzzzzzzzzzzzzr
+Multa 152 Zzzzzzzzzzzzzzzzzzzs
+Multa 153 Zzzzzzzzzzzzzzzzzzza
+Multa 154 zzzzzzzzzzzzzzzzzzzb
+Multa 155 zzzzzzzzzzzzzzzzzzzc
+Multa 156 zzzzzzzzzzzzzzzzzzzd
+Multa 157 zzzzzzzzzzzzzzzzzzze
+Multa 158 zzzzzzzzzzzzzzzzzzzf
+Multa 159 zzzzzzzzzzzzzzzzzzzg
+Multa 160 zzzzzzzzzzzzzzzzzzzh
+Multa 161 zzzzzzzzzzzzzzzzzzzi
+Multa 162 zzzzzzzzzzzzzzzzzzzj
+Multa 163 zzzzzzzzzzzzzzzzzzzk
+Multa 164 zzzzzzzzzzzzzzzzzzzl
+Multa 165 zzzzzzzzzzzzzzzzzzzm
+Multa 166 zzzzzzzzzzzzzzzzzzzn
+Multa 167 zzzzzzzzzzzzzzzzzzzo
+Multa 168 zzzzzzzzzzzzzzzzzzzp
+Multa 169 zzzzzzzzzzzzzzzzzzzq
+Multa 170 zzzzzzzzzzzzzzzzzzzr
+Multa 171 Zzzzzzzzzzzzzzzzzzzs
+Multa 172 Zzzzzzzzzzzzzzzzzzza
+Multa 173 zzzzzzzzzzzzzzzzzzzb
+Multa 174 zzzzzzzzzzzzzzzzzzzc
+Multa 175 zzzzzzzzzzzzzzzzzzzd
+Multa 176 zzzzzzzzzzzzzzzzzzze
+Multa 177 zzzzzzzzzzzzzzzzzzzf
+Multa 178 zzzzzzzzzzzzzzzzzzzg
+Multa 179 zzzzzzzzzzzzzzzzzzzh
+Multa 180 zzzzzzzzzzzzzzzzzzzi
+Multa 181 zzzzzzzzzzzzzzzzzzzj
+Multa 182 zzzzzzzzzzzzzzzzzzzk
+Multa 183 zzzzzzzzzzzzzzzzzzzl
+Multa 184 zzzzzzzzzzzzzzzzzzzm
+Multa 185 zzzzzzzzzzzzzzzzzzzn
+Multa 186 zzzzzzzzzzzzzzzzzzzo
+Multa 187 zzzzzzzzzzzzzzzzzzzp
+Multa 188 zzzzzzzzzzzzzzzzzzzq
+Multa 189 zzzzzzzzzzzzzzzzzzzr
+Multa 190 Zzzzzzzzzzzzzzzzzzzs
+Multa 191 Zzzzzzzzzzzzzzzzzzza
+Multa 192 zzzzzzzzzzzzzzzzzzzb
+Multa 193 zzzzzzzzzzzzzzzzzzzc
+Multa 194 zzzzzzzzzzzzzzzzzzzd
+Multa 195 zzzzzzzzzzzzzzzzzzze
+Multa 196 zzzzzzzzzzzzzzzzzzzf
+Multa 197 zzzzzzzzzzzzzzzzzzzg
+Multa 198 zzzzzzzzzzzzzzzzzzzh
+Multa 199 zzzzzzzzzzzzzzzzzzzi
+Multa 200 zzzzzzzzzzzzzzzzzzzj
+Multa 201 zzzzzzzzzzzzzzzzzzzk
+Multa 202 zzzzzzzzzzzzzzzzzzzl
+Multa 203 zzzzzzzzzzzzzzzzzzzm
+Multa 204 zzzzzzzzzzzzzzzzzzzn
+Multa 205 zzzzzzzzzzzzzzzzzzzo
+Multa 206 zzzzzzzzzzzzzzzzzzzp
+Multa 207 zzzzzzzzzzzzzzzzzzzq
+Multa 208 zzzzzzzzzzzzzzzzzzzr
+Multa 209 Zzzzzzzzzzzzzzzzzzzs
+Multa 210 Zzzzzzzzzzzzzzzzzzza
+Multa 211 zzzzzzzzzzzzzzzzzzzb
+Multa 212 zzzzzzzzzzzzzzzzzzzc
+Multa 213 zzzzzzzzzzzzzzzzzzzd
+Multa 214 zzzzzzzzzzzzzzzzzzze
+Multa 215 zzzzzzzzzzzzzzzzzzzf
+Multa 216 zzzzzzzzzzzzzzzzzzzg
+Multa 217 zzzzzzzzzzzzzzzzzzzh
+Multa 218 zzzzzzzzzzzzzzzzzzzi
+Multa 219 zzzzzzzzzzzzzzzzzzzj
+Multa 220 zzzzzzzzzzzzzzzzzzzk
+Multa 221 zzzzzzzzzzzzzzzzzzzl
+Multa 222 zzzzzzzzzzzzzzzzzzzm
+Multa 223 zzzzzzzzzzzzzzzzzzzn
+Multa 224 zzzzzzzzzzzzzzzzzzzo
+Multa 225 zzzzzzzzzzzzzzzzzzzp
+Multa 226 zzzzzzzzzzzzzzzzzzzq
+Multa 227 zzzzzzzzzzzzzzzzzzzr
+Multa 228 Zzzzzzzzzzzzzzzzzzzs
+Multa 229 Zzzzzzzzzzzzzzzzzzza
+Multa 230 zzzzzzzzzzzzzzzzzzzb
+Multa 231 zzzzzzzzzzzzzzzzzzzc
+Multa 232 zzzzzzzzzzzzzzzzzzzd
+Multa 233 zzzzzzzzzzzzzzzzzzze
+Multa 234 zzzzzzzzzzzzzzzzzzzf
+Multa 235 zzzzzzzzzzzzzzzzzzzg
+Multa 236 zzzzzzzzzzzzzzzzzzzh
+Multa 237 zzzzzzzzzzzzzzzzzzzi
+Multa 238 zzzzzzzzzzzzzzzzzzzj
+Multa 239 zzzzzzzzzzzzzzzzzzzk
+Multa 240 zzzzzzzzzzzzzzzzzzzl
+Multa 241 zzzzzzzzzzzzzzzzzzzm
+Multa 242 zzzzzzzzzzzzzzzzzzzn
+Multa 243 zzzzzzzzzzzzzzzzzzzo
+Multa 244 zzzzzzzzzzzzzzzzzzzp
+Multa 245 zzzzzzzzzzzzzzzzzzzq
+Multa 246 zzzzzzzzzzzzzzzzzzzr
+Multa 247 Zzzzzzzzzzzzzzzzzzzs
+Multa 248 Zzzzzzzzzzzzzzzzzzza
+Multa 249 zzzzzzzzzzzzzzzzzzzb
+Multa 250 zzzzzzzzzzzzzzzzzzzc
+Multa 251 zzzzzzzzzzzzzzzzzzzd
+Multa 252 zzzzzzzzzzzzzzzzzzze
+Multa 253 zzzzzzzzzzzzzzzzzzzf
+Multa 254 zzzzzzzzzzzzzzzzzzzg
+Multa 255 zzzzzzzzzzzzzzzzzzzh
+Multa 256 zzzzzzzzzzzzzzzzzzzi
+Multa 257 zzzzzzzzzzzzzzzzzzzj
+Multa 258 zzzzzzzzzzzzzzzzzzzk
+Multa 259 zzzzzzzzzzzzzzzzzzzl
+Multa 260 zzzzzzzzzzzzzzzzzzzm
+Multa 261 zzzzzzzzzzzzzzzzzzzn
+Multa 262 zzzzzzzzzzzzzzzzzzzo
+Multa 263 zzzzzzzzzzzzzzzzzzzp
+Multa 264 zzzzzzzzzzzzzzzzzzzq
+Multa 265 zzzzzzzzzzzzzzzzzzzr
+Multa 266 Zzzzzzzzzzzzzzzzzzzs
+Multa 267 Zzzzzzzzzzzzzzzzzzza
+Multa 268 zzzzzzzzzzzzzzzzzzzb
+Multa 269 zzzzzzzzzzzzzzzzzzzc
+Multa 270 zzzzzzzzzzzzzzzzzzzd
+Multa 271 zzzzzzzzzzzzzzzzzzze
+Multa 272 zzzzzzzzzzzzzzzzzzzf
+Multa 273 zzzzzzzzzzzzzzzzzzzg
+Multa 274 zzzzzzzzzzzzzzzzzzzh
+Multa 275 zzzzzzzzzzzzzzzzzzzi
+Multa 276 zzzzzzzzzzzzzzzzzzzj
+Multa 277 zzzzzzzzzzzzzzzzzzzk
+Multa 278 zzzzzzzzzzzzzzzzzzzl
+Multa 279 zzzzzzzzzzzzzzzzzzzm
+Multa 280 zzzzzzzzzzzzzzzzzzzn
+Multa 281 zzzzzzzzzzzzzzzzzzzo
+Multa 282 zzzzzzzzzzzzzzzzzzzp
+Multa 283 zzzzzzzzzzzzzzzzzzzq
+Multa 284 zzzzzzzzzzzzzzzzzzzr
+Multa 285 Zzzzzzzzzzzzzzzzzzzs
+Multa 286 Zzzzzzzzzzzzzzzzzzza
+Multa 287 zzzzzzzzzzzzzzzzzzzb
+Multa 288 zzzzzzzzzzzzzzzzzzzc
+Multa 289 zzzzzzzzzzzzzzzzzzzd
+Multa 290 zzzzzzzzzzzzzzzzzzze
+Multa 291 zzzzzzzzzzzzzzzzzzzf
+Multa 292 zzzzzzzzzzzzzzzzzzzg
+Multa 293 zzzzzzzzzzzzzzzzzzzh
+Multa 294 zzzzzzzzzzzzzzzzzzzi
+Multa 295 zzzzzzzzzzzzzzzzzzzj
+Multa 296 zzzzzzzzzzzzzzzzzzzk
+Multa 297 zzzzzzzzzzzzzzzzzzzl
+Multa 298 zzzzzzzzzzzzzzzzzzzm
+Multa 299 zzzzzzzzzzzzzzzzzzzn
+Multa 300 zzzzzzzzzzzzzzzzzzzo
+Multa 301 zzzzzzzzzzzzzzzzzzzp
+Multa 302 zzzzzzzzzzzzzzzzzzzq
+Multa 303 zzzzzzzzzzzzzzzzzzzr
+Multa 304 Zzzzzzzzzzzzzzzzzzzs
+Multa 305 Zzzzzzzzzzzzzzzzzzza
+Multa 306 zzzzzzzzzzzzzzzzzzzb
+Multa 307 zzzzzzzzzzzzzzzzzzzc
+Multa 308 zzzzzzzzzzzzzzzzzzzd
+Multa 309 zzzzzzzzzzzzzzzzzzze
+Multa 310 zzzzzzzzzzzzzzzzzzzf
+Multa 311 zzzzzzzzzzzzzzzzzzzg
+Multa 312 zzzzzzzzzzzzzzzzzzzh
+Multa 313 zzzzzzzzzzzzzzzzzzzi
+Multa 314 zzzzzzzzzzzzzzzzzzzj
+Multa 315 zzzzzzzzzzzzzzzzzzzk
+Multa 316 zzzzzzzzzzzzzzzzzzzl
+Multa 317 zzzzzzzzzzzzzzzzzzzm
+Multa 318 zzzzzzzzzzzzzzzzzzzn
+Multa 319 zzzzzzzzzzzzzzzzzzzo
+Multa 320 zzzzzzzzzzzzzzzzzzzp
+Multa 321 zzzzzzzzzzzzzzzzzzzq
+Multa 322 zzzzzzzzzzzzzzzzzzzr
+Multa 323 Zzzzzzzzzzzzzzzzzzzs
+Multa 324 Zzzzzzzzzzzzzzzzzzza
+Multa 325 zzzzzzzzzzzzzzzzzzzb
+Multa 326 zzzzzzzzzzzzzzzzzzzc
+Multa 327 zzzzzzzzzzzzzzzzzzzd
+Multa 328 zzzzzzzzzzzzzzzzzzze
+Multa 329 zzzzzzzzzzzzzzzzzzzf
+Multa 330 zzzzzzzzzzzzzzzzzzzg
+Multa 331 zzzzzzzzzzzzzzzzzzzh
+Multa 332 zzzzzzzzzzzzzzzzzzzi
+Multa 333 zzzzzzzzzzzzzzzzzzzj
+Multa 334 zzzzzzzzzzzzzzzzzzzk
+Multa 335 zzzzzzzzzzzzzzzzzzzl
+Multa 336 zzzzzzzzzzzzzzzzzzzm
+Multa 337 zzzzzzzzzzzzzzzzzzzn
+Multa 338 zzzzzzzzzzzzzzzzzzzo
+Multa 339 zzzzzzzzzzzzzzzzzzzp
+Multa 340 zzzzzzzzzzzzzzzzzzzq
+Multa 341 zzzzzzzzzzzzzzzzzzzr
+Multa 342 Zzzzzzzzzzzzzzzzzzzs
+Multa 343 Zzzzzzzzzzzzzzzzzzza
+Multa 344 zzzzzzzzzzzzzzzzzzzb
+Multa 345 zzzzzzzzzzzzzzzzzzzc
+Multa 346 zzzzzzzzzzzzzzzzzzzd
+Multa 347 zzzzzzzzzzzzzzzzzzze
+Multa 348 zzzzzzzzzzzzzzzzzzzf
+Multa 349 zzzzzzzzzzzzzzzzzzzg
+Multa 350 zzzzzzzzzzzzzzzzzzzh
+Multa 351 zzzzzzzzzzzzzzzzzzzi
+Multa 352 zzzzzzzzzzzzzzzzzzzj
+Multa 353 zzzzzzzzzzzzzzzzzzzk
+Multa 354 zzzzzzzzzzzzzzzzzzzl
+Multa 355 zzzzzzzzzzzzzzzzzzzm
+Multa 356 zzzzzzzzzzzzzzzzzzzn
+Multa 357 zzzzzzzzzzzzzzzzzzzo
+Multa 358 zzzzzzzzzzzzzzzzzzzp
+Multa 359 zzzzzzzzzzzzzzzzzzzq
+Multa 360 zzzzzzzzzzzzzzzzzzzr
+Multa 361 Zzzzzzzzzzzzzzzzzzzs
+Multa 362 Zzzzzzzzzzzzzzzzzzza
+Multa 363 zzzzzzzzzzzzzzzzzzzb
+Multa 364 zzzzzzzzzzzzzzzzzzzc
+Multa 365 zzzzzzzzzzzzzzzzzzzd
+Multa 366 zzzzzzzzzzzzzzzzzzze
+Multa 367 zzzzzzzzzzzzzzzzzzzf
+Multa 368 zzzzzzzzzzzzzzzzzzzg
+Multa 369 zzzzzzzzzzzzzzzzzzzh
+Multa 370 zzzzzzzzzzzzzzzzzzzi
+Multa 371 zzzzzzzzzzzzzzzzzzzj
+Multa 372 zzzzzzzzzzzzzzzzzzzk
+Multa 373 zzzzzzzzzzzzzzzzzzzl
+Multa 374 zzzzzzzzzzzzzzzzzzzm
+Multa 375 zzzzzzzzzzzzzzzzzzzn
+Multa 376 zzzzzzzzzzzzzzzzzzzo
+Multa 377 zzzzzzzzzzzzzzzzzzzp
+Multa 378 zzzzzzzzzzzzzzzzzzzq
+Multa 379 zzzzzzzzzzzzzzzzzzzr
+Multa 380 Zzzzzzzzzzzzzzzzzzzs
+Multa 381 Zzzzzzzzzzzzzzzzzzza carteira suspensa
+Multa 382 zzzzzzzzzzzzzzzzzzzb carteira suspensa
+Multa 383 zzzzzzzzzzzzzzzzzzzc carteira suspensa
+Multa 384 zzzzzzzzzzzzzzzzzzzd carteira suspensa
+Multa 385 zzzzzzzzzzzzzzzzzzze carteira suspensa
+Multa 386 zzzzzzzzzzzzzzzzzzzf carteira suspensa
+Multa 387 zzzzzzzzzzzzzzzzzzzg carteira suspensa
+Multa 388 zzzzzzzzzzzzzzzzzzzh carteira suspensa
+Multa 389 zzzzzzzzzzzzzzzzzzzi carteira suspensa
+Multa 390 zzzzzzzzzzzzzzzzzzzj carteira suspensa
+Multa 391 zzzzzzzzzzzzzzzzzzzk carteira suspensa
+Multa 392 zzzzzzzzzzzzzzzzzzzl carteira suspensa
+Multa 393 zzzzzzzzzzzzzzzzzzzm carteira suspensa
+Multa 394 zzzzzzzzzzzzzzzzzzzn carteira suspensa
+Multa 395 zzzzzzzzzzzzzzzzzzzo carteira suspensa
+Multa 396 zzzzzzzzzzzzzzzzzzzp carteira suspensa
+Multa 397 zzzzzzzzzzzzzzzzzzzq carteira suspensa
+Multa 398 zzzzzzzzzzzzzzzzzzzr carteira suspensa
+Multa 399 Zzzzzzzzzzzzzzzzzzzs carteira suspensa
+
+Familia 5
+Multa 1 a
+Multa 2 b
+Multa 3 c
+Multa 4 d
+Multa 5 e
+Multa 6 e
+Multa 7 d
+Multa 8 e
+Multa 9 c
+Multa 10 d
+Multa 11 e
+Multa 12 b
+Multa 13 c
+Multa 14 d
+Multa 15 e
+Multa 16 a
+Multa 17 b
+Multa 18 c
+Multa 19 d
+Multa 20 e
+
diff --git a/doc/problemexamples/multas/run/c b/doc/problemexamples/multas/run/c
new file mode 100755
index 0000000..b46e5f9
--- /dev/null
+++ b/doc/problemexamples/multas/run/c
@@ -0,0 +1,128 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 22/aug/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 exe_file
+# $2 input_file
+# $3 timelimit (limit to run all the repetitions, by default only one repetition)
+# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit)
+# $5 maximum allowed memory (in MBytes)
+# $6 maximum allowed output size (in KBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -x "$1" ]; then
+ echo "$1 not found (or is not in the current dir) or it's not executable"
+ exit 44
+fi
+if [ ! -r "$2" ]; then
+ echo "$2 not found (or is not in the current dir) or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$3
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+nruns=1
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ nruns=$4
+ fi
+fi
+maxm=512000
+if [ "$5" != "" ]; then
+ if [ "$5" -gt "0" ]; then
+ maxm=${5}000
+ fi
+fi
+maxf=1024
+if [ "$6" != "" ]; then
+ if [ "$6" -gt "0" ]; then
+ maxf=${6}
+ fi
+fi
+
+cp "$2" stdin0 2>/dev/null
+cp "$1" run.exe 2>/dev/null
+
+file run.exe | grep -iq "statically linked"
+if [ "$?" != "0" ]; then
+ echo "Aborting because $1 is not statically linked"
+ exit 47
+fi
+
+cdir=`pwd`
+echo "Current directory is $cdir -- chrooting on it" >&2
+$sf -F10 -f$maxf -r$nruns -n1 -R$cdir -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d$maxm -m$maxm -t$time -T$ttime -istdin0 ./run.exe
+ret=$?
+if [ $ret -gt 10 ]; then
+ ret=0
+fi
+if [ -f stdout0 ]; then
+ cat stdout0
+fi
+exit $ret
diff --git a/doc/problemexamples/multas/run/cpp b/doc/problemexamples/multas/run/cpp
new file mode 100755
index 0000000..b46e5f9
--- /dev/null
+++ b/doc/problemexamples/multas/run/cpp
@@ -0,0 +1,128 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 22/aug/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 exe_file
+# $2 input_file
+# $3 timelimit (limit to run all the repetitions, by default only one repetition)
+# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit)
+# $5 maximum allowed memory (in MBytes)
+# $6 maximum allowed output size (in KBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -x "$1" ]; then
+ echo "$1 not found (or is not in the current dir) or it's not executable"
+ exit 44
+fi
+if [ ! -r "$2" ]; then
+ echo "$2 not found (or is not in the current dir) or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$3
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+nruns=1
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ nruns=$4
+ fi
+fi
+maxm=512000
+if [ "$5" != "" ]; then
+ if [ "$5" -gt "0" ]; then
+ maxm=${5}000
+ fi
+fi
+maxf=1024
+if [ "$6" != "" ]; then
+ if [ "$6" -gt "0" ]; then
+ maxf=${6}
+ fi
+fi
+
+cp "$2" stdin0 2>/dev/null
+cp "$1" run.exe 2>/dev/null
+
+file run.exe | grep -iq "statically linked"
+if [ "$?" != "0" ]; then
+ echo "Aborting because $1 is not statically linked"
+ exit 47
+fi
+
+cdir=`pwd`
+echo "Current directory is $cdir -- chrooting on it" >&2
+$sf -F10 -f$maxf -r$nruns -n1 -R$cdir -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d$maxm -m$maxm -t$time -T$ttime -istdin0 ./run.exe
+ret=$?
+if [ $ret -gt 10 ]; then
+ ret=0
+fi
+if [ -f stdout0 ]; then
+ cat stdout0
+fi
+exit $ret
diff --git a/doc/problemexamples/multas/run/java b/doc/problemexamples/multas/run/java
new file mode 100755
index 0000000..d6a73a5
--- /dev/null
+++ b/doc/problemexamples/multas/run/java
@@ -0,0 +1,183 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 14/sept/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 main_class
+# $2 input_file
+# $3 timelimit (limit to run all the repetitions, by default only one repetition)
+# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit)
+# $5 maximum allowed memory (in MBytes)
+# $6 maximum allowed output size (in KBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ -r run.exe ]; then
+ mv run.exe run.jar
+fi
+if [ -r "$1" ]; then
+ mv "$1" run.jar
+fi
+if [ ! -r run.jar ]; then
+ echo "ERROR: file run.jar not found - possible error during compilation"
+ exit 1
+fi
+name="$1"
+if [ "${name##*.}" == "class" -a "${name##*.}" == "CLASS" ]; then
+ echo "WARNING: removing .class file extension"
+fi
+if [ "${name##*.}" == "class" ]; then
+ name=`basename "$1" .class`
+fi
+if [ "${name##*.}" == "CLASS" ]; then
+ name=`basename "$1" .CLASS`
+fi
+if [ ! -r "$2" ]; then
+ echo "$2 not found (or is not in the current dir) or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$3
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+nruns=1
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ nruns=$4
+ fi
+fi
+maxm=512000
+if [ "$5" != "" ]; then
+ if [ "$5" -gt "0" ]; then
+ maxm=${5}000
+ fi
+fi
+maxf=1024
+if [ "$6" != "" ]; then
+ if [ "$6" -gt "0" ]; then
+ maxf=${6}
+ fi
+fi
+
+rm -f runit.retcode 2>/dev/null
+cp "$2" stdin0 2>/dev/null
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+java=`which java`
+[ -x "\$java" ] || java=/usr/bin/java
+if [ ! -x \$java ]; then
+ echo "\$java not found or it's not executable"
+ exit 47
+fi
+export CLASSPATH=.:./run.jar:$CLASSPATH
+$sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 -- \$java -Xmx${maxm}K -Xms${maxm}K "$name"
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ fi
+ if [ "$ret" == "" ]; then
+ echo "Execution error - check autojudging"
+ exit 49
+ fi
+else
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ java=`which java`
+ [ -x "$java" ] || java=/usr/bin/java
+ if [ ! -x $java ]; then
+ echo "$java not found or it's not executable"
+ exit 47
+ fi
+ $sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 -- $java -cp run.jar -Xmx${maxm}K -Xms${maxm}K "$name"
+ ret=$?
+fi
+if [ $ret -gt 10 ]; then
+ echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <"
+ ret=9
+fi
+if [ -f stdout0 ]; then
+ cat stdout0
+fi
+exit $ret
diff --git a/doc/problemexamples/multas/tests/c b/doc/problemexamples/multas/tests/c
new file mode 100755
index 0000000..de0a9c5
--- /dev/null
+++ b/doc/problemexamples/multas/tests/c
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# This file performs a test of the autojudge system. It can run whatever you feel important to test the autojudge
+# and the script files that are included in the problem package
+
+cat > test.c <
+int main() {
+ char s[100];
+ scanf("%s", s);
+ printf("%s\n",s);
+ return 0;
+}
+EOF
+cat > test.in <.
+# ////////////////////////////////////////////////////////////////////////////////
+# // Last modified 21/jul/2012 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 problem_input (might be used by some specific checkers, here it is not)
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/doc/problemexamples/problemtemplate/compare/cpp b/doc/problemexamples/problemtemplate/compare/cpp
new file mode 100755
index 0000000..4998be3
--- /dev/null
+++ b/doc/problemexamples/problemtemplate/compare/cpp
@@ -0,0 +1,97 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+# // Last modified 21/jul/2012 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 problem_input (might be used by some specific checkers, here it is not)
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/doc/problemexamples/problemtemplate/compare/java b/doc/problemexamples/problemtemplate/compare/java
new file mode 100755
index 0000000..4998be3
--- /dev/null
+++ b/doc/problemexamples/problemtemplate/compare/java
@@ -0,0 +1,97 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+# // Last modified 21/jul/2012 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 problem_input (might be used by some specific checkers, here it is not)
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/doc/problemexamples/problemtemplate/compile/c b/doc/problemexamples/problemtemplate/compile/c
new file mode 100644
index 0000000..5376708
--- /dev/null
+++ b/doc/problemexamples/problemtemplate/compile/c
@@ -0,0 +1,172 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 21/july/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.exe)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes, default 512M)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ name="*.c"
+else
+ cp "$name" src
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+maxm=512000
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ maxm=${4}000
+ fi
+fi
+
+# setting up the timelimit according to the problem
+if [ "$3" == "" ]; then
+time=5
+else
+time=$3
+fi
+let "ttime = $time + 30"
+
+if [ "$2" == "" ]; then
+ exe=run.exe
+else
+ exe=$2
+fi
+
+rm -f $exe compileit.retcode runit.retcode 2>/dev/null
+cat < compileit.sh
+#!/bin/bash
+cc=\`which gcc\`
+[ -x "\$cc" ] || cc=/usr/bin/gcc
+if [ ! -x "\$cc" ]; then
+ echo "\$cc not found or it's not executable"
+ exit 47
+fi
+cd src
+"\$cc" -static -O2 -o ../$exe $name -lm
+echo \$? > ../compileit.retcode
+exit 0
+EOF
+chmod 755 compileit.sh
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ echo "Internal directory is $cdir"
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+ $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/problemtemplate/compile/cpp b/doc/problemexamples/problemtemplate/compile/cpp
new file mode 100644
index 0000000..6a61bc1
--- /dev/null
+++ b/doc/problemexamples/problemtemplate/compile/cpp
@@ -0,0 +1,172 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 21/july/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.exe)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ name="*.c"
+else
+ cp "$name" src
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+maxm=512000
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ maxm=${4}000
+ fi
+fi
+
+# setting up the timelimit according to the problem
+if [ "$3" == "" ]; then
+time=5
+else
+time=$3
+fi
+let "ttime = $time + 30"
+
+if [ "$2" == "" ]; then
+ exe=run.exe
+else
+ exe=$2
+fi
+
+rm -f $exe compileit.retcode runit.retcode 2>/dev/null
+cat < compileit.sh
+#!/bin/bash
+cc=\`which g++\`
+[ -x "\$cc" ] || cc=/usr/bin/g++
+if [ ! -x "\$cc" ]; then
+ echo "\$cc not found or it's not executable"
+ exit 47
+fi
+cd src
+"\$cc" -static -O2 -o ../$exe $name -lm
+echo \$? > ../compileit.retcode
+exit 0
+EOF
+chmod 755 compileit.sh
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ echo "Internal directory is $cdir"
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+ $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/problemtemplate/compile/java b/doc/problemexamples/problemtemplate/compile/java
new file mode 100644
index 0000000..f62215b
--- /dev/null
+++ b/doc/problemexamples/problemtemplate/compile/java
@@ -0,0 +1,189 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 21/july/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.jar)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ if [ "${name##*.}" == "zip" ]; then
+ name=`basename $name .zip`
+ else
+ name=`basename $name .ZIP`
+ fi
+else
+ cp $name src
+fi
+chown -R $bocau src
+chmod -R 700 src
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$4
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+maxm=512
+if [ "$4" != "" -a "$4" -gt "0" ]; then
+maxm=$4
+fi
+
+if [ "$2" == "" ]; then
+ jarfile=run.jar
+else
+ jarfile=$2
+fi
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+
+cat < compileit.sh
+#!/bin/bash
+javac=`which javac`
+[ -x "\$javac" ] || javac=/usr/bin/javac
+if [ ! -x \$javac ]; then
+ echo "\$javac not found or it's not executable"
+ exit 47
+fi
+jar=`which jar`
+[ -x "\$jar" ] || jar=/usr/bin/jar
+if [ ! -x \$jar ]; then
+ echo "\$jar not found or it's not executable"
+ exit 47
+fi
+export CLASSPATH=.:\$CLASSPATH
+cd src
+if [ -r "$name" ]; then
+ \$javac "$name"
+ echo \$? > ../compileit.retcode
+fi
+find . -name "*.java" | while read lin; do
+ \$javac "\$lin"
+ echo \$? > ../compileit.retcode
+done
+rm -f ../$jarfile
+\$jar cvf ../$jarfile *
+exit 0
+EOF
+chmod 755 compileit.sh
+
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+
+$sf -r1 -t$time -T$ttime -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+# $javac "$name"
+ $sf -r1 -t$time -T$ttime -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/problemtemplate/compile/pas b/doc/problemexamples/problemtemplate/compile/pas
new file mode 100644
index 0000000..e0b73ca
--- /dev/null
+++ b/doc/problemexamples/problemtemplate/compile/pas
@@ -0,0 +1,172 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 28/aug/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 source_file
+# $2 exe_file (default run.exe)
+# $3 timelimit (optional, limit to run all the repetitions, by default only one repetition)
+# $4 maximum allowed memory (in MBytes, default 512M)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+
+if [ "$1" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+name="$1"
+if [ ! -r "$1" ]; then
+ echo "$1 not found or it's not readable"
+ exit 44
+fi
+mkdir -p src
+if [ "${name##*.}" == "zip" -a "${name##*.}" == "ZIP" ]; then
+ unzip "$name" -d src
+ name="*.c"
+else
+ cp "$name" src
+fi
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+maxm=512000
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ maxm=${4}000
+ fi
+fi
+
+# setting up the timelimit according to the problem
+if [ "$3" == "" ]; then
+time=5
+else
+time=$3
+fi
+let "ttime = $time + 30"
+
+if [ "$2" == "" ]; then
+ exe=run.exe
+else
+ exe=$2
+fi
+
+rm -f $exe compileit.retcode runit.retcode 2>/dev/null
+cat < compileit.sh
+#!/bin/bash
+cc=\`which fpc\`
+[ -x "\$cc" ] || cc=/usr/bin/fpc
+if [ ! -x "\$cc" ]; then
+ echo "\$cc not found or it's not executable"
+ exit 47
+fi
+cd src
+"\$cc" -Xt -XS -O2 -o../$exe $name
+echo \$? > ../compileit.retcode
+exit 0
+EOF
+chmod 755 compileit.sh
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ echo "Internal directory is $cdir"
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+$sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ else
+ ret=99
+ fi
+else
+ echo "COMPILATION IS NOT BEING CHROOTED -- THIS IS NOT AN IDEAL SETTING"
+ $sf -r1 -F1000 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d$maxm -m$maxm -f20000 -t$ttime -T$ttime ./compileit.sh
+ ret=$?
+fi
+if [ -f "stdout0" ]; then
+ cat "stdout0"
+fi
+if [ -f "stderr0" ]; then
+ cat "stderr0"
+fi
+rm -rf src/
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit $ret
+fi
+ret=`cat compileit.retcode`
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ ret=1
+fi
+exit $ret
diff --git a/doc/problemexamples/problemtemplate/description/desc.txt b/doc/problemexamples/problemtemplate/description/desc.txt
new file mode 100644
index 0000000..4cd89f0
--- /dev/null
+++ b/doc/problemexamples/problemtemplate/description/desc.txt
@@ -0,0 +1 @@
+THIS IS THE FILE DESCRIBING THE PROBLEM! IT CAN BE A PDF OR ANY OTHER FORMAT...
diff --git a/doc/problemexamples/problemtemplate/description/problem.info b/doc/problemexamples/problemtemplate/description/problem.info
new file mode 100644
index 0000000..785e648
--- /dev/null
+++ b/doc/problemexamples/problemtemplate/description/problem.info
@@ -0,0 +1,3 @@
+basename=shortfilename
+fullname=This is the problem full name
+descfile=desc.txt
diff --git a/doc/problemexamples/problemtemplate/input/file1 b/doc/problemexamples/problemtemplate/input/file1
new file mode 100644
index 0000000..79ecf36
--- /dev/null
+++ b/doc/problemexamples/problemtemplate/input/file1
@@ -0,0 +1 @@
+FILE WITH THE INPUT TO BE GIVEN TO THE PROGRAM. NOTE THAT THE CORRESPONDING OUTPUT FILE HAS TO HAVE THE SAME NAME AS THIS FILE!
diff --git a/doc/problemexamples/problemtemplate/limits/c b/doc/problemexamples/problemtemplate/limits/c
new file mode 100644
index 0000000..b5aec73
--- /dev/null
+++ b/doc/problemexamples/problemtemplate/limits/c
@@ -0,0 +1,15 @@
+#!/bin/bash
+# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename
+echo 4
+# and the number of repetitions to run within the given timelimit in the second line
+echo 10
+# and the maximum amount of memory per repetition in the third line (in Mbytes)
+echo 512
+# and the maximum file size in the fourth line (in kbytes)
+echo 1024
+# and shall return zero to indicate no failure
+exit 0
+# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be
+# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is
+# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs
+# the value.
diff --git a/doc/problemexamples/problemtemplate/limits/cpp b/doc/problemexamples/problemtemplate/limits/cpp
new file mode 100644
index 0000000..b5aec73
--- /dev/null
+++ b/doc/problemexamples/problemtemplate/limits/cpp
@@ -0,0 +1,15 @@
+#!/bin/bash
+# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename
+echo 4
+# and the number of repetitions to run within the given timelimit in the second line
+echo 10
+# and the maximum amount of memory per repetition in the third line (in Mbytes)
+echo 512
+# and the maximum file size in the fourth line (in kbytes)
+echo 1024
+# and shall return zero to indicate no failure
+exit 0
+# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be
+# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is
+# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs
+# the value.
diff --git a/doc/problemexamples/problemtemplate/limits/java b/doc/problemexamples/problemtemplate/limits/java
new file mode 100644
index 0000000..b5aec73
--- /dev/null
+++ b/doc/problemexamples/problemtemplate/limits/java
@@ -0,0 +1,15 @@
+#!/bin/bash
+# this executable shall output the number of second of timelimit in the first line, for the given problem and with language according to this filename
+echo 4
+# and the number of repetitions to run within the given timelimit in the second line
+echo 10
+# and the maximum amount of memory per repetition in the third line (in Mbytes)
+echo 512
+# and the maximum file size in the fourth line (in kbytes)
+echo 1024
+# and shall return zero to indicate no failure
+exit 0
+# the idea is that this file will be executed by the autojudge in the first time the autojudge downloads a problem, so as it will be
+# able to decide the proper time limit for the machine where it is running. If one wants to fix a predefined time limit, then it is
+# enough to write a script like this one with the desired value. Otherwise, one can build any more sophisticated program that outputs
+# the value.
diff --git a/doc/problemexamples/problemtemplate/output/file1 b/doc/problemexamples/problemtemplate/output/file1
new file mode 100644
index 0000000..16a2f69
--- /dev/null
+++ b/doc/problemexamples/problemtemplate/output/file1
@@ -0,0 +1 @@
+FILE WITH THE OUTPUT THAT SHOULD HAVE BEEN GENERATED BY THE PROGRAM FOR THE INPUT WITH THE SAME NAME
diff --git a/doc/problemexamples/problemtemplate/run/c b/doc/problemexamples/problemtemplate/run/c
new file mode 100755
index 0000000..b46e5f9
--- /dev/null
+++ b/doc/problemexamples/problemtemplate/run/c
@@ -0,0 +1,128 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 22/aug/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 exe_file
+# $2 input_file
+# $3 timelimit (limit to run all the repetitions, by default only one repetition)
+# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit)
+# $5 maximum allowed memory (in MBytes)
+# $6 maximum allowed output size (in KBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -x "$1" ]; then
+ echo "$1 not found (or is not in the current dir) or it's not executable"
+ exit 44
+fi
+if [ ! -r "$2" ]; then
+ echo "$2 not found (or is not in the current dir) or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$3
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+nruns=1
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ nruns=$4
+ fi
+fi
+maxm=512000
+if [ "$5" != "" ]; then
+ if [ "$5" -gt "0" ]; then
+ maxm=${5}000
+ fi
+fi
+maxf=1024
+if [ "$6" != "" ]; then
+ if [ "$6" -gt "0" ]; then
+ maxf=${6}
+ fi
+fi
+
+cp "$2" stdin0 2>/dev/null
+cp "$1" run.exe 2>/dev/null
+
+file run.exe | grep -iq "statically linked"
+if [ "$?" != "0" ]; then
+ echo "Aborting because $1 is not statically linked"
+ exit 47
+fi
+
+cdir=`pwd`
+echo "Current directory is $cdir -- chrooting on it" >&2
+$sf -F10 -f$maxf -r$nruns -n1 -R$cdir -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d$maxm -m$maxm -t$time -T$ttime -istdin0 ./run.exe
+ret=$?
+if [ $ret -gt 10 ]; then
+ ret=0
+fi
+if [ -f stdout0 ]; then
+ cat stdout0
+fi
+exit $ret
diff --git a/doc/problemexamples/problemtemplate/run/cpp b/doc/problemexamples/problemtemplate/run/cpp
new file mode 100755
index 0000000..b46e5f9
--- /dev/null
+++ b/doc/problemexamples/problemtemplate/run/cpp
@@ -0,0 +1,128 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 22/aug/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 exe_file
+# $2 input_file
+# $3 timelimit (limit to run all the repetitions, by default only one repetition)
+# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit)
+# $5 maximum allowed memory (in MBytes)
+# $6 maximum allowed output size (in KBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -x "$1" ]; then
+ echo "$1 not found (or is not in the current dir) or it's not executable"
+ exit 44
+fi
+if [ ! -r "$2" ]; then
+ echo "$2 not found (or is not in the current dir) or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$3
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+nruns=1
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ nruns=$4
+ fi
+fi
+maxm=512000
+if [ "$5" != "" ]; then
+ if [ "$5" -gt "0" ]; then
+ maxm=${5}000
+ fi
+fi
+maxf=1024
+if [ "$6" != "" ]; then
+ if [ "$6" -gt "0" ]; then
+ maxf=${6}
+ fi
+fi
+
+cp "$2" stdin0 2>/dev/null
+cp "$1" run.exe 2>/dev/null
+
+file run.exe | grep -iq "statically linked"
+if [ "$?" != "0" ]; then
+ echo "Aborting because $1 is not statically linked"
+ exit 47
+fi
+
+cdir=`pwd`
+echo "Current directory is $cdir -- chrooting on it" >&2
+$sf -F10 -f$maxf -r$nruns -n1 -R$cdir -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d$maxm -m$maxm -t$time -T$ttime -istdin0 ./run.exe
+ret=$?
+if [ $ret -gt 10 ]; then
+ ret=0
+fi
+if [ -f stdout0 ]; then
+ cat stdout0
+fi
+exit $ret
diff --git a/doc/problemexamples/problemtemplate/run/java b/doc/problemexamples/problemtemplate/run/java
new file mode 100755
index 0000000..d6a73a5
--- /dev/null
+++ b/doc/problemexamples/problemtemplate/run/java
@@ -0,0 +1,183 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA System (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see .
+# ////////////////////////////////////////////////////////////////////////////////
+#Last modified: 14/sept/2012 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 main_class
+# $2 input_file
+# $3 timelimit (limit to run all the repetitions, by default only one repetition)
+# $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit)
+# $5 maximum allowed memory (in MBytes)
+# $6 maximum allowed output size (in KBytes)
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ -r run.exe ]; then
+ mv run.exe run.jar
+fi
+if [ -r "$1" ]; then
+ mv "$1" run.jar
+fi
+if [ ! -r run.jar ]; then
+ echo "ERROR: file run.jar not found - possible error during compilation"
+ exit 1
+fi
+name="$1"
+if [ "${name##*.}" == "class" -a "${name##*.}" == "CLASS" ]; then
+ echo "WARNING: removing .class file extension"
+fi
+if [ "${name##*.}" == "class" ]; then
+ name=`basename "$1" .class`
+fi
+if [ "${name##*.}" == "CLASS" ]; then
+ name=`basename "$1" .CLASS`
+fi
+if [ ! -r "$2" ]; then
+ echo "$2 not found (or is not in the current dir) or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+
+time=$3
+if [ "$time" -gt "0" ]; then
+ let "ttime = $time + 30"
+else
+ time=1
+ ttime=30
+fi
+
+nruns=1
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ nruns=$4
+ fi
+fi
+maxm=512000
+if [ "$5" != "" ]; then
+ if [ "$5" -gt "0" ]; then
+ maxm=${5}000
+ fi
+fi
+maxf=1024
+if [ "$6" != "" ]; then
+ if [ "$6" -gt "0" ]; then
+ maxf=${6}
+ fi
+fi
+
+rm -f runit.retcode 2>/dev/null
+cp "$2" stdin0 2>/dev/null
+
+cdir=`pwd`
+echo "Current directory is $cdir" >&2
+echo $cdir | grep -q "/bocajail"
+if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ cat < runit.sh
+#!/bin/bash
+cd "$cdir"
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+java=`which java`
+[ -x "\$java" ] || java=/usr/bin/java
+if [ ! -x \$java ]; then
+ echo "\$java not found or it's not executable"
+ exit 47
+fi
+export CLASSPATH=.:./run.jar:$CLASSPATH
+$sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 -- \$java -Xmx${maxm}K -Xms${maxm}K "$name"
+echo \$? > runit.retcode
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
+ fi
+ if [ "$ret" == "" ]; then
+ echo "Execution error - check autojudging"
+ exit 49
+ fi
+else
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ java=`which java`
+ [ -x "$java" ] || java=/usr/bin/java
+ if [ ! -x $java ]; then
+ echo "$java not found or it's not executable"
+ exit 47
+ fi
+ $sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 -- $java -cp run.jar -Xmx${maxm}K -Xms${maxm}K "$name"
+ ret=$?
+fi
+if [ $ret -gt 10 ]; then
+ echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <"
+ ret=9
+fi
+if [ -f stdout0 ]; then
+ cat stdout0
+fi
+exit $ret
diff --git a/doc/problemexamples/problemtemplate/tests/c b/doc/problemexamples/problemtemplate/tests/c
new file mode 100755
index 0000000..de0a9c5
--- /dev/null
+++ b/doc/problemexamples/problemtemplate/tests/c
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# This file performs a test of the autojudge system. It can run whatever you feel important to test the autojudge
+# and the script files that are included in the problem package
+
+cat > test.c <
+int main() {
+ char s[100];
+ scanf("%s", s);
+ printf("%s\n",s);
+ return 0;
+}
+EOF
+cat > test.in <
+
+int main(int argc, char *argv[])
+{
+ FILE * ent;
+ int cont = 0;
+ int n, num, rec[1000], desp[1000], soma, i, inic, somamax, imax, fmax;
+
+ ent = stdin;
+ fscanf(ent, "%d", &n);
+ while (n > 0){
+ cont++;
+ printf("Fazenda %d\n", cont);
+ for (i = 0; i < n; i++) fscanf(ent, "%d", &rec[i]);
+ for (i = 0; i < n; i++) fscanf(ent, "%d", &desp[i]);
+ somamax = -1;
+ imax = 0;
+ fmax = 0;
+ soma = 0;
+ inic = 1;
+ for (i = 0; i < n; i++){
+ num = rec[i] - desp[i];
+ if (soma + num >= 0){
+ soma += num;
+ if (soma > somamax){
+ imax = inic;
+ fmax = i + 1;
+ somamax = soma;
+ }
+ }
+ else{
+ inic = i + 2;
+ soma = 0;
+ }
+ }
+ if(somamax >= 0)
+ printf("Inicio %d Fim %d\n\n", imax, fmax);
+ else
+ printf("O produtor so teve prejuizo nesta fazenda\n\n");
+
+ fscanf(ent, "%d", &n);
+ }
+ return(0);
+}
+
diff --git a/doc/tests/fontes/bits-compile.c b/doc/tests/fontes/bits-compile.c
new file mode 100644
index 0000000..ad979fd
--- /dev/null
+++ b/doc/tests/fontes/bits-compile.c
@@ -0,0 +1,5 @@
+int main(void) {
+ int n;
+ n = 42
+ return 0;
+}
diff --git a/doc/tests/fontes/bits-compile.cpp b/doc/tests/fontes/bits-compile.cpp
new file mode 100644
index 0000000..ad979fd
--- /dev/null
+++ b/doc/tests/fontes/bits-compile.cpp
@@ -0,0 +1,5 @@
+int main(void) {
+ int n;
+ n = 42
+ return 0;
+}
diff --git a/doc/tests/fontes/bits-compile.java b/doc/tests/fontes/bits-compile.java
new file mode 100644
index 0000000..dcfa1eb
--- /dev/null
+++ b/doc/tests/fontes/bits-compile.java
@@ -0,0 +1,23 @@
+import java.io.*;
+class bits {
+ public static void main(String args[]) {
+ StreamTokenizer st = new StreamTokenizer(System.in);
+ int i, j, n, max, inst=0;
+ while(42==42) {
+ st.nextToken();
+ n = (int) st.nval;
+ if(n==0) break;
+ max=1;
+ for(i=0; imax) max=j;
+ }
+ for(i=0; max>0; i++)
+ max >>= 1;
+ inst++;
+ System.out.println("Instancia " + inst);
+ System.out.println(i*n + "\n");
+ }
+ }
+}
diff --git a/doc/tests/fontes/bits-compile.pas b/doc/tests/fontes/bits-compile.pas
new file mode 100644
index 0000000..ad2765f
--- /dev/null
+++ b/doc/tests/fontes/bits-compile.pas
@@ -0,0 +1,27 @@
+program bits;
+var i, j, n, max, inst: Longint;
+begin
+ inst=0;
+ while true do
+ begin
+ read(n);
+ if n=0 then break;
+ max:=1;
+ for i:=0 to n-1 do
+ begin
+ read(j);
+ if j>max then max:=j
+ end;
+ i:=0;
+ while max>0 do
+ begin
+ max := max div 2;
+ i := i + 1
+ end;
+ write('Instancia ');
+ inst := inst + 1;
+ writeln(inst);
+ writeln(i*n);
+ writeln()
+ end
+end.
diff --git a/doc/tests/fontes/bits-diffbug.c b/doc/tests/fontes/bits-diffbug.c
new file mode 100644
index 0000000..3703152
--- /dev/null
+++ b/doc/tests/fontes/bits-diffbug.c
@@ -0,0 +1,25 @@
+/* this file illustrate a bug in diff that, even using -w -B -b,
+ * it will think that the files are different and will return
+ * exit code 1, when the only difference between them is a line
+ * in the end with a single white space.
+ * Author: cassio@ime.usp.br
+ * Last updated: 18/aug/2008
+ */
+#include
+int main(void) {
+ int i, j, n, max, inst=0;
+ while(42) {
+ scanf("%d", &n);
+ if(!n) break;
+ max=1;
+ for(i=0; imax) max=j;
+ }
+ for(i=0; max>0; i++)
+ max >>= 1;
+ printf("Instancia %d\n%d\n\n", ++inst, i*n);
+ }
+ printf(" \n");
+ return 0;
+}
diff --git a/doc/tests/fontes/bits-incorrect.c b/doc/tests/fontes/bits-incorrect.c
new file mode 100644
index 0000000..de05583
--- /dev/null
+++ b/doc/tests/fontes/bits-incorrect.c
@@ -0,0 +1,17 @@
+#include
+int main(void) {
+ int i, j, n, max, inst=0;
+ while(42) {
+ scanf("%d", &n);
+ if(!n) break;
+ max=0;
+ for(i=0; imax) max=j;
+ }
+ for(i=0; max>0; i++)
+ max >>= 1;
+ printf("Instancia %d\n%d\n\n", ++inst, i*n);
+ }
+ return 0;
+}
diff --git a/doc/tests/fontes/bits-incorrect.cpp b/doc/tests/fontes/bits-incorrect.cpp
new file mode 100644
index 0000000..3b38845
--- /dev/null
+++ b/doc/tests/fontes/bits-incorrect.cpp
@@ -0,0 +1,18 @@
+#include
+using namespace std;
+int main(void) {
+ int i, j, n, max, inst=0;
+ while(42) {
+ cin >> n;
+ if(!n) break;
+ max=0;
+ for(i=0; i> j;
+ if(j>max) max=j;
+ }
+ for(i=0; max>0; i++)
+ max >>= 1;
+ cout << "Instancia " << ++inst << endl << (i*n) << endl << endl;
+ }
+ return 0;
+}
diff --git a/doc/tests/fontes/bits-incorrect.java b/doc/tests/fontes/bits-incorrect.java
new file mode 100644
index 0000000..30b388d
--- /dev/null
+++ b/doc/tests/fontes/bits-incorrect.java
@@ -0,0 +1,23 @@
+import java.io.*;
+class bits {
+ public static void main(String args[]) throws Exception {
+ StreamTokenizer st = new StreamTokenizer(System.in);
+ int i, j, n, max, inst=0;
+ while(42==42) {
+ st.nextToken();
+ n = (int) st.nval;
+ if(n==0) break;
+ max=0;
+ for(i=0; imax) max=j;
+ }
+ for(i=0; max>0; i++)
+ max >>= 1;
+ inst++;
+ System.out.println("Instancia " + inst);
+ System.out.println(i*n + "\n");
+ }
+ }
+}
diff --git a/doc/tests/fontes/bits-incorrect.pas b/doc/tests/fontes/bits-incorrect.pas
new file mode 100644
index 0000000..7dbcd4b
--- /dev/null
+++ b/doc/tests/fontes/bits-incorrect.pas
@@ -0,0 +1,27 @@
+program bits;
+var i, j, n, max, inst: Longint;
+begin
+ inst:=0;
+ while true do
+ begin
+ read(n);
+ if n=0 then break;
+ max:=1;
+ for i:=0 to n-1 do
+ begin
+ read(j);
+ if j>max then max:=j
+ end;
+ i:=0;
+ while max>0 do
+ begin
+ max := max div 2;
+ i := i + 1
+ end;
+ write('Instancia ');
+ inst := inst + 1;
+ writeln(inst);
+ writeln(i);
+ writeln()
+ end
+end.
diff --git a/doc/tests/fontes/bits-outputformat.c b/doc/tests/fontes/bits-outputformat.c
new file mode 100644
index 0000000..62d11f5
--- /dev/null
+++ b/doc/tests/fontes/bits-outputformat.c
@@ -0,0 +1,17 @@
+#include
+int main(void) {
+ int i, j, n, max, inst=0;
+ while(42) {
+ scanf("%d", &n);
+ if(!n) break;
+ max=1;
+ for(i=0; imax) max=j;
+ }
+ for(i=0; max>0; i++)
+ max >>= 1;
+ printf("INStanCIA %d\n%d\n\n", ++inst, i*n);
+ }
+ return 0;
+}
diff --git a/doc/tests/fontes/bits-outputformat.cpp b/doc/tests/fontes/bits-outputformat.cpp
new file mode 100644
index 0000000..62d11f5
--- /dev/null
+++ b/doc/tests/fontes/bits-outputformat.cpp
@@ -0,0 +1,17 @@
+#include
+int main(void) {
+ int i, j, n, max, inst=0;
+ while(42) {
+ scanf("%d", &n);
+ if(!n) break;
+ max=1;
+ for(i=0; imax) max=j;
+ }
+ for(i=0; max>0; i++)
+ max >>= 1;
+ printf("INStanCIA %d\n%d\n\n", ++inst, i*n);
+ }
+ return 0;
+}
diff --git a/doc/tests/fontes/bits-outputformat.java b/doc/tests/fontes/bits-outputformat.java
new file mode 100644
index 0000000..7a3d144
--- /dev/null
+++ b/doc/tests/fontes/bits-outputformat.java
@@ -0,0 +1,23 @@
+import java.io.*;
+class bits {
+ public static void main(String args[]) throws Exception {
+ StreamTokenizer st = new StreamTokenizer(System.in);
+ int i, j, n, max, inst=0;
+ while(42==42) {
+ st.nextToken();
+ n = (int) st.nval;
+ if(n==0) break;
+ max=1;
+ for(i=0; imax) max=j;
+ }
+ for(i=0; max>0; i++)
+ max >>= 1;
+ inst++;
+ System.out.println("Instancia " + inst);
+ System.out.println(i*n);
+ }
+ }
+}
diff --git a/doc/tests/fontes/bits-outputformat.pas b/doc/tests/fontes/bits-outputformat.pas
new file mode 100644
index 0000000..e5094d2
--- /dev/null
+++ b/doc/tests/fontes/bits-outputformat.pas
@@ -0,0 +1,27 @@
+program bits;
+var i, j, n, max, inst: Longint;
+begin
+ inst:=0;
+ while true do
+ begin
+ read(n);
+ if n=0 then break;
+ max:=1;
+ for i:=0 to n-1 do
+ begin
+ read(j);
+ if j>max then max:=j
+ end;
+ i:=0;
+ while max>0 do
+ begin
+ max := max div 2;
+ i := i + 1
+ end;
+ write('Instacia ');
+ inst := inst + 1;
+ writeln(inst);
+ writeln(i*n);
+ writeln()
+ end
+end.
diff --git a/doc/tests/fontes/bits-runtime.c b/doc/tests/fontes/bits-runtime.c
new file mode 100644
index 0000000..9fe074f
--- /dev/null
+++ b/doc/tests/fontes/bits-runtime.c
@@ -0,0 +1,5 @@
+int main(void) {
+ int *n= (int *)42;
+ *n = 42;
+ return 0;
+}
diff --git a/doc/tests/fontes/bits-runtime.cpp b/doc/tests/fontes/bits-runtime.cpp
new file mode 100644
index 0000000..9fe074f
--- /dev/null
+++ b/doc/tests/fontes/bits-runtime.cpp
@@ -0,0 +1,5 @@
+int main(void) {
+ int *n= (int *)42;
+ *n = 42;
+ return 0;
+}
diff --git a/doc/tests/fontes/bits-runtime.java b/doc/tests/fontes/bits-runtime.java
new file mode 100644
index 0000000..f7bffc5
--- /dev/null
+++ b/doc/tests/fontes/bits-runtime.java
@@ -0,0 +1,24 @@
+import java.io.*;
+class bits {
+ public static void main(String args[]) throws Exception {
+ StreamTokenizer st = new StreamTokenizer(System.in);
+ int i, j, n, max, inst=0;
+ while(42==42) {
+ st.nextToken();
+ n = (int) st.nval;
+ if(n==0) break;
+ max=1;
+ for(i=0; imax) max=j;
+ }
+ for(i=0; max>0; i++)
+ max >>= 1;
+ inst++;
+ System.out.println("Instancia " + inst);
+ System.out.println(i*n + "\n");
+ throw new Exception("OPA! Runtime error, hehehe...");
+ }
+ }
+}
diff --git a/doc/tests/fontes/bits-runtime.pas b/doc/tests/fontes/bits-runtime.pas
new file mode 100644
index 0000000..ed496c0
--- /dev/null
+++ b/doc/tests/fontes/bits-runtime.pas
@@ -0,0 +1,27 @@
+program bits;
+var i, inst, max, n: Longint;
+ v: array[0..1] of Longint;
+begin
+ while true do
+ begin
+ read(n);
+ if n=0 then break;
+ max := 1;
+ for i:=0 to n-1 do
+ begin
+ read(v[i]);
+ if v[i]>max then max:=v[i]
+ end;
+ i:=0;
+ while max>0 do
+ begin
+ max := max div 2;
+ i := i + 1
+ end;
+ write('Instancia ');
+ inst := inst + 1;
+ writeln(inst);
+ writeln(i*n);
+ writeln()
+ end
+end.
diff --git a/doc/tests/fontes/bits-timelimit.c b/doc/tests/fontes/bits-timelimit.c
new file mode 100644
index 0000000..19e1c57
--- /dev/null
+++ b/doc/tests/fontes/bits-timelimit.c
@@ -0,0 +1,8 @@
+#include
+int main(void) {
+ int n=0;
+ while(42) {
+ n++;
+ }
+ return 0;
+}
diff --git a/doc/tests/fontes/bits-timelimit.cpp b/doc/tests/fontes/bits-timelimit.cpp
new file mode 100644
index 0000000..25cb517
--- /dev/null
+++ b/doc/tests/fontes/bits-timelimit.cpp
@@ -0,0 +1,8 @@
+#include
+int main(void) {
+ int n=0;
+ while(42) {
+ n++;
+ }
+ return 0;
+}
diff --git a/doc/tests/fontes/bits-timelimit.java b/doc/tests/fontes/bits-timelimit.java
new file mode 100644
index 0000000..4330bb3
--- /dev/null
+++ b/doc/tests/fontes/bits-timelimit.java
@@ -0,0 +1,10 @@
+import java.io.*;
+class bits {
+ public static void main(String args[]) throws Exception {
+ StreamTokenizer st = new StreamTokenizer(System.in);
+ int inst=0;
+ while(42==42) {
+ inst++;
+ }
+ }
+}
diff --git a/doc/tests/fontes/bits-timelimit.pas b/doc/tests/fontes/bits-timelimit.pas
new file mode 100644
index 0000000..d0b496d
--- /dev/null
+++ b/doc/tests/fontes/bits-timelimit.pas
@@ -0,0 +1,8 @@
+program bits;
+var inst: Longint;
+begin
+ inst:=0;
+ while true do
+ begin
+ end
+end.
diff --git a/doc/tests/fontes/bits-yes.c b/doc/tests/fontes/bits-yes.c
new file mode 100644
index 0000000..ab23f83
--- /dev/null
+++ b/doc/tests/fontes/bits-yes.c
@@ -0,0 +1,17 @@
+#include
+int main(void) {
+ int i, j, n, max, inst=0;
+ while(42) {
+ scanf("%d", &n);
+ if(!n) break;
+ max=1;
+ for(i=0; imax) max=j;
+ }
+ for(i=0; max>0; i++)
+ max >>= 1;
+ printf("Instancia %d\n%d\n\n", ++inst, i*n);
+ }
+ return 0;
+}
diff --git a/doc/tests/fontes/bits-yes.cpp b/doc/tests/fontes/bits-yes.cpp
new file mode 100644
index 0000000..11a32b5
--- /dev/null
+++ b/doc/tests/fontes/bits-yes.cpp
@@ -0,0 +1,18 @@
+#include
+using namespace std;
+int main(void) {
+ int i, j, n, max, inst=0;
+ while(42) {
+ cin >> n;
+ if(!n) break;
+ max=1;
+ for(i=0; i> j;
+ if(j>max) max=j;
+ }
+ for(i=0; max>0; i++)
+ max >>= 1;
+ cout << "Instancia " << ++inst << endl << (i*n) << endl << endl;
+ }
+ return 0;
+}
diff --git a/doc/tests/fontes/bits-yes.java b/doc/tests/fontes/bits-yes.java
new file mode 100644
index 0000000..3448484
--- /dev/null
+++ b/doc/tests/fontes/bits-yes.java
@@ -0,0 +1,23 @@
+import java.io.*;
+class bits {
+ public static void main(String args[]) throws Exception {
+ StreamTokenizer st = new StreamTokenizer(System.in);
+ int i, j, n, max, inst=0;
+ while(42==42) {
+ st.nextToken();
+ n = (int) st.nval;
+ if(n==0) break;
+ max=1;
+ for(i=0; imax) max=j;
+ }
+ for(i=0; max>0; i++)
+ max >>= 1;
+ inst++;
+ System.out.println("Instancia " + inst);
+ System.out.println(i*n + "\n");
+ }
+ }
+}
diff --git a/doc/tests/fontes/bits-yes.pas b/doc/tests/fontes/bits-yes.pas
new file mode 100644
index 0000000..0970c43
--- /dev/null
+++ b/doc/tests/fontes/bits-yes.pas
@@ -0,0 +1,27 @@
+program bits;
+var i, j, n, max, inst: Longint;
+begin
+ inst:=0;
+ while true do
+ begin
+ read(n);
+ if n=0 then break;
+ max:=1;
+ for i:=0 to n-1 do
+ begin
+ read(j);
+ if j>max then max:=j
+ end;
+ i:=0;
+ while max>0 do
+ begin
+ max := max div 2;
+ i := i + 1
+ end;
+ write('Instancia ');
+ inst := inst + 1;
+ writeln(inst);
+ writeln(i*n);
+ writeln()
+ end
+end.
diff --git a/doc/tests/fontes/formiga-yes.c b/doc/tests/fontes/formiga-yes.c
new file mode 100644
index 0000000..7640d75
--- /dev/null
+++ b/doc/tests/fontes/formiga-yes.c
@@ -0,0 +1,68 @@
+/* Copyright 2002 Maratona de Programacao do IME-USP -- cef@ime.usp.br (written by S.G.Tavares)
+ */
+
+#include
+#include
+#include
+#include
+
+FILE *in, *out;
+
+long mdc(long a, long b){
+ long i, mdca=1;
+ for(i=2; ((i<=a) && (i<=b)) ; i++)
+ if ((!(a%i)) && (!(b%i))) mdca = i;
+ return mdca;
+}
+
+
+int main(){
+ long x, y, i, j, k;
+ char p1[8];
+ double db1;
+ int dh, dv;
+ in = stdin;
+ out = stdout;
+
+ while(42){
+ fscanf(in, "%ld%ld\n", &x, &y);
+ if (!x || !y) break;
+ fscanf(in, "%s\n", &p1[0]);
+ if (p1[0]=='N') {
+ dh = 0;
+ dv = 0;
+ }
+ else if (p1[0]=='S') {
+ dh = 1;
+ dv = 1;
+ }
+ else if (p1[0]=='L') {
+ dh = 1;
+ dv = 0;
+ }
+ else {
+ dh = 0;
+ dv = 1;
+ }
+ for (i=x, j=y; ((!(i%2)) && (!(j%2))); i /= 2, j /= 2 );
+ if (i%2) dh = !dh;
+ if (j%2) dv = !dv;
+ k = mdc(x, y);
+ db1 = 100.0/(double)k;
+ i = floor(100.0/(double)k);
+ if (db1-(double)i > 0.5) i++;
+
+ j = x/k + y/k -2;
+ fprintf(out, "%3ld%%%10ld", i, j);
+ if (dh){
+ if (dv) fprintf(out, " Sul\n");
+ else fprintf(out, " Leste\n");
+ }
+ else {
+ if (dv) fprintf(out, " Oeste\n");
+ else fprintf(out, " Norte\n");
+ }
+ }
+
+ return 0;
+}
diff --git a/doc/tests/fontes/grid.java b/doc/tests/fontes/grid.java
new file mode 100644
index 0000000..b7876ec
--- /dev/null
+++ b/doc/tests/fontes/grid.java
@@ -0,0 +1,10 @@
+import java.io.*;
+class cancer {
+ public static void main(String args[]) throws Exception {
+ StreamTokenizer st = new StreamTokenizer(System.in);
+ int inst=0;
+ while(42==42) {
+ inst++;
+ }
+ }
+}
diff --git a/doc/tests/fontes/multas-yes.c b/doc/tests/fontes/multas-yes.c
new file mode 100644
index 0000000..3729d0b
--- /dev/null
+++ b/doc/tests/fontes/multas-yes.c
@@ -0,0 +1,85 @@
+/* Copyright 2001 Maratona de Programacao do IME-USP -- cef@ime.usp.br
+ */
+
+#include
+
+typedef struct
+{
+ char nome[100];
+ char nomeconv[100];
+
+ int pontos;
+}
+m_familia;
+
+#define MAX 21
+
+char conv(char c)
+{
+ if(c >= 'A' && c <= 'Z') return (c += 'a' - 'A');
+ return(c);
+
+}
+
+
+int menor(char v[80], char w[80])
+{
+ int i=0;
+
+ while(i < 80 && v[i] == w[i])i++;
+ return(v[i] < w[i]);
+}
+
+
+int main(int argc, char *argv[])
+{
+ FILE * ent;
+ int cont = 0;
+ int n, i,j, multa, nmult, min;
+ m_familia familia[20];
+
+ ent = stdin;
+
+ fscanf(ent, "%d", &n);
+ while (n > 0){
+ cont++;
+ printf("Familia %d\n", cont);
+
+ for (i = 0; i < n; i++){
+ fscanf(ent, "%s", &(familia[i].nome[0]));
+ j = 0;
+ while(familia[i].nome[j] != 0) {
+ familia[i].nomeconv[j]=conv(familia[i].nome[j]);
+ j++;
+ }
+ familia[i].nomeconv[j]=0;
+
+ familia[i].pontos = 0;
+ }
+ fscanf(ent, "%d", &multa);
+ nmult = 0;
+
+ while(multa > 0){
+ nmult++;
+ min = 0;
+ for (i = 0; i < n; i++)
+ if (familia[i].pontos < familia[min].pontos ||
+ (familia[i].pontos == familia[min].pontos &&
+ menor(familia[i].nomeconv, familia[min].nomeconv)))
+ min = i;
+ printf("Multa %d %s", nmult, familia[min].nome);
+ familia[min].pontos += multa;
+ if ( familia[min].pontos >= MAX)
+ printf(" carteira suspensa\n");
+ else printf("\n");
+ fscanf(ent, "%d", &multa);
+ }
+ printf("\n");
+
+ fscanf(ent, "%d", &n);
+ }
+ fclose(ent);
+ return(0);
+}
+
+
diff --git a/doc/tests/in_out/abacaxi.in b/doc/tests/in_out/abacaxi.in
new file mode 100644
index 0000000..26d3afe
--- /dev/null
+++ b/doc/tests/in_out/abacaxi.in
@@ -0,0 +1,25 @@
+5
+32 37 82 46 32
+13 40 75 62 19
+8
+14 22 29 41 72 25 68 90
+22 19 21 45 70 46 66 80
+3
+2 4 5
+8 8 8
+8
+12 1 0 8 5 0 9 4
+0 0 13 0 0 13 0 0
+8
+8 8 8 8 8 8 8 8
+7 9 5 8 9 5 9 7
+1
+0
+0
+999
+1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+999
+ 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0
diff --git a/doc/tests/in_out/abacaxi.sol b/doc/tests/in_out/abacaxi.sol
new file mode 100644
index 0000000..2e9fd8b
--- /dev/null
+++ b/doc/tests/in_out/abacaxi.sol
@@ -0,0 +1,24 @@
+Fazenda 1
+Inicio 1 Fim 3
+
+Fazenda 2
+Inicio 7 Fim 8
+
+Fazenda 3
+O produtor so teve prejuizo nesta fazenda
+
+Fazenda 4
+Inicio 1 Fim 2
+
+Fazenda 5
+Inicio 1 Fim 6
+
+Fazenda 6
+Inicio 1 Fim 1
+
+Fazenda 7
+Inicio 1 Fim 999
+
+Fazenda 8
+Inicio 1 Fim 999
+
diff --git a/doc/tests/in_out/bits.in b/doc/tests/in_out/bits.in
new file mode 100644
index 0000000..ef548be
--- /dev/null
+++ b/doc/tests/in_out/bits.in
@@ -0,0 +1,9 @@
+1 7
+4 1 10 20 30
+2 2000 999
+3 0 0 0
+2 1 1000
+1000 1073741824 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 0
+1 8
+0
diff --git a/doc/tests/in_out/bits.sol b/doc/tests/in_out/bits.sol
new file mode 100644
index 0000000..7749442
--- /dev/null
+++ b/doc/tests/in_out/bits.sol
@@ -0,0 +1,24 @@
+Instancia 1
+3
+
+Instancia 2
+20
+
+Instancia 3
+22
+
+Instancia 4
+3
+
+Instancia 5
+20
+
+Instancia 6
+31000
+
+Instancia 7
+1
+
+Instancia 8
+4
+
diff --git a/doc/tests/in_out/formiga.in b/doc/tests/in_out/formiga.in
new file mode 100644
index 0000000..c9a59b2
--- /dev/null
+++ b/doc/tests/in_out/formiga.in
@@ -0,0 +1,15 @@
+1 1 Norte
+4 8 Norte
+3 2 Sul
+100000 100000 Oeste
+6 6 Sul
+4 13 Oeste
+4 14 Sul
+4 13 Leste
+640 648 Norte
+45 99998 Leste
+45 99995 Oeste
+99999 99998 Norte
+99999 99996 Oeste
+445 1157 Sul
+100000 0 Qqlixo
diff --git a/doc/tests/in_out/formiga.sol b/doc/tests/in_out/formiga.sol
new file mode 100644
index 0000000..499641c
--- /dev/null
+++ b/doc/tests/in_out/formiga.sol
@@ -0,0 +1,14 @@
+100% 0 Sul
+ 25% 1 Leste
+100% 3 Oeste
+ 0% 0 Leste
+ 17% 0 Norte
+100% 15 Norte
+ 50% 7 Leste
+100% 15 Sul
+ 12% 159 Oeste
+100% 100041 Norte
+ 20% 20006 Leste
+100% 199995 Leste
+ 33% 66663 Sul
+ 1% 16 Norte
diff --git a/doc/tests/in_out/multas.in b/doc/tests/in_out/multas.in
new file mode 100644
index 0000000..bb947cd
--- /dev/null
+++ b/doc/tests/in_out/multas.in
@@ -0,0 +1,518 @@
+5
+john
+mary
+bob
+rick
+donna
+4
+4
+5
+7
+7
+7
+-2
+3
+paul
+irene
+charlie
+5
+5
+5
+5
+5
+4
+7
+7
+4
+4
+4
+4
+-3
+19
+Zzzzzzzzzzzzzzzzzzzs
+zzzzzzzzzzzzzzzzzzzr
+zzzzzzzzzzzzzzzzzzzq
+zzzzzzzzzzzzzzzzzzzpzzzzzzzzzzzzzzzzzzzpzzzzzzzzzzzzzzzzzzzpzzzzzzzzzzzzzzzzzzzp
+zzzzzzzzzzzzzzzzzzzo
+zzzzzzzzzzzzzzzzzzzn
+zzzzzzzzzzzzzzzzzzzm
+zzzzzzzzzzzzzzzzzzzl
+zzzzzzzzzzzzzzzzzzzk
+zzzzzzzzzzzzzzzzzzzj
+zzzzzzzzzzzzzzzzzzzi
+zzzzzzzzzzzzzzzzzzzh
+zzzzzzzzzzzzzzzzzzzg
+zzzzzzzzzzzzzzzzzzzf
+zzzzzzzzzzzzzzzzzzze
+zzzzzzzzzzzzzzzzzzzd
+zzzzzzzzzzzzzzzzzzzc
+zzzzzzzzzzzzzzzzzzzb
+Zzzzzzzzzzzzzzzzzzza
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+250
+-50
+19
+Zzzzzzzzzzzzzzzzzzzs
+zzzzzzzzzzzzzzzzzzzr
+zzzzzzzzzzzzzzzzzzzq
+zzzzzzzzzzzzzzzzzzzp
+zzzzzzzzzzzzzzzzzzzo
+zzzzzzzzzzzzzzzzzzzn
+zzzzzzzzzzzzzzzzzzzm
+zzzzzzzzzzzzzzzzzzzl
+zzzzzzzzzzzzzzzzzzzk
+zzzzzzzzzzzzzzzzzzzj
+zzzzzzzzzzzzzzzzzzzi
+zzzzzzzzzzzzzzzzzzzh
+zzzzzzzzzzzzzzzzzzzg
+zzzzzzzzzzzzzzzzzzzf
+zzzzzzzzzzzzzzzzzzze
+zzzzzzzzzzzzzzzzzzzd
+zzzzzzzzzzzzzzzzzzzc
+zzzzzzzzzzzzzzzzzzzb
+Zzzzzzzzzzzzzzzzzzza
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+-50
+5
+a
+b
+c
+d
+e
+5
+4
+3
+2
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+-3
+0
diff --git a/doc/tests/in_out/multas.sol b/doc/tests/in_out/multas.sol
new file mode 100644
index 0000000..5855c90
--- /dev/null
+++ b/doc/tests/in_out/multas.sol
@@ -0,0 +1,466 @@
+Familia 1
+Multa 1 bob
+Multa 2 donna
+Multa 3 john
+Multa 4 mary
+Multa 5 rick
+Multa 6 bob
+
+Familia 2
+Multa 1 charlie
+Multa 2 irene
+Multa 3 paul
+Multa 4 charlie
+Multa 5 irene
+Multa 6 paul
+Multa 7 paul
+Multa 8 charlie
+Multa 9 irene
+Multa 10 irene
+Multa 11 paul
+Multa 12 charlie carteira suspensa
+
+Familia 3
+Multa 1 Zzzzzzzzzzzzzzzzzzza carteira suspensa
+Multa 2 zzzzzzzzzzzzzzzzzzzb carteira suspensa
+Multa 3 zzzzzzzzzzzzzzzzzzzc carteira suspensa
+Multa 4 zzzzzzzzzzzzzzzzzzzd carteira suspensa
+Multa 5 zzzzzzzzzzzzzzzzzzze carteira suspensa
+Multa 6 zzzzzzzzzzzzzzzzzzzf carteira suspensa
+Multa 7 zzzzzzzzzzzzzzzzzzzg carteira suspensa
+Multa 8 zzzzzzzzzzzzzzzzzzzh carteira suspensa
+Multa 9 zzzzzzzzzzzzzzzzzzzi carteira suspensa
+Multa 10 zzzzzzzzzzzzzzzzzzzj carteira suspensa
+Multa 11 zzzzzzzzzzzzzzzzzzzk carteira suspensa
+Multa 12 zzzzzzzzzzzzzzzzzzzl carteira suspensa
+Multa 13 zzzzzzzzzzzzzzzzzzzm carteira suspensa
+Multa 14 zzzzzzzzzzzzzzzzzzzn carteira suspensa
+Multa 15 zzzzzzzzzzzzzzzzzzzo carteira suspensa
+Multa 16 zzzzzzzzzzzzzzzzzzzpzzzzzzzzzzzzzzzzzzzpzzzzzzzzzzzzzzzzzzzpzzzzzzzzzzzzzzzzzzzp carteira suspensa
+Multa 17 zzzzzzzzzzzzzzzzzzzq carteira suspensa
+Multa 18 zzzzzzzzzzzzzzzzzzzr carteira suspensa
+Multa 19 Zzzzzzzzzzzzzzzzzzzs carteira suspensa
+
+Familia 4
+Multa 1 Zzzzzzzzzzzzzzzzzzza
+Multa 2 zzzzzzzzzzzzzzzzzzzb
+Multa 3 zzzzzzzzzzzzzzzzzzzc
+Multa 4 zzzzzzzzzzzzzzzzzzzd
+Multa 5 zzzzzzzzzzzzzzzzzzze
+Multa 6 zzzzzzzzzzzzzzzzzzzf
+Multa 7 zzzzzzzzzzzzzzzzzzzg
+Multa 8 zzzzzzzzzzzzzzzzzzzh
+Multa 9 zzzzzzzzzzzzzzzzzzzi
+Multa 10 zzzzzzzzzzzzzzzzzzzj
+Multa 11 zzzzzzzzzzzzzzzzzzzk
+Multa 12 zzzzzzzzzzzzzzzzzzzl
+Multa 13 zzzzzzzzzzzzzzzzzzzm
+Multa 14 zzzzzzzzzzzzzzzzzzzn
+Multa 15 zzzzzzzzzzzzzzzzzzzo
+Multa 16 zzzzzzzzzzzzzzzzzzzp
+Multa 17 zzzzzzzzzzzzzzzzzzzq
+Multa 18 zzzzzzzzzzzzzzzzzzzr
+Multa 19 Zzzzzzzzzzzzzzzzzzzs
+Multa 20 Zzzzzzzzzzzzzzzzzzza
+Multa 21 zzzzzzzzzzzzzzzzzzzb
+Multa 22 zzzzzzzzzzzzzzzzzzzc
+Multa 23 zzzzzzzzzzzzzzzzzzzd
+Multa 24 zzzzzzzzzzzzzzzzzzze
+Multa 25 zzzzzzzzzzzzzzzzzzzf
+Multa 26 zzzzzzzzzzzzzzzzzzzg
+Multa 27 zzzzzzzzzzzzzzzzzzzh
+Multa 28 zzzzzzzzzzzzzzzzzzzi
+Multa 29 zzzzzzzzzzzzzzzzzzzj
+Multa 30 zzzzzzzzzzzzzzzzzzzk
+Multa 31 zzzzzzzzzzzzzzzzzzzl
+Multa 32 zzzzzzzzzzzzzzzzzzzm
+Multa 33 zzzzzzzzzzzzzzzzzzzn
+Multa 34 zzzzzzzzzzzzzzzzzzzo
+Multa 35 zzzzzzzzzzzzzzzzzzzp
+Multa 36 zzzzzzzzzzzzzzzzzzzq
+Multa 37 zzzzzzzzzzzzzzzzzzzr
+Multa 38 Zzzzzzzzzzzzzzzzzzzs
+Multa 39 Zzzzzzzzzzzzzzzzzzza
+Multa 40 zzzzzzzzzzzzzzzzzzzb
+Multa 41 zzzzzzzzzzzzzzzzzzzc
+Multa 42 zzzzzzzzzzzzzzzzzzzd
+Multa 43 zzzzzzzzzzzzzzzzzzze
+Multa 44 zzzzzzzzzzzzzzzzzzzf
+Multa 45 zzzzzzzzzzzzzzzzzzzg
+Multa 46 zzzzzzzzzzzzzzzzzzzh
+Multa 47 zzzzzzzzzzzzzzzzzzzi
+Multa 48 zzzzzzzzzzzzzzzzzzzj
+Multa 49 zzzzzzzzzzzzzzzzzzzk
+Multa 50 zzzzzzzzzzzzzzzzzzzl
+Multa 51 zzzzzzzzzzzzzzzzzzzm
+Multa 52 zzzzzzzzzzzzzzzzzzzn
+Multa 53 zzzzzzzzzzzzzzzzzzzo
+Multa 54 zzzzzzzzzzzzzzzzzzzp
+Multa 55 zzzzzzzzzzzzzzzzzzzq
+Multa 56 zzzzzzzzzzzzzzzzzzzr
+Multa 57 Zzzzzzzzzzzzzzzzzzzs
+Multa 58 Zzzzzzzzzzzzzzzzzzza
+Multa 59 zzzzzzzzzzzzzzzzzzzb
+Multa 60 zzzzzzzzzzzzzzzzzzzc
+Multa 61 zzzzzzzzzzzzzzzzzzzd
+Multa 62 zzzzzzzzzzzzzzzzzzze
+Multa 63 zzzzzzzzzzzzzzzzzzzf
+Multa 64 zzzzzzzzzzzzzzzzzzzg
+Multa 65 zzzzzzzzzzzzzzzzzzzh
+Multa 66 zzzzzzzzzzzzzzzzzzzi
+Multa 67 zzzzzzzzzzzzzzzzzzzj
+Multa 68 zzzzzzzzzzzzzzzzzzzk
+Multa 69 zzzzzzzzzzzzzzzzzzzl
+Multa 70 zzzzzzzzzzzzzzzzzzzm
+Multa 71 zzzzzzzzzzzzzzzzzzzn
+Multa 72 zzzzzzzzzzzzzzzzzzzo
+Multa 73 zzzzzzzzzzzzzzzzzzzp
+Multa 74 zzzzzzzzzzzzzzzzzzzq
+Multa 75 zzzzzzzzzzzzzzzzzzzr
+Multa 76 Zzzzzzzzzzzzzzzzzzzs
+Multa 77 Zzzzzzzzzzzzzzzzzzza
+Multa 78 zzzzzzzzzzzzzzzzzzzb
+Multa 79 zzzzzzzzzzzzzzzzzzzc
+Multa 80 zzzzzzzzzzzzzzzzzzzd
+Multa 81 zzzzzzzzzzzzzzzzzzze
+Multa 82 zzzzzzzzzzzzzzzzzzzf
+Multa 83 zzzzzzzzzzzzzzzzzzzg
+Multa 84 zzzzzzzzzzzzzzzzzzzh
+Multa 85 zzzzzzzzzzzzzzzzzzzi
+Multa 86 zzzzzzzzzzzzzzzzzzzj
+Multa 87 zzzzzzzzzzzzzzzzzzzk
+Multa 88 zzzzzzzzzzzzzzzzzzzl
+Multa 89 zzzzzzzzzzzzzzzzzzzm
+Multa 90 zzzzzzzzzzzzzzzzzzzn
+Multa 91 zzzzzzzzzzzzzzzzzzzo
+Multa 92 zzzzzzzzzzzzzzzzzzzp
+Multa 93 zzzzzzzzzzzzzzzzzzzq
+Multa 94 zzzzzzzzzzzzzzzzzzzr
+Multa 95 Zzzzzzzzzzzzzzzzzzzs
+Multa 96 Zzzzzzzzzzzzzzzzzzza
+Multa 97 zzzzzzzzzzzzzzzzzzzb
+Multa 98 zzzzzzzzzzzzzzzzzzzc
+Multa 99 zzzzzzzzzzzzzzzzzzzd
+Multa 100 zzzzzzzzzzzzzzzzzzze
+Multa 101 zzzzzzzzzzzzzzzzzzzf
+Multa 102 zzzzzzzzzzzzzzzzzzzg
+Multa 103 zzzzzzzzzzzzzzzzzzzh
+Multa 104 zzzzzzzzzzzzzzzzzzzi
+Multa 105 zzzzzzzzzzzzzzzzzzzj
+Multa 106 zzzzzzzzzzzzzzzzzzzk
+Multa 107 zzzzzzzzzzzzzzzzzzzl
+Multa 108 zzzzzzzzzzzzzzzzzzzm
+Multa 109 zzzzzzzzzzzzzzzzzzzn
+Multa 110 zzzzzzzzzzzzzzzzzzzo
+Multa 111 zzzzzzzzzzzzzzzzzzzp
+Multa 112 zzzzzzzzzzzzzzzzzzzq
+Multa 113 zzzzzzzzzzzzzzzzzzzr
+Multa 114 Zzzzzzzzzzzzzzzzzzzs
+Multa 115 Zzzzzzzzzzzzzzzzzzza
+Multa 116 zzzzzzzzzzzzzzzzzzzb
+Multa 117 zzzzzzzzzzzzzzzzzzzc
+Multa 118 zzzzzzzzzzzzzzzzzzzd
+Multa 119 zzzzzzzzzzzzzzzzzzze
+Multa 120 zzzzzzzzzzzzzzzzzzzf
+Multa 121 zzzzzzzzzzzzzzzzzzzg
+Multa 122 zzzzzzzzzzzzzzzzzzzh
+Multa 123 zzzzzzzzzzzzzzzzzzzi
+Multa 124 zzzzzzzzzzzzzzzzzzzj
+Multa 125 zzzzzzzzzzzzzzzzzzzk
+Multa 126 zzzzzzzzzzzzzzzzzzzl
+Multa 127 zzzzzzzzzzzzzzzzzzzm
+Multa 128 zzzzzzzzzzzzzzzzzzzn
+Multa 129 zzzzzzzzzzzzzzzzzzzo
+Multa 130 zzzzzzzzzzzzzzzzzzzp
+Multa 131 zzzzzzzzzzzzzzzzzzzq
+Multa 132 zzzzzzzzzzzzzzzzzzzr
+Multa 133 Zzzzzzzzzzzzzzzzzzzs
+Multa 134 Zzzzzzzzzzzzzzzzzzza
+Multa 135 zzzzzzzzzzzzzzzzzzzb
+Multa 136 zzzzzzzzzzzzzzzzzzzc
+Multa 137 zzzzzzzzzzzzzzzzzzzd
+Multa 138 zzzzzzzzzzzzzzzzzzze
+Multa 139 zzzzzzzzzzzzzzzzzzzf
+Multa 140 zzzzzzzzzzzzzzzzzzzg
+Multa 141 zzzzzzzzzzzzzzzzzzzh
+Multa 142 zzzzzzzzzzzzzzzzzzzi
+Multa 143 zzzzzzzzzzzzzzzzzzzj
+Multa 144 zzzzzzzzzzzzzzzzzzzk
+Multa 145 zzzzzzzzzzzzzzzzzzzl
+Multa 146 zzzzzzzzzzzzzzzzzzzm
+Multa 147 zzzzzzzzzzzzzzzzzzzn
+Multa 148 zzzzzzzzzzzzzzzzzzzo
+Multa 149 zzzzzzzzzzzzzzzzzzzp
+Multa 150 zzzzzzzzzzzzzzzzzzzq
+Multa 151 zzzzzzzzzzzzzzzzzzzr
+Multa 152 Zzzzzzzzzzzzzzzzzzzs
+Multa 153 Zzzzzzzzzzzzzzzzzzza
+Multa 154 zzzzzzzzzzzzzzzzzzzb
+Multa 155 zzzzzzzzzzzzzzzzzzzc
+Multa 156 zzzzzzzzzzzzzzzzzzzd
+Multa 157 zzzzzzzzzzzzzzzzzzze
+Multa 158 zzzzzzzzzzzzzzzzzzzf
+Multa 159 zzzzzzzzzzzzzzzzzzzg
+Multa 160 zzzzzzzzzzzzzzzzzzzh
+Multa 161 zzzzzzzzzzzzzzzzzzzi
+Multa 162 zzzzzzzzzzzzzzzzzzzj
+Multa 163 zzzzzzzzzzzzzzzzzzzk
+Multa 164 zzzzzzzzzzzzzzzzzzzl
+Multa 165 zzzzzzzzzzzzzzzzzzzm
+Multa 166 zzzzzzzzzzzzzzzzzzzn
+Multa 167 zzzzzzzzzzzzzzzzzzzo
+Multa 168 zzzzzzzzzzzzzzzzzzzp
+Multa 169 zzzzzzzzzzzzzzzzzzzq
+Multa 170 zzzzzzzzzzzzzzzzzzzr
+Multa 171 Zzzzzzzzzzzzzzzzzzzs
+Multa 172 Zzzzzzzzzzzzzzzzzzza
+Multa 173 zzzzzzzzzzzzzzzzzzzb
+Multa 174 zzzzzzzzzzzzzzzzzzzc
+Multa 175 zzzzzzzzzzzzzzzzzzzd
+Multa 176 zzzzzzzzzzzzzzzzzzze
+Multa 177 zzzzzzzzzzzzzzzzzzzf
+Multa 178 zzzzzzzzzzzzzzzzzzzg
+Multa 179 zzzzzzzzzzzzzzzzzzzh
+Multa 180 zzzzzzzzzzzzzzzzzzzi
+Multa 181 zzzzzzzzzzzzzzzzzzzj
+Multa 182 zzzzzzzzzzzzzzzzzzzk
+Multa 183 zzzzzzzzzzzzzzzzzzzl
+Multa 184 zzzzzzzzzzzzzzzzzzzm
+Multa 185 zzzzzzzzzzzzzzzzzzzn
+Multa 186 zzzzzzzzzzzzzzzzzzzo
+Multa 187 zzzzzzzzzzzzzzzzzzzp
+Multa 188 zzzzzzzzzzzzzzzzzzzq
+Multa 189 zzzzzzzzzzzzzzzzzzzr
+Multa 190 Zzzzzzzzzzzzzzzzzzzs
+Multa 191 Zzzzzzzzzzzzzzzzzzza
+Multa 192 zzzzzzzzzzzzzzzzzzzb
+Multa 193 zzzzzzzzzzzzzzzzzzzc
+Multa 194 zzzzzzzzzzzzzzzzzzzd
+Multa 195 zzzzzzzzzzzzzzzzzzze
+Multa 196 zzzzzzzzzzzzzzzzzzzf
+Multa 197 zzzzzzzzzzzzzzzzzzzg
+Multa 198 zzzzzzzzzzzzzzzzzzzh
+Multa 199 zzzzzzzzzzzzzzzzzzzi
+Multa 200 zzzzzzzzzzzzzzzzzzzj
+Multa 201 zzzzzzzzzzzzzzzzzzzk
+Multa 202 zzzzzzzzzzzzzzzzzzzl
+Multa 203 zzzzzzzzzzzzzzzzzzzm
+Multa 204 zzzzzzzzzzzzzzzzzzzn
+Multa 205 zzzzzzzzzzzzzzzzzzzo
+Multa 206 zzzzzzzzzzzzzzzzzzzp
+Multa 207 zzzzzzzzzzzzzzzzzzzq
+Multa 208 zzzzzzzzzzzzzzzzzzzr
+Multa 209 Zzzzzzzzzzzzzzzzzzzs
+Multa 210 Zzzzzzzzzzzzzzzzzzza
+Multa 211 zzzzzzzzzzzzzzzzzzzb
+Multa 212 zzzzzzzzzzzzzzzzzzzc
+Multa 213 zzzzzzzzzzzzzzzzzzzd
+Multa 214 zzzzzzzzzzzzzzzzzzze
+Multa 215 zzzzzzzzzzzzzzzzzzzf
+Multa 216 zzzzzzzzzzzzzzzzzzzg
+Multa 217 zzzzzzzzzzzzzzzzzzzh
+Multa 218 zzzzzzzzzzzzzzzzzzzi
+Multa 219 zzzzzzzzzzzzzzzzzzzj
+Multa 220 zzzzzzzzzzzzzzzzzzzk
+Multa 221 zzzzzzzzzzzzzzzzzzzl
+Multa 222 zzzzzzzzzzzzzzzzzzzm
+Multa 223 zzzzzzzzzzzzzzzzzzzn
+Multa 224 zzzzzzzzzzzzzzzzzzzo
+Multa 225 zzzzzzzzzzzzzzzzzzzp
+Multa 226 zzzzzzzzzzzzzzzzzzzq
+Multa 227 zzzzzzzzzzzzzzzzzzzr
+Multa 228 Zzzzzzzzzzzzzzzzzzzs
+Multa 229 Zzzzzzzzzzzzzzzzzzza
+Multa 230 zzzzzzzzzzzzzzzzzzzb
+Multa 231 zzzzzzzzzzzzzzzzzzzc
+Multa 232 zzzzzzzzzzzzzzzzzzzd
+Multa 233 zzzzzzzzzzzzzzzzzzze
+Multa 234 zzzzzzzzzzzzzzzzzzzf
+Multa 235 zzzzzzzzzzzzzzzzzzzg
+Multa 236 zzzzzzzzzzzzzzzzzzzh
+Multa 237 zzzzzzzzzzzzzzzzzzzi
+Multa 238 zzzzzzzzzzzzzzzzzzzj
+Multa 239 zzzzzzzzzzzzzzzzzzzk
+Multa 240 zzzzzzzzzzzzzzzzzzzl
+Multa 241 zzzzzzzzzzzzzzzzzzzm
+Multa 242 zzzzzzzzzzzzzzzzzzzn
+Multa 243 zzzzzzzzzzzzzzzzzzzo
+Multa 244 zzzzzzzzzzzzzzzzzzzp
+Multa 245 zzzzzzzzzzzzzzzzzzzq
+Multa 246 zzzzzzzzzzzzzzzzzzzr
+Multa 247 Zzzzzzzzzzzzzzzzzzzs
+Multa 248 Zzzzzzzzzzzzzzzzzzza
+Multa 249 zzzzzzzzzzzzzzzzzzzb
+Multa 250 zzzzzzzzzzzzzzzzzzzc
+Multa 251 zzzzzzzzzzzzzzzzzzzd
+Multa 252 zzzzzzzzzzzzzzzzzzze
+Multa 253 zzzzzzzzzzzzzzzzzzzf
+Multa 254 zzzzzzzzzzzzzzzzzzzg
+Multa 255 zzzzzzzzzzzzzzzzzzzh
+Multa 256 zzzzzzzzzzzzzzzzzzzi
+Multa 257 zzzzzzzzzzzzzzzzzzzj
+Multa 258 zzzzzzzzzzzzzzzzzzzk
+Multa 259 zzzzzzzzzzzzzzzzzzzl
+Multa 260 zzzzzzzzzzzzzzzzzzzm
+Multa 261 zzzzzzzzzzzzzzzzzzzn
+Multa 262 zzzzzzzzzzzzzzzzzzzo
+Multa 263 zzzzzzzzzzzzzzzzzzzp
+Multa 264 zzzzzzzzzzzzzzzzzzzq
+Multa 265 zzzzzzzzzzzzzzzzzzzr
+Multa 266 Zzzzzzzzzzzzzzzzzzzs
+Multa 267 Zzzzzzzzzzzzzzzzzzza
+Multa 268 zzzzzzzzzzzzzzzzzzzb
+Multa 269 zzzzzzzzzzzzzzzzzzzc
+Multa 270 zzzzzzzzzzzzzzzzzzzd
+Multa 271 zzzzzzzzzzzzzzzzzzze
+Multa 272 zzzzzzzzzzzzzzzzzzzf
+Multa 273 zzzzzzzzzzzzzzzzzzzg
+Multa 274 zzzzzzzzzzzzzzzzzzzh
+Multa 275 zzzzzzzzzzzzzzzzzzzi
+Multa 276 zzzzzzzzzzzzzzzzzzzj
+Multa 277 zzzzzzzzzzzzzzzzzzzk
+Multa 278 zzzzzzzzzzzzzzzzzzzl
+Multa 279 zzzzzzzzzzzzzzzzzzzm
+Multa 280 zzzzzzzzzzzzzzzzzzzn
+Multa 281 zzzzzzzzzzzzzzzzzzzo
+Multa 282 zzzzzzzzzzzzzzzzzzzp
+Multa 283 zzzzzzzzzzzzzzzzzzzq
+Multa 284 zzzzzzzzzzzzzzzzzzzr
+Multa 285 Zzzzzzzzzzzzzzzzzzzs
+Multa 286 Zzzzzzzzzzzzzzzzzzza
+Multa 287 zzzzzzzzzzzzzzzzzzzb
+Multa 288 zzzzzzzzzzzzzzzzzzzc
+Multa 289 zzzzzzzzzzzzzzzzzzzd
+Multa 290 zzzzzzzzzzzzzzzzzzze
+Multa 291 zzzzzzzzzzzzzzzzzzzf
+Multa 292 zzzzzzzzzzzzzzzzzzzg
+Multa 293 zzzzzzzzzzzzzzzzzzzh
+Multa 294 zzzzzzzzzzzzzzzzzzzi
+Multa 295 zzzzzzzzzzzzzzzzzzzj
+Multa 296 zzzzzzzzzzzzzzzzzzzk
+Multa 297 zzzzzzzzzzzzzzzzzzzl
+Multa 298 zzzzzzzzzzzzzzzzzzzm
+Multa 299 zzzzzzzzzzzzzzzzzzzn
+Multa 300 zzzzzzzzzzzzzzzzzzzo
+Multa 301 zzzzzzzzzzzzzzzzzzzp
+Multa 302 zzzzzzzzzzzzzzzzzzzq
+Multa 303 zzzzzzzzzzzzzzzzzzzr
+Multa 304 Zzzzzzzzzzzzzzzzzzzs
+Multa 305 Zzzzzzzzzzzzzzzzzzza
+Multa 306 zzzzzzzzzzzzzzzzzzzb
+Multa 307 zzzzzzzzzzzzzzzzzzzc
+Multa 308 zzzzzzzzzzzzzzzzzzzd
+Multa 309 zzzzzzzzzzzzzzzzzzze
+Multa 310 zzzzzzzzzzzzzzzzzzzf
+Multa 311 zzzzzzzzzzzzzzzzzzzg
+Multa 312 zzzzzzzzzzzzzzzzzzzh
+Multa 313 zzzzzzzzzzzzzzzzzzzi
+Multa 314 zzzzzzzzzzzzzzzzzzzj
+Multa 315 zzzzzzzzzzzzzzzzzzzk
+Multa 316 zzzzzzzzzzzzzzzzzzzl
+Multa 317 zzzzzzzzzzzzzzzzzzzm
+Multa 318 zzzzzzzzzzzzzzzzzzzn
+Multa 319 zzzzzzzzzzzzzzzzzzzo
+Multa 320 zzzzzzzzzzzzzzzzzzzp
+Multa 321 zzzzzzzzzzzzzzzzzzzq
+Multa 322 zzzzzzzzzzzzzzzzzzzr
+Multa 323 Zzzzzzzzzzzzzzzzzzzs
+Multa 324 Zzzzzzzzzzzzzzzzzzza
+Multa 325 zzzzzzzzzzzzzzzzzzzb
+Multa 326 zzzzzzzzzzzzzzzzzzzc
+Multa 327 zzzzzzzzzzzzzzzzzzzd
+Multa 328 zzzzzzzzzzzzzzzzzzze
+Multa 329 zzzzzzzzzzzzzzzzzzzf
+Multa 330 zzzzzzzzzzzzzzzzzzzg
+Multa 331 zzzzzzzzzzzzzzzzzzzh
+Multa 332 zzzzzzzzzzzzzzzzzzzi
+Multa 333 zzzzzzzzzzzzzzzzzzzj
+Multa 334 zzzzzzzzzzzzzzzzzzzk
+Multa 335 zzzzzzzzzzzzzzzzzzzl
+Multa 336 zzzzzzzzzzzzzzzzzzzm
+Multa 337 zzzzzzzzzzzzzzzzzzzn
+Multa 338 zzzzzzzzzzzzzzzzzzzo
+Multa 339 zzzzzzzzzzzzzzzzzzzp
+Multa 340 zzzzzzzzzzzzzzzzzzzq
+Multa 341 zzzzzzzzzzzzzzzzzzzr
+Multa 342 Zzzzzzzzzzzzzzzzzzzs
+Multa 343 Zzzzzzzzzzzzzzzzzzza
+Multa 344 zzzzzzzzzzzzzzzzzzzb
+Multa 345 zzzzzzzzzzzzzzzzzzzc
+Multa 346 zzzzzzzzzzzzzzzzzzzd
+Multa 347 zzzzzzzzzzzzzzzzzzze
+Multa 348 zzzzzzzzzzzzzzzzzzzf
+Multa 349 zzzzzzzzzzzzzzzzzzzg
+Multa 350 zzzzzzzzzzzzzzzzzzzh
+Multa 351 zzzzzzzzzzzzzzzzzzzi
+Multa 352 zzzzzzzzzzzzzzzzzzzj
+Multa 353 zzzzzzzzzzzzzzzzzzzk
+Multa 354 zzzzzzzzzzzzzzzzzzzl
+Multa 355 zzzzzzzzzzzzzzzzzzzm
+Multa 356 zzzzzzzzzzzzzzzzzzzn
+Multa 357 zzzzzzzzzzzzzzzzzzzo
+Multa 358 zzzzzzzzzzzzzzzzzzzp
+Multa 359 zzzzzzzzzzzzzzzzzzzq
+Multa 360 zzzzzzzzzzzzzzzzzzzr
+Multa 361 Zzzzzzzzzzzzzzzzzzzs
+Multa 362 Zzzzzzzzzzzzzzzzzzza
+Multa 363 zzzzzzzzzzzzzzzzzzzb
+Multa 364 zzzzzzzzzzzzzzzzzzzc
+Multa 365 zzzzzzzzzzzzzzzzzzzd
+Multa 366 zzzzzzzzzzzzzzzzzzze
+Multa 367 zzzzzzzzzzzzzzzzzzzf
+Multa 368 zzzzzzzzzzzzzzzzzzzg
+Multa 369 zzzzzzzzzzzzzzzzzzzh
+Multa 370 zzzzzzzzzzzzzzzzzzzi
+Multa 371 zzzzzzzzzzzzzzzzzzzj
+Multa 372 zzzzzzzzzzzzzzzzzzzk
+Multa 373 zzzzzzzzzzzzzzzzzzzl
+Multa 374 zzzzzzzzzzzzzzzzzzzm
+Multa 375 zzzzzzzzzzzzzzzzzzzn
+Multa 376 zzzzzzzzzzzzzzzzzzzo
+Multa 377 zzzzzzzzzzzzzzzzzzzp
+Multa 378 zzzzzzzzzzzzzzzzzzzq
+Multa 379 zzzzzzzzzzzzzzzzzzzr
+Multa 380 Zzzzzzzzzzzzzzzzzzzs
+Multa 381 Zzzzzzzzzzzzzzzzzzza carteira suspensa
+Multa 382 zzzzzzzzzzzzzzzzzzzb carteira suspensa
+Multa 383 zzzzzzzzzzzzzzzzzzzc carteira suspensa
+Multa 384 zzzzzzzzzzzzzzzzzzzd carteira suspensa
+Multa 385 zzzzzzzzzzzzzzzzzzze carteira suspensa
+Multa 386 zzzzzzzzzzzzzzzzzzzf carteira suspensa
+Multa 387 zzzzzzzzzzzzzzzzzzzg carteira suspensa
+Multa 388 zzzzzzzzzzzzzzzzzzzh carteira suspensa
+Multa 389 zzzzzzzzzzzzzzzzzzzi carteira suspensa
+Multa 390 zzzzzzzzzzzzzzzzzzzj carteira suspensa
+Multa 391 zzzzzzzzzzzzzzzzzzzk carteira suspensa
+Multa 392 zzzzzzzzzzzzzzzzzzzl carteira suspensa
+Multa 393 zzzzzzzzzzzzzzzzzzzm carteira suspensa
+Multa 394 zzzzzzzzzzzzzzzzzzzn carteira suspensa
+Multa 395 zzzzzzzzzzzzzzzzzzzo carteira suspensa
+Multa 396 zzzzzzzzzzzzzzzzzzzp carteira suspensa
+Multa 397 zzzzzzzzzzzzzzzzzzzq carteira suspensa
+Multa 398 zzzzzzzzzzzzzzzzzzzr carteira suspensa
+Multa 399 Zzzzzzzzzzzzzzzzzzzs carteira suspensa
+
+Familia 5
+Multa 1 a
+Multa 2 b
+Multa 3 c
+Multa 4 d
+Multa 5 e
+Multa 6 e
+Multa 7 d
+Multa 8 e
+Multa 9 c
+Multa 10 d
+Multa 11 e
+Multa 12 b
+Multa 13 c
+Multa 14 d
+Multa 15 e
+Multa 16 a
+Multa 17 b
+Multa 18 c
+Multa 19 d
+Multa 20 e
+
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..e69de29
diff --git a/old/C.compare b/old/C.compare
new file mode 100755
index 0000000..cc4c63b
--- /dev/null
+++ b/old/C.compare
@@ -0,0 +1,129 @@
+#!/bin/bash
+#//////////////////////////////////////////////////////////////////////////////////////////
+#//BOCA Online Contest Administrator. Copyright (c) 2003- Cassio Polpo de Campos.
+#//It may be distributed under the terms of the Q Public License version 1.0. A copy of the
+#//license can be found with this software or at http://www.opensource.org/licenses/qtpl.php
+#//
+#//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+#//INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+#//PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER
+#//OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR
+#//CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+#//PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+#//OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#///////////////////////////////////////////////////////////////////////////////////////////
+#Last modified: 31/oct/2011 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 languagename
+# $4 problemname
+# $5 problem_input
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# if there is an special checker, use it. It can be defined by an sol_output
+# which has .sh extension (which makes it be executed instead of compared to)
+# or by the existence of the file bocachecker.$4 in the execution path (here
+# $4 is in fact the short problename, which has to match with the spec in BOCA)
+schecker=
+if [ ${2: -3} == ".sh" ]; then
+ schecker=$2
+ chmod 755 "$schecker"
+else
+ if [ "$4" != "" ]; then
+ schecker=`which "bocachecker.$4"`
+ fi
+fi
+if [ -x "$schecker" ]; then
+ echo "Calling special checker $schecker"
+ "$schecker" "$@"
+ ret=$?
+ if [ "$ret" == "0" ]; then
+ echo "Checker answered YES"
+ exit 4
+ fi
+ if [ "$ret" == "1" ]; then
+ echo "Checker answered WRONG ANSWER"
+ exit 6
+ fi
+ if [ "$ret" == "2" ]; then
+ echo "Checker answered OUTPUT FORMAT ERROR"
+ exit 5
+ fi
+ echo "special checker returned unknown code"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/old/C.run b/old/C.run
new file mode 100755
index 0000000..6336c09
--- /dev/null
+++ b/old/C.run
@@ -0,0 +1,141 @@
+#!/bin/bash
+#//////////////////////////////////////////////////////////////////////////////////////////
+#//BOCA Online Contest Administrator. Copyright (c) 2003- Cassio Polpo de Campos.
+#//It may be distributed under the terms of the Q Public License version 1.0. A copy of the
+#//license can be found with this software or at http://www.opensource.org/licenses/qtpl.php
+#//
+#//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+#//INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+#//PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER
+#//OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR
+#//CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+#//PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+#//OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#///////////////////////////////////////////////////////////////////////////////////////////
+#Last modified: 17/oct/2011 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 base_filename
+# $2 source_file
+# $3 input_file
+# $4 languagename
+# $5 problemname
+# $6 timelimit
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened (according to safeexec):
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+gcc=`which gcc`
+[ -x "$gcc" ] || gcc=/usr/bin/gcc
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r $2 ]; then
+ echo "$2 not found or it's not readable"
+ exit 44
+fi
+if [ ! -r $3 ]; then
+ echo "$3 not found or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+if [ ! -x $gcc ]; then
+ echo "$gcc not found or it's not executable"
+ exit 47
+fi
+
+prefix=$1
+name=$2
+input=$3
+
+# setting up the timelimit according to the problem
+if [ "$6" == "" ]; then
+time=5
+else
+time=$6
+fi
+let ttime=$time+30
+
+$gcc -O2 -lm -o $prefix "$name"
+ret=$?
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit 1
+else
+ cdir=`pwd`
+ echo "Current directory is $cdir" >&2
+ echo $cdir | grep -q "/bocajail"
+ if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ cat < runit.sh
+#!/bin/bash
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+cd $cdir
+$sf -F10 -n0 -U$bocau -G$bocag -C. -ostdout0 -estderr0 -d512000 -m512000 -f20000 -t$time -T$ttime -i$input ./$prefix
+echo \$? > runit.retcode
+/bin/umount /proc 2>/dev/null
+#/bin/umount /dev
+/bin/umount /sys 2>/dev/null
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail $cdir/runit.sh
+ ret=`cat runit.retcode`
+ if [ "$ret" == "" ]; then
+ echo "Execution error - check autojudging"
+ exit 49
+ fi
+ else
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ $sf -F10 -n0 -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d512000000 -m512000000 -t$time -T$ttime -i$input ./$prefix
+ ret=$?
+ fi
+ if [ $ret -gt 10 ]; then
+ ret=0
+ fi
+fi
+if [ -f stdout0 ]; then
+ cat stdout0
+fi
+exit $ret
diff --git a/old/Cpp.compare b/old/Cpp.compare
new file mode 100755
index 0000000..cc4c63b
--- /dev/null
+++ b/old/Cpp.compare
@@ -0,0 +1,129 @@
+#!/bin/bash
+#//////////////////////////////////////////////////////////////////////////////////////////
+#//BOCA Online Contest Administrator. Copyright (c) 2003- Cassio Polpo de Campos.
+#//It may be distributed under the terms of the Q Public License version 1.0. A copy of the
+#//license can be found with this software or at http://www.opensource.org/licenses/qtpl.php
+#//
+#//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+#//INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+#//PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER
+#//OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR
+#//CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+#//PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+#//OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#///////////////////////////////////////////////////////////////////////////////////////////
+#Last modified: 31/oct/2011 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 languagename
+# $4 problemname
+# $5 problem_input
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# if there is an special checker, use it. It can be defined by an sol_output
+# which has .sh extension (which makes it be executed instead of compared to)
+# or by the existence of the file bocachecker.$4 in the execution path (here
+# $4 is in fact the short problename, which has to match with the spec in BOCA)
+schecker=
+if [ ${2: -3} == ".sh" ]; then
+ schecker=$2
+ chmod 755 "$schecker"
+else
+ if [ "$4" != "" ]; then
+ schecker=`which "bocachecker.$4"`
+ fi
+fi
+if [ -x "$schecker" ]; then
+ echo "Calling special checker $schecker"
+ "$schecker" "$@"
+ ret=$?
+ if [ "$ret" == "0" ]; then
+ echo "Checker answered YES"
+ exit 4
+ fi
+ if [ "$ret" == "1" ]; then
+ echo "Checker answered WRONG ANSWER"
+ exit 6
+ fi
+ if [ "$ret" == "2" ]; then
+ echo "Checker answered OUTPUT FORMAT ERROR"
+ exit 5
+ fi
+ echo "special checker returned unknown code"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/old/Cpp.run b/old/Cpp.run
new file mode 100755
index 0000000..6c6d7ea
--- /dev/null
+++ b/old/Cpp.run
@@ -0,0 +1,142 @@
+#!/bin/bash
+#//////////////////////////////////////////////////////////////////////////////////////////
+#//BOCA Online Contest Administrator. Copyright (c) 2003- Cassio Polpo de Campos.
+#//It may be distributed under the terms of the Q Public License version 1.0. A copy of the
+#//license can be found with this software or at http://www.opensource.org/licenses/qtpl.php
+#//
+#//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+#//INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+#//PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER
+#//OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR
+#//CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+#//PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+#//OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#///////////////////////////////////////////////////////////////////////////////////////////
+#Last modified: 17/oct/2011 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 base_filename
+# $2 source_file
+# $3 input_file
+# $4 languagename
+# $5 problemname
+# $6 timelimit
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened:
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+gpp=`which g++`
+[ -x "$gpp" ] || gcc=/usr/bin/g++
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r $2 ]; then
+ echo "$2 not found or it's not readable"
+ exit 44
+fi
+if [ ! -r $3 ]; then
+ echo "$3 not found or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+if [ ! -x $gpp ]; then
+ echo "$gpp not found or it's not executable"
+ exit 47
+fi
+
+prefix=$1
+name=$2
+input=$3
+
+# setting up the timelimit according to the problem
+# note that problems should spelling the same as inside BOCA
+if [ "$6" == "" ]; then
+time=5
+else
+time=$6
+fi
+let ttime=$time+30
+
+$gpp -O2 -lm -o $prefix "$name"
+ret=$?
+if [ "$ret" != "0" ]; then
+ echo "Compiling Error: $ret"
+ exit 1
+else
+ cdir=`pwd`
+ echo "Current directory is $cdir" >&2
+ echo $cdir | grep -q "/bocajail"
+ if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ cat < runit.sh
+#!/bin/bash
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+cd $cdir
+$sf -F10 -t$time -T$ttime -i$input -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d512000 -m512000 ./$prefix
+echo \$? > runit.retcode
+/bin/umount /proc 2>/dev/null
+#/bin/umount /dev
+/bin/umount /sys 2>/dev/null
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail $cdir/runit.sh
+ ret=`cat runit.retcode`
+ if [ "$ret" == "" ]; then
+ echo "Execution error - check autojudging"
+ exit 49
+ fi
+ else
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ $sf -F10 -n0 -C. -U$bocau -G$bocag -ostdout0 -estderr0 -d512000000 -m512000000 -t$time -T$ttime -i$input ./$prefix
+ ret=$?
+ fi
+ if [ $ret -gt 10 ]; then
+ ret=0
+ fi
+fi
+if [ -f stdout0 ]; then
+ cat stdout0
+fi
+exit $ret
diff --git a/old/Java.compare b/old/Java.compare
new file mode 100755
index 0000000..cc4c63b
--- /dev/null
+++ b/old/Java.compare
@@ -0,0 +1,129 @@
+#!/bin/bash
+#//////////////////////////////////////////////////////////////////////////////////////////
+#//BOCA Online Contest Administrator. Copyright (c) 2003- Cassio Polpo de Campos.
+#//It may be distributed under the terms of the Q Public License version 1.0. A copy of the
+#//license can be found with this software or at http://www.opensource.org/licenses/qtpl.php
+#//
+#//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+#//INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+#//PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER
+#//OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR
+#//CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+#//PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+#//OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#///////////////////////////////////////////////////////////////////////////////////////////
+#Last modified: 31/oct/2011 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 languagename
+# $4 problemname
+# $5 problem_input
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# if there is an special checker, use it. It can be defined by an sol_output
+# which has .sh extension (which makes it be executed instead of compared to)
+# or by the existence of the file bocachecker.$4 in the execution path (here
+# $4 is in fact the short problename, which has to match with the spec in BOCA)
+schecker=
+if [ ${2: -3} == ".sh" ]; then
+ schecker=$2
+ chmod 755 "$schecker"
+else
+ if [ "$4" != "" ]; then
+ schecker=`which "bocachecker.$4"`
+ fi
+fi
+if [ -x "$schecker" ]; then
+ echo "Calling special checker $schecker"
+ "$schecker" "$@"
+ ret=$?
+ if [ "$ret" == "0" ]; then
+ echo "Checker answered YES"
+ exit 4
+ fi
+ if [ "$ret" == "1" ]; then
+ echo "Checker answered WRONG ANSWER"
+ exit 6
+ fi
+ if [ "$ret" == "2" ]; then
+ echo "Checker answered OUTPUT FORMAT ERROR"
+ exit 5
+ fi
+ echo "special checker returned unknown code"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/old/Java.run b/old/Java.run
new file mode 100755
index 0000000..7708811
--- /dev/null
+++ b/old/Java.run
@@ -0,0 +1,160 @@
+#!/bin/bash
+#//////////////////////////////////////////////////////////////////////////////////////////
+#//BOCA Online Contest Administrator. Copyright (c) 2003- Cassio Polpo de Campos.
+#//It may be distributed under the terms of the Q Public License version 1.0. A copy of the
+#//license can be found with this software or at http://www.opensource.org/licenses/qtpl.php
+#//
+#//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+#//INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+#//PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER
+#//OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR
+#//CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+#//PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+#//OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#///////////////////////////////////////////////////////////////////////////////////////////
+#Last modified: 17/oct/2011 by cassio@ime.usp.br
+#
+# parameters are:
+# $1 base_filename
+# $2 source_file
+# $3 input_file
+# $4 languagename
+# $5 problemname
+# $6 timelimit
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened:
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# 4 internal error
+# 5 parameter error
+# 6 internal error
+# 7 memory limit exceeded
+# 8 security threat
+# 9 runtime error
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+id -u bocajail >/dev/null 2>/dev/null
+if [ $? == 0 ]; then
+ bocau=`id -u bocajail`
+ bocag=`id -g bocajail`
+ chown bocajail.nogroup .
+else
+ bocau=`id -u nobody`
+ bocag=`id -g nobody`
+ chown nobody.nogroup .
+fi
+if [ "$bocau" == "" -o "$bocag" == "" ]; then
+ echo "error finding user to run script"
+ exit 43
+fi
+
+export CLASSPATH=.:$CLASSPATH
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+java=`which java`
+[ -x "$java" ] || java=/usr/java/bin/java
+javac=`which javac`
+[ -x "$javac" ] || javac=/usr/java/bin/javac
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r $2 ]; then
+ echo "$2 not found or it's not readable"
+ exit 44
+fi
+if [ ! -r $3 ]; then
+ echo "$3 not found or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+if [ ! -x $java ]; then
+ echo "$java not found or it's not executable"
+ exit 47
+fi
+if [ ! -x $javac ]; then
+ echo "$javac not found or it's not executable"
+ exit 47
+fi
+
+prefix=$1
+name=$2
+input=$3
+
+# setting up the timelimit according to the problem
+# note that problems should spelling the same as inside BOCA
+if [ "$6" == "" ]; then
+time=5
+else
+time=$6
+fi
+let ttime=$time+30
+
+$javac "$name"
+ret=$?
+if [ "$ret" != "0" ]; then
+ echo "Compilation Error: $ret"
+ exit 1
+else
+ if [ ! -f "$prefix.class" ]; then
+ echo "Class file $prefix.class not generated - possible name mismatch"
+ exit 48
+ fi
+ cdir=`pwd`
+ echo "Current directory is $cdir" >&2
+ echo $cdir | grep -q "/bocajail"
+ if [ $? == 0 ]; then
+ cdir=`echo $cdir | sed "s/.*\/bocajail//"`
+ cat < runit.sh
+#!/bin/bash
+[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
+#/bin/mount --bind /dev /dev
+[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
+cd $cdir
+$sf -t$time -T$ttime -i$input -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d1000000 -m1000000 -- $java -Xmx512M -Xms512M $prefix
+echo \$? > runit.retcode
+/bin/umount /proc 2>/dev/null
+#/bin/umount /dev
+/bin/umount /sys 2>/dev/null
+EOF
+ chmod 755 runit.sh
+ chroot /bocajail $cdir/runit.sh
+ ret=`cat runit.retcode`
+ if [ "$ret" == "" ]; then
+ echo "Execution error - check autojudging"
+ exit 49
+ fi
+ if [ $ret -gt 10 ]; then
+ echo "> > > > > > > Nonzero return code - possible runtime error - GUESSING IT IS RUNTIME ERROR! < < < < < < < <"
+ exit 9
+ fi
+ else
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+# $java $prefix < $input
+ $sf -t$time -T$ttime -i$input -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d900000000 -m900000000 -- $java -Xmx512M -Xms512M $prefix
+ ret=$?
+ fi
+ if [ $ret -gt 10 ]; then
+ echo "> > > > > > > Nonzero return code - possible runtime error - GUESSING IT IS RUNTIME ERROR! < < < < < < < <"
+ ret=9
+ fi
+fi
+if [ -f stdout0 ]; then
+ cat stdout0
+fi
+exit $ret
diff --git a/old/Pascal.compare b/old/Pascal.compare
new file mode 100755
index 0000000..cc4c63b
--- /dev/null
+++ b/old/Pascal.compare
@@ -0,0 +1,129 @@
+#!/bin/bash
+#//////////////////////////////////////////////////////////////////////////////////////////
+#//BOCA Online Contest Administrator. Copyright (c) 2003- Cassio Polpo de Campos.
+#//It may be distributed under the terms of the Q Public License version 1.0. A copy of the
+#//license can be found with this software or at http://www.opensource.org/licenses/qtpl.php
+#//
+#//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+#//INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+#//PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER
+#//OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR
+#//CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+#//PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+#//OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#///////////////////////////////////////////////////////////////////////////////////////////
+#Last modified: 31/oct/2011 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 languagename
+# $4 problemname
+# $5 problem_input
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# if there is an special checker, use it. It can be defined by an sol_output
+# which has .sh extension (which makes it be executed instead of compared to)
+# or by the existence of the file bocachecker.$4 in the execution path (here
+# $4 is in fact the short problename, which has to match with the spec in BOCA)
+schecker=
+if [ ${2: -3} == ".sh" ]; then
+ schecker=$2
+ chmod 755 "$schecker"
+else
+ if [ "$4" != "" ]; then
+ schecker=`which "bocachecker.$4"`
+ fi
+fi
+if [ -x "$schecker" ]; then
+ echo "Calling special checker $schecker"
+ "$schecker" "$@"
+ ret=$?
+ if [ "$ret" == "0" ]; then
+ echo "Checker answered YES"
+ exit 4
+ fi
+ if [ "$ret" == "1" ]; then
+ echo "Checker answered WRONG ANSWER"
+ exit 6
+ fi
+ if [ "$ret" == "2" ]; then
+ echo "Checker answered OUTPUT FORMAT ERROR"
+ exit 5
+ fi
+ echo "special checker returned unknown code"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/old/Pascal.run b/old/Pascal.run
new file mode 100755
index 0000000..df98e41
--- /dev/null
+++ b/old/Pascal.run
@@ -0,0 +1,107 @@
+#!/bin/bash
+#//////////////////////////////////////////////////////////////////////////////////////////
+#//BOCA Online Contest Administrator. Copyright (c) 2003- Cassio Polpo de Campos.
+#//It may be distributed under the terms of the Q Public License version 1.0. A copy of the
+#//license can be found with this software or at http://www.opensource.org/licenses/qtpl.php
+#//
+#//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+#//INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+#//PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER
+#//OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR
+#//CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+#//PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+#//OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#///////////////////////////////////////////////////////////////////////////////////////////
+#Last modified: 25/may/2010 by cassiopc
+#
+# parameters are:
+# $1 base_filename
+# $2 source_file
+# $3 input_file
+# $4 languagename
+# $5 problemname
+# $6 timelimit
+#
+# the output of the submission should be directed to the standard output
+#
+# the return code show what happened:
+# 0 ok
+# 1 compile error
+# 2 runtime error
+# 3 timelimit exceeded
+# other_codes are unknown to boca: in this case BOCA will present the
+# last line of standard output to the judge
+
+umask 0022
+chown nobody.nogroup .
+
+# this script makes use of safeexec to execute the code with less privilegies
+# make sure that directories below are correct.
+grep=`which grep`
+[ -x "$grep" ] || grep=/bin/grep
+sf=`which safeexec`
+[ -x "$sf" ] || sf=/usr/bin/safeexec
+pascal=`which fpc`
+[ -x "$pascal" ] || pascal=/usr/bin/fpc
+
+if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
+ echo "parameter problem"
+ exit 43
+fi
+if [ ! -r $2 ]; then
+ echo "$2 not found or it's not readable"
+ exit 44
+fi
+if [ ! -r $3 ]; then
+ echo "$3 not found or it's not readable"
+ exit 45
+fi
+if [ ! -x $sf ]; then
+ echo "$sf not found or it's not executable"
+ exit 46
+fi
+if [ ! -x $pascal ]; then
+ echo "$pascal not found or it's not executable"
+ exit 47
+fi
+
+prefix=$1
+name=$2
+input=$3
+
+# setting up the timelimit according to the problem
+# note that problems should spelling the same as inside BOCA
+if [ "$6" == "" ]; then
+time=5
+else
+time=$6
+fi
+let ttime=$time+30
+
+$pascal -o$prefix $name >compiler.out 2>compiler.out
+$grep -irq linking compiler.out
+ret=$?
+$grep -irq "lines compiled" compiler.out
+ret2=$?
+if [ "$ret" != "0" -o "$ret2" != "0" ]; then
+ cat compiler.out
+ echo "Compiling Error: $ret"
+ exit 1
+else
+ $sf -F10 -t$time -T$ttime -i$input -opascal.out -n0 -R. ./$prefix
+ ret=$?
+ if [ -f pascal.out ]; then
+ cat pascal.out
+ $grep -irq "runtime error" pascal.out
+ ret2=$?
+ if [ "$ret2" = "0" ]; then
+ echo "Strange output - possible runtime error"
+ if [ $ret -lt 4 ]; then
+ ret=48
+ fi
+ fi
+ else
+ echo "Output file not found - possible runtime error"
+ fi
+fi
+exit $ret
diff --git a/old/compare.sh b/old/compare.sh
new file mode 100755
index 0000000..cc4c63b
--- /dev/null
+++ b/old/compare.sh
@@ -0,0 +1,129 @@
+#!/bin/bash
+#//////////////////////////////////////////////////////////////////////////////////////////
+#//BOCA Online Contest Administrator. Copyright (c) 2003- Cassio Polpo de Campos.
+#//It may be distributed under the terms of the Q Public License version 1.0. A copy of the
+#//license can be found with this software or at http://www.opensource.org/licenses/qtpl.php
+#//
+#//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+#//INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+#//PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER
+#//OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR
+#//CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+#//PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+#//OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#///////////////////////////////////////////////////////////////////////////////////////////
+#Last modified: 31/oct/2011 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 languagename
+# $4 problemname
+# $5 problem_input
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# if there is an special checker, use it. It can be defined by an sol_output
+# which has .sh extension (which makes it be executed instead of compared to)
+# or by the existence of the file bocachecker.$4 in the execution path (here
+# $4 is in fact the short problename, which has to match with the spec in BOCA)
+schecker=
+if [ ${2: -3} == ".sh" ]; then
+ schecker=$2
+ chmod 755 "$schecker"
+else
+ if [ "$4" != "" ]; then
+ schecker=`which "bocachecker.$4"`
+ fi
+fi
+if [ -x "$schecker" ]; then
+ echo "Calling special checker $schecker"
+ "$schecker" "$@"
+ ret=$?
+ if [ "$ret" == "0" ]; then
+ echo "Checker answered YES"
+ exit 4
+ fi
+ if [ "$ret" == "1" ]; then
+ echo "Checker answered WRONG ANSWER"
+ exit 6
+ fi
+ if [ "$ret" == "2" ]; then
+ echo "Checker answered OUTPUT FORMAT ERROR"
+ exit 5
+ fi
+ echo "special checker returned unknown code"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6
diff --git a/old/connect.php b/old/connect.php
new file mode 100644
index 0000000..1ee33da
--- /dev/null
+++ b/old/connect.php
@@ -0,0 +1,44 @@
+ $ct["contestmaxfilesize"] || strlen($name)>100 || strlen($name)<1) {
+ LOGLevel("User {$_SESSION["usertable"]["username"]} tried to submit file " .
+ ":${name}: with $size bytes.", 1);
+ MSGError("File size exceeds the limit allowed or invalid name.");
+} else
+
+ DBNewBkp ($_SESSION["usertable"]["contestnumber"],
+ $_SESSION["usertable"]["usersitenumber"],
+ $_SESSION["usertable"]["usernumber"],
+ $name,
+ $fn, $size);
+@unlink($fn);
+ForceLoad("../index.php");
+?>
diff --git a/old/create-import-file.sh b/old/create-import-file.sh
new file mode 100755
index 0000000..0d3ca9e
--- /dev/null
+++ b/old/create-import-file.sh
@@ -0,0 +1,197 @@
+#!/bin/bash
+# Copyright (c) 2007- C. P. de Campos (cassio@ime.usp.br). All rights reserved.
+# Licensed under Q Public License version 1.0. See http://www.opensource.org/licenses/qtpl.php
+
+for i in /usr/bin/cut /bin/cat /bin/date /usr/bin/basename /bin/true /usr/bin/uuencode /usr/bin/wc /usr/bin/tail; do
+ if [ ! -x $i ]; then
+ echo "$i not found. Aborting"
+ exit 1
+ fi
+done
+
+if [ "$1" == "" -o "$2" == "" -o ! -d "$2" -o ! -r "$2" ]; then
+ echo "Usage $0 "
+ echo "filename will be overwritten."
+ echo "directory must contain the following files:"
+ echo " *.run: where * is a language name."
+ echo " *.compare: where * is a language name."
+ echo " *.in: where * is a problem name."
+ echo " *.out: where * is a problem name."
+ echo " *.pdf: where * is a problem name."
+ echo " For better compatibility, use only letters in filenames (avoid spaces, symbols, etc)."
+ exit 1
+fi
+file=$1
+dir=$2
+
+d=`/bin/date +%s`
+endmark=endmark$d
+
+echo -n "Enter the contest name: "
+read name
+
+echo -n "Enter your site name: "
+read site
+
+st=$d
+while /bin/true; do
+ echo -n "Enter starting date (format complying with /bin/date. For example, '12/25/2007 13:34'): "
+ read data
+ st=`/bin/date -d "$data" +%s`
+ if [ $? == 0 ]; then
+ break
+ fi
+done
+
+echo "Creating contest, site and answer sections"
+/bin/cat << EOFEOF > $file
+$endmark
+
+[contest]
+contestname=$name
+scorelevel=4
+sitename=$site
+startdate=$st
+
+[site]
+
+[answer]
+answernumber=1
+answername=NO - Compile error
+answeryes=f
+
+answernumber=2
+answername=NO - Runtime error
+answeryes=f
+
+answernumber=3
+answername=NO - Time limit exceeded
+answeryes=f
+
+answernumber=4
+answername=YES
+answeryes=t
+
+answernumber=5
+answername=NO - Presentation error
+answeryes=f
+
+answernumber=6
+answername=NO - Wrong answer
+answeryes=f
+
+answernumber=7
+answername=NO - Contact staff
+answeryes=f
+
+answernumber=8
+answername=NO - Problem/File name mismatch
+answeryes=f
+
+EOFEOF
+
+echo "Creating language section"
+echo "[language]" >> $file
+
+j=1
+for i in $dir/*.run ; do
+ lang=`/usr/bin/basename "$i" .run`
+ echo "Creating $lang"
+ mds=`/usr/bin/md5sum $i | /usr/bin/cut -d" " -f1`
+ mdc=`/usr/bin/md5sum $dir/$lang.compare | /usr/bin/cut -d" " -f1`
+
+ echo -n "Enter language name: "
+ read name
+
+ /usr/bin/uuencode -m x < $dir/$lang.run > $file.tmp
+ lin=`/usr/bin/wc -l $file.tmp | /usr/bin/cut -d" " -f1`
+ let lin="$lin - 1"
+
+ /bin/cat << EOFEOF >> $file
+langnumber=$j
+langname=$name
+langscriptmd5=$mds
+langcompscriptmd5=$mdc
+langscript=base64:$lang.run
+EOFEOF
+ /usr/bin/tail -n $lin $file.tmp >> $file
+ echo "***${endmark}***" >> $file
+
+ /usr/bin/uuencode -m x < $dir/$lang.compare > $file.tmp
+ lin=`/usr/bin/wc -l $file.tmp | /usr/bin/cut -d" " -f1`
+ let lin="$lin - 1"
+ echo "langcompscript=base64:$lang.compare" >> $file
+ /usr/bin/tail -n $lin $file.tmp >> $file
+ echo "***${endmark}***" >> $file
+
+ echo "" >> $file
+ let j="$j + 1"
+done
+
+echo "Creating problem section"
+echo "[problem]" >> $file
+letters="A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
+
+j=1
+for i in $dir/*.out ; do
+ prob=`/usr/bin/basename "$i" .out`
+ letter=`echo $letters | /usr/bin/cut -d" " -f$j`
+ echo "Creating problem $letter (basename=$prob)"
+
+ echo -n "Enter full name: "
+ read full
+ echo -n "Enter time limit: "
+ read tl
+ echo -n "Enter Color name: "
+ read cn
+ echo -n "Enter Color (html RGB format): "
+ read rgb
+
+ /bin/cat << EOFEOF >> $file
+probnumber=$j
+probname=$letter
+probfullname=$full
+probbasename=$prob
+probtimelimit=$tl
+probcolorname=$cn
+probcolor=$rgb
+EOFEOF
+
+ if [ -r $dir/$prob.in ]; then
+ mds=`/usr/bin/md5sum $dir/$prob.in | /usr/bin/cut -d" " -f1`
+ echo "probinputfilemd5=$mds" >> $file
+ echo "probinputfile=base64:$prob.in" >> $file
+ /usr/bin/uuencode -m x < $dir/$prob.in > $file.tmp
+ lin=`/usr/bin/wc -l $file.tmp | /usr/bin/cut -d" " -f1`
+ let lin="$lin - 1"
+ /usr/bin/tail -n $lin $file.tmp >> $file
+ echo "***${endmark}***" >> $file
+ fi
+ if [ -r $dir/$prob.out ]; then
+ mds=`/usr/bin/md5sum $dir/$prob.out | /usr/bin/cut -d" " -f1`
+ echo "probsolfilemd5=$mds" >> $file
+ echo "probsolfile=base64:$prob.out" >> $file
+ /usr/bin/uuencode -m x < $dir/$prob.out > $file.tmp
+ lin=`/usr/bin/wc -l $file.tmp | /usr/bin/cut -d" " -f1`
+ let lin="$lin - 1"
+ /usr/bin/tail -n $lin $file.tmp >> $file
+ echo "***${endmark}***" >> $file
+ fi
+ if [ -r $dir/$prob.pdf ]; then
+ mds=`/usr/bin/md5sum $dir/$prob.pdf | /usr/bin/cut -d" " -f1`
+ echo "probdescfilemd5=$mds" >> $file
+ echo "probdescfile=base64:$prob.pdf" >> $file
+ /usr/bin/uuencode -m x < $dir/$prob.pdf > $file.tmp
+ lin=`/usr/bin/wc -l $file.tmp | /usr/bin/cut -d" " -f1`
+ let lin="$lin - 1"
+ /usr/bin/tail -n $lin $file.tmp >> $file
+ echo "***${endmark}***" >> $file
+ fi
+
+ echo "" >> $file
+ let j="$j + 1"
+done
+
+echo "[end]" >> $file
+rm -f $file.tmp
+echo "Done."
diff --git a/old/getextdata.old b/old/getextdata.old
new file mode 100644
index 0000000..7c9955d
--- /dev/null
+++ b/old/getextdata.old
@@ -0,0 +1,931 @@
+$aqui["updatetime"])
+ $situacao[$j]="atualizar";
+ else
+ $situacao[$j]="ok";
+ break;
+ }
+ }
+ if ($k>=$nn) $situacao[$j]="inserir";
+ }
+ $del=0; $upd=0; $ins=0;
+ for ($k=0; $k<$nn; $k++) {
+ $atual = DBRow($rr, $k);
+ if (!$needed[$k]) {
+ DBExec($c, "delete from answertable where contestnumber=$contest and answernumber=".$atual["answernumber"]);
+ $del++;
+ }
+ }
+ for ($j=0;$j<$n;$j++) {
+ $atual = DBRow($r,$j);
+ if ($atual["updatetime"]=="") $atual["updatetime"]=time();
+ if ($situacao[$j]=="atualizar") {
+ $upd++;
+ DBExec ($c, "update answertable set ".
+ "runanswer='".$atual["runanswer"]."',".
+ "yes='".$atual["yes"]."',".
+ "fake='".$atual["fake"]."',".
+ "updatetime=".$atual["updatetime"].
+ " where contestnumber=$contest and answernumber=".$atual["answernumber"].
+ " and updatetime<".$atual["updatetime"]);
+ } else if ($situacao[$j]=="inserir") {
+ $ins++;
+ DBExec($c,"insert into answertable (contestnumber, answernumber, runanswer, yes, fake, updatetime) values (" .
+ $contest.",".$atual["answernumber"].",'".$atual["runanswer"]."','".$atual["yes"]."',".
+ "'".$atual["fake"]."',".$atual["updatetime"].")");
+ }
+ }
+ echo " deletions=$del, updates=$upd, insertions=$ins\n\n";
+
+ // sincronizando languages
+ $r = DBExec ($t, "select * from langtable where contestnumber=$contest");
+ $rr = DBExec ($c, "select * from langtable where contestnumber=$contest for update");
+ $n = DBnLines ($r);
+ $nn = DBnLines ($rr);
+ echo "languages: external(site=$mainsite, reading=$mainsite)=$n, local=$nn\n";
+ for ($k=0; $k<$nn; $k++) $needed[$k]=false;
+ for ($j=0;$j<$n;$j++) {
+ $la = DBRow($r,$j);
+ for ($k=0; $k<$nn; $k++) {
+ $aqui = DBRow($rr,$k);
+ if ($la["langnumber"]==$aqui["langnumber"] && $la["contestnumber"]==$aqui["contestnumber"]) {
+ $needed[$k]=true;
+ if ($la["updatetime"]>$aqui["updatetime"])
+ $situacao[$j]="atualizar";
+ else
+ $situacao[$j]="ok";
+ break;
+ }
+ }
+ if ($k>=$nn) $situacao[$j]="inserir";
+ }
+ $del=0; $upd=0; $ins=0;
+ for ($k=0; $k<$nn; $k++) {
+ $atual = DBRow($rr, $k);
+ if (!$needed[$k]) {
+ DBExec($c, "delete from langtable where contestnumber=$contest and langnumber=".$atual["langnumber"]);
+ $del++;
+ }
+ }
+ for ($j=0;$j<$n;$j++) {
+ $atual = DBRow($r,$j);
+ if ($atual["updatetime"]=="") $atual["updatetime"]=time();
+ if ($situacao[$j]=="atualizar") {
+ $upd++;
+ DBExec ($c, "update langtable set ".
+ "langname='".escape_string($atual["langname"])."',".
+ "updatetime=".$atual["updatetime"].
+ " where contestnumber=$contest and langnumber=".$atual["langnumber"].
+ " and updatetime<".$atual["updatetime"]);
+ } else if ($situacao[$j]=="inserir") {
+ $ins++;
+ DBExec($c,"insert into langtable (contestnumber, langnumber, langname, updatetime) values ($contest,".$atual["langnumber"].
+ ",'".escape_string($atual["langname"])."',".$atual["updatetime"].")");
+ }
+ }
+ echo " deletions=$del, updates=$upd, insertions=$ins\n\n";
+
+ // sincronizando problems
+ $r = DBExec ($t, "select * from problemtable where contestnumber=$contest");
+ $rr = DBExec ($c, "select * from problemtable where contestnumber=$contest for update");
+ $n = DBnLines ($r);
+ $nn = DBnLines ($rr);
+ echo "problems: external(site=$mainsite, reading=$mainsite)=$n, local=$nn\n";
+ for ($k=0; $k<$nn; $k++) $needed[$k]=false;
+ for ($j=0;$j<$n;$j++) {
+ $la = DBRow($r,$j);
+ for ($k=0; $k<$nn; $k++) {
+ $aqui = DBRow($rr,$k);
+ if ($la["problemnumber"]==$aqui["problemnumber"] && $la["contestnumber"]==$aqui["contestnumber"]) {
+ $needed[$k]=true;
+ if ($la["updatetime"]>$aqui["updatetime"])
+ $situacao[$j]="atualizar";
+ else
+ $situacao[$j]="ok";
+ break;
+ }
+ }
+ if ($k>=$nn) $situacao[$j]="inserir";
+ }
+ $del=0; $upd=0; $ins=0;
+ for ($k=0; $k<$nn; $k++) {
+ $atual = DBRow($rr, $k);
+ if (!$needed[$k]) {
+ DBExec($c, "delete from problemtable where contestnumber=$contest and problemnumber=".$atual["problemnumber"]);
+ $del++;
+ }
+ }
+ for ($j=0;$j<$n;$j++) {
+ $atual = DBRow($r,$j);
+ if ($atual["updatetime"]=="") $atual["updatetime"]=time();
+ if ($situacao[$j]=="inserir") {
+ $ins++; $upd--;
+ DBExec($c,"insert into problemtable (contestnumber, problemnumber, problemname, updatetime) values ($contest,".
+ $atual["problemnumber"].",'".escape_string($atual["problemname"])."', 0)");
+ }
+ if ($situacao[$j]=="atualizar" || $situacao[$j]=="inserir") {
+ $upd++;
+ $p = DBRow($r2, 0);
+ if ($p["probleminputfile"]>0) DB_lo_unlink($c, $p["probleminputfile"]);
+ if ($p["problemsolfile"]>0) DB_lo_unlink($c, $p["problemsolfile"]);
+ DBExec($t, "begin work");
+ if ($atual["probleminputfile"]=="") $inputfile="null";
+ else {
+ $in = DB_lo_open($t, $atual["probleminputfile"], "r");
+ if (!$in) $inputfile="null";
+ else {
+ $inputfile = DB_lo_create ($c);
+ $out = DB_lo_open ($c, $inputfile, "w");
+ while (($buf = DB_lo_read ($in, 100000)) != false)
+ DB_lo_write ($out, $buf);
+ DB_lo_close ($out);
+ DB_lo_close ($in);
+ }
+ }
+ if ($atual["problemsolfile"]=="") $solfile="null";
+ else {
+ $in = DB_lo_open($t, $atual["problemsolfile"], "r");
+ if (!$in) $solfile="null";
+ else {
+ $solfile = DB_lo_create ($c);
+ $out = DB_lo_open ($c, $solfile, "w");
+ while (($buf = DB_lo_read ($in, 100000)) != false)
+ DB_lo_write ($out, $buf);
+ DB_lo_close ($out);
+ DB_lo_close ($in);
+ }
+ }
+ DBExec ($t, "commit work");
+
+ DBExec ($c, "update problemtable set ".
+ "problemname='".escape_string($atual["problemname"])."',".
+ "problemfullname='".escape_string($atual["problemfullname"])."',".
+ "problembasefilename='".escape_string($atual["problembasefilename"])."',".
+ "probleminputfilename='".escape_string($atual["probleminputfilename"])."',".
+ "problemsolfilename='".escape_string($atual["problemsolfilename"])."',".
+ "fake='".$atual["fake"]."',".
+ "probleminputfile=".$inputfile.",".
+ "problemsolfile=".$solfile.",".
+ "updatetime=".$atual["updatetime"].
+ " where contestnumber=$contest and problemnumber=".$atual["problemnumber"].
+ " and updatetime<".$atual["updatetime"]);
+ }
+ }
+ echo " deletions=$del, updates=$upd, insertions=$ins\n\n";
+ DBExec($c, "commit work");
+ }
+
+ }
+
+ $r = DBExec ($c, "select * from sitetable where contestnumber=$contest");
+ $n = DBnlines($r);
+ if ($n == 0) {
+ echo "Unable to find sites in the database.\n";
+ exit;
+ }
+ $st = array();
+ for ($i=0;$i<$n;$i++) {
+ $st[$i] = DBRow($r,$i);
+ }
+
+ for ($i=0; $i$aqui["updatetime"])
+ $situacao[$j]="atualizar";
+ else
+ $situacao[$j]="ok";
+ break;
+ }
+ }
+ if ($k>=$nn) $situacao[$j]="inserir";
+ }
+ $del=0;
+ for ($k=0; $k<$nn; $k++) {
+ $atual = DBRow($rr, $k);
+ if (!$needed[$k]) {
+ DBExec($c, "delete from usertable where contestnumber=$contest and usersitenumber=$site and usernumber=".
+ $atual["usernumber"]);
+ $del++;
+ }
+ }
+ $upd=0; $ins=0;
+ for ($j=0;$j<$n;$j++) {
+ $atual = DBRow($r,$j);
+ if ($atual["userlastlogin"]=="") $atual["userlastlogin"]="null";
+ if ($atual["userlastlogout"]=="") $atual["userlastlogout"]="null";
+ if ($atual["updatetime"]=="") $atual["updatetime"]=time();
+ if ($situacao[$j]=="atualizar") {
+ DBExec ($c, "update usertable set ".
+ "username='".escape_string($atual["username"])."',".
+ "userfullname='".escape_string($atual["userfullname"])."',".
+ "userdesc='".escape_string($atual["userdesc"])."',".
+ "usertype='".escape_string($atual["usertype"])."',".
+ "userenabled='".$atual["userenabled"]."',".
+ "usermultilogin='".$atual["usermultilogin"]."',".
+ "userpassword='".$atual["userpassword"]."',".
+ "userip='".$atual["userip"]."',".
+ "userlastlogin=".$atual["userlastlogin"].",".
+ "userlastlogout=".$atual["userlastlogout"].",".
+ "usersession='".$atual["usersession"]."',".
+ "userpermitip='".$atual["userpermitip"]."',".
+ "updatetime=".$atual["updatetime"].
+ " where contestnumber=$contest and usersitenumber=".$atual["usersitenumber"].
+ " and usernumber=".$atual["usernumber"]." and updatetime<".$atual["updatetime"]);
+ $upd++;
+ } else if ($situacao[$j]=="inserir") {
+ DBExec ($c, "insert into usertable (username, userfullname, userdesc, usertype, userenabled, usermultilogin, ".
+ "userpassword, userip, userlastlogin, userlastlogout, usersession, userpermitip, updatetime, ".
+ "contestnumber, usersitenumber, usernumber) values (".
+ "'".escape_string($atual["username"])."',".
+ "'".escape_string($atual["userfullname"])."',".
+ "'".escape_string($atual["userdesc"])."',".
+ "'".$atual["usertype"]."',".
+ "'".$atual["userenabled"]."',".
+ "'".$atual["usermultilogin"]."',".
+ "'".$atual["userpassword"]."',".
+ "'".$atual["userip"]."',".
+ $atual["userlastlogin"].",".
+ $atual["userlastlogout"].",".
+ "'".$atual["usersession"]."',".
+ "'".$atual["userpermitip"]."',".
+ $atual["updatetime"].",$contest,".$atual["usersitenumber"].",".$atual["usernumber"].")");
+ $ins++;
+ }
+ }
+ echo " deletions=$del, updates=$upd, insertions=$ins\n\n";
+
+ // sincronizando clars
+ $r = DBExec ($t, "select * from clartable where contestnumber=$contest and clarsitenumber=$site");
+ $rr = DBExec ($c, "select * from clartable where contestnumber=$contest and clarsitenumber=$site");
+ $n = DBnLines ($r);
+ $nn = DBnLines ($rr);
+ echo "clars: external(site=$site, reading=$site)=$n, local=$nn\n";
+ for ($k=0; $k<$nn; $k++) $needed[$k]=false;
+ for ($j=0;$j<$n;$j++) {
+ $la = DBRow($r,$j);
+ for ($k=0; $k<$nn; $k++) {
+ $aqui = DBRow($rr,$k);
+ if ($la["clarnumber"]==$aqui["clarnumber"] && $la["contestnumber"]==$aqui["contestnumber"] &&
+ $la["clarsitenumber"]==$aqui["clarsitenumber"]) {
+ $needed[$k]=true;
+ if ($la["updatetime"]>$aqui["updatetime"])
+ $situacao[$j]="atualizar";
+ else
+ $situacao[$j]="ok";
+ break;
+ }
+ }
+ if ($k>=$nn) $situacao[$j]="inserir";
+ }
+ $del=0;
+ for ($k=0; $k<$nn; $k++) {
+ $atual = DBRow($rr, $k);
+ if (!$needed[$k]) {
+ DBExec($c, "delete from clartable where contestnumber=$contest and clarsitenumber=$site and clarnumber=".
+ $atual["clarnumber"]);
+ $del++;
+ }
+ }
+ $upd=0; $ins=0;
+ for ($j=0;$j<$n;$j++) {
+ $atual = DBRow($r,$j);
+ if ($atual["claranswer"]=="") $atual["claranswer"]="null";
+ else $atual["claranswer"]="'".escape_string($atual["claranswer"])."'";
+ if ($atual["clarjudge"]=="") $atual["clarjudge"]="null";
+ if ($atual["clarjudgesite"]=="") $atual["clarjudgesite"]="null";
+ if ($atual["updatetime"]=="") $atual["updatetime"]=time();
+ if ($situacao[$j]=="atualizar") {
+ DBExec ($c, "update clartable set ".
+ "usernumber=".$atual["usernumber"].",".
+ "clardate=".$atual["clardate"].",".
+ "clardatediff=".$atual["clardatediff"].",".
+ "clardatediffans=".$atual["clardatediffans"].",".
+ "clarproblem=".$atual["clarproblem"].",".
+ "clardata='".escape_string($atual["clardata"])."',".
+ "claranswer=".$atual["claranswer"].",".
+ "clarstatus='".escape_string($atual["clarstatus"])."',".
+ "clarjudge=".$atual["clarjudge"].",".
+ "clarjudgesite=".$atual["clarjudgesite"].",".
+ "updatetime=".$atual["updatetime"].
+ " where contestnumber=$contest and clarsitenumber=".$atual["clarsitenumber"].
+ " and clarnumber=".$atual["clarnumber"]." and updatetime<".$atual["updatetime"]);
+ $upd++;
+ } else if($situacao[$j]=="inserir") {
+ DBExec ($c, "insert into clartable (contestnumber, clarsitenumber, clarnumber, usernumber, clardate,".
+ "clardatediff, clardatediffans, clarproblem, clardata, claranswer, clarstatus, clarjudge, clarjudgesite, updatetime) ".
+ "values (".$contest.",".$atual["clarsitenumber"].",".$atual["clarnumber"].",".$atual["usernumber"].",".
+ $atual["clardate"].",".
+ $atual["clardatediff"].",".
+ $atual["clardatediffans"].",".
+ $atual["clarproblem"].",".
+ "'".escape_string($atual["clardata"])."',".
+ $atual["claranswer"].",".
+ "'".escape_string($atual["clarstatus"])."',".
+ $atual["clarjudge"].",".
+ $atual["clarjudgesite"].",".
+ $atual["updatetime"].")");
+ $ins++;
+ }
+ }
+ echo " deletions=$del, updates=$upd, insertions=$ins\n\n";
+
+ // sincronizando clars
+ $r = DBExec ($t, "select * from clartable where contestnumber=$contest and clarsitenumber=$localsite");
+ $rr = DBExec ($c, "select * from clartable where contestnumber=$contest and clarsitenumber=$localsite");
+ $n = DBnLines ($r);
+ $nn = DBnLines ($rr);
+ echo "clars: external(site=$site, reading=$localsite)=$n, local=$nn\n";
+ for ($k=0; $k<$nn; $k++) $needed[$k]=false;
+ for ($j=0;$j<$n;$j++) {
+ $la = DBRow($r,$j);
+ for ($k=0; $k<$nn; $k++) {
+ $aqui = DBRow($rr,$k);
+ if ($la["clarnumber"]==$aqui["clarnumber"] && $la["contestnumber"]==$aqui["contestnumber"] &&
+ $la["clarsitenumber"]==$aqui["clarsitenumber"]) {
+ $needed[$k]=true;
+ if ($la["updatetime"]>$aqui["updatetime"])
+ $situacao[$j]="atualizar";
+ else
+ $situacao[$j]="ok";
+ break;
+ }
+ }
+ if ($k>=$nn) $situacao[$j]="inserir";
+ }
+ $upd=0; $ins=0;
+ for ($j=0;$j<$n;$j++) {
+ $atual = DBRow($r,$j);
+ if ($atual["claranswer"]=="") $atual["claranswer"]="null";
+ else $atual["claranswer"]="'".escape_string($atual["claranswer"])."'";
+ if ($atual["clarjudge"]=="") $atual["clarjudge"]="null";
+ if ($atual["clarjudgesite"]=="") $atual["clarjudgesite"]="null";
+ if ($atual["updatetime"]=="") $atual["updatetime"]=time();
+ if ($situacao[$j]=="atualizar") {
+ DBExec ($c, "update clartable set ".
+ "usernumber=".$atual["usernumber"].",".
+ "clardate=".$atual["clardate"].",".
+ "clardatediff=".$atual["clardatediff"].",".
+ "clardatediffans=".$atual["clardatediffans"].",".
+ "clarproblem=".$atual["clarproblem"].",".
+ "clardata='".escape_string($atual["clardata"])."',".
+ "claranswer=".$atual["claranswer"].",".
+ "clarstatus='".escape_string($atual["clarstatus"])."',".
+ "clarjudge=".$atual["clarjudge"].",".
+ "clarjudgesite=".$atual["clarjudgesite"].",".
+ "updatetime=".$atual["updatetime"].
+ " where contestnumber=$contest and clarsitenumber=".$atual["clarsitenumber"].
+ " and clarnumber=".$atual["clarnumber"]." and updatetime<".$atual["updatetime"]);
+ $upd++;
+ } else if($situacao[$j]=="inserir") {
+ $ins++;
+ echo "Clar inserts shouldn't exist (clarnumber=".$atual["clarnumber"].")...\n";
+ }
+ }
+ echo " updates=$upd, insertions=$ins\n\n";
+
+ // sincronizando runs
+ $r = DBExec ($t, "select * from runtable where contestnumber=$contest and runsitenumber=$site");
+ $rr = DBExec ($c, "select * from runtable where contestnumber=$contest and runsitenumber=$site");
+ $n = DBnLines ($r);
+ $nn = DBnLines ($rr);
+ echo "runs: external(site=$site, reading=$site)=$n, local=$nn\n";
+ for ($k=0; $k<$nn; $k++) $needed[$k]=false;
+ for ($j=0;$j<$n;$j++) {
+ $la = DBRow($r,$j);
+ for ($k=0; $k<$nn; $k++) {
+ $aqui = DBRow($rr,$k);
+ if ($la["runnumber"]==$aqui["runnumber"] && $la["contestnumber"]==$aqui["contestnumber"] &&
+ $la["runsitenumber"]==$aqui["runsitenumber"]) {
+ $needed[$k]=true;
+ if ($la["updatetime"]>$aqui["updatetime"]) {
+ $situacao[$j]="atualizar";
+ }
+ else
+ $situacao[$j]="ok";
+ break;
+ }
+ }
+ if ($k>=$nn) $situacao[$j]="inserir";
+ }
+ $del=0;
+ for ($k=0; $k<$nn; $k++) {
+ $atual = DBRow($rr, $k);
+ if (!$needed[$k]) {
+ $del++;
+ DBExec($c, "delete from runtable where contestnumber=$contest and runsitenumber=$site and runnumber=".
+ $atual["runnumber"]);
+ }
+ }
+ $upd=0; $ins=0;
+ for ($j=0;$j<$n;$j++) {
+ $atual = DBRow($r,$j);
+/*
+ $r2 = DBExec ($c,"select * from runtable where contestnumber=$contest and runsitenumber=".$atual["runsitenumber"].
+ " and runnumber=".$atual["runnumber"]." for update");
+ if (DBnLines($r2)>0) {
+ $p = DBRow($r2, 0);
+ DB_lo_unlink($c, $p["rundata"]);
+ }
+*/
+ if ($atual["runjudge"]=="") $atual["runjudge"]="null";
+ if ($atual["runjudgesite"]=="") $atual["runjudgesite"]="null";
+ if ($atual["updatetime"]=="") $atual["updatetime"]=time();
+ if ($situacao[$j]=="atualizar") {
+ $upd++;
+ DBExec ($c, "update runtable set ".
+ "usernumber=".$atual["usernumber"].",".
+ "rundate=".$atual["rundate"].",".
+ "rundatediff=".$atual["rundatediff"].",".
+ "rundatediffans=".$atual["rundatediffans"].",".
+ "runproblem=".$atual["runproblem"].",".
+ "runlangnumber=".$atual["runlangnumber"].",".
+ "runanswer=".$atual["runanswer"].",".
+ "runstatus='".escape_string($atual["runstatus"])."',".
+ "runjudge=".$atual["runjudge"].",".
+ "runjudgesite=".$atual["runjudgesite"].",".
+ "runfilename='".escape_string($atual["runfilename"])."',".
+ "updatetime=".$atual["updatetime"].
+ " where contestnumber=$contest and runsitenumber=".$atual["runsitenumber"].
+ " and runnumber=".$atual["runnumber"]." and updatetime<".$atual["updatetime"]);
+ } else if ($situacao[$j]=="inserir") {
+ $ins++;
+ DBExec($t, "begin work");
+ $in = DB_lo_open($t, $atual["rundata"], "r");
+ if (!$in) $o="0";
+ else {
+ $o = DB_lo_create ($c);
+ $out = DB_lo_open ($c, $o, "w");
+ while (($buf = DB_lo_read ($in, 1000)) != false)
+ DB_lo_write ($out, $buf);
+ DB_lo_close ($out);
+ DB_lo_close ($in);
+
+ $in = DB_lo_open($t, $atual["rundata"], "r");
+ if (!$in) {
+ $o="0";
+ LOGLevel("Run not saved as file (run=".$atual["runnumber"].",site=".$atual["runsitenumber"].
+ ",contest=$contest", 1);
+ } else {
+ $sitess=$atual["runsitenumber"];
+ $nss=$atual["runnumber"];
+ $user=$atual["usernumber"];
+ $problem=$atual["runproblem"];
+ $filename=escape_string($atual["runfilename"]);
+ $ttimet=$atual["rundate"];
+ $fp = fopen("/tmp/boca/contest${contest}.site${sitess}.run${nss}.user${user}.".
+ "problem${problem}.time${ttimet}.${filename}", "w");
+ if ($fp) {
+ while (($buf = DB_lo_read ($in, 1000)) != false)
+ fwrite ($fp, $buf);
+ fclose ($fp);
+ $fp = fopen("/tmp/check/contest${contest}.site${sitess}.run${nss}.user${user}.".
+ "problem${problem}.time${ttimet}.${filename}.check", "w");
+ if ($fp) {
+ fwrite($fp, "1");
+ fclose ($fp);
+ }
+ else
+ LOGLevel("Run not saved as check file (run=".$atual["runnumber"].",site=".$atual["runsitenumber"].
+ ",contest=$contest", 1);
+ } else
+ LOGLevel("Run not saved as file (run=".$atual["runnumber"].",site=".$atual["runsitenumber"].
+ ",contest=$contest", 1);
+ DB_lo_close ($out);
+ }
+
+ }
+ DBExec ($c, "insert into runtable (contestnumber, runsitenumber, runnumber, usernumber, rundate,".
+ "rundatediff, rundatediffans, runproblem, runfilename, rundata, runanswer, runstatus, runjudge,".
+ "runjudgesite, runlangnumber, updatetime) ".
+ "values (".$contest.",".$atual["runsitenumber"].",".$atual["runnumber"].",".$atual["usernumber"].",".
+ $atual["rundate"].",".
+ $atual["rundatediff"].",".
+ $atual["rundatediffans"].",".
+ $atual["runproblem"].",".
+ "'".escape_string($atual["runfilename"])."',$o,".
+ $atual["runanswer"].",".
+ "'".escape_string($atual["runstatus"])."',".
+ $atual["runjudge"].",".
+ $atual["runjudgesite"].",".
+ $atual["runlangnumber"].",".
+ $atual["updatetime"].")");
+ DBExec ($t, "commit work");
+ }
+ }
+ echo " deletions=$del, updates=$upd, insertions=$ins\n\n";
+
+ // sincronizando runs
+ $r = DBExec ($t, "select * from runtable where contestnumber=$contest and runsitenumber=$localsite");
+ $rr = DBExec ($c, "select * from runtable where contestnumber=$contest and runsitenumber=$localsite");
+ $n = DBnLines ($r);
+ $nn = DBnLines ($rr);
+ echo "runs: external(site=$site, reading=$localsite)=$n, local=$nn\n";
+ for ($k=0; $k<$nn; $k++) $needed[$k]=false;
+ for ($j=0;$j<$n;$j++) {
+ $la = DBRow($r,$j);
+ for ($k=0; $k<$nn; $k++) {
+ $aqui = DBRow($rr,$k);
+ if ($la["runnumber"]==$aqui["runnumber"] && $la["contestnumber"]==$aqui["contestnumber"] &&
+ $la["runsitenumber"]==$aqui["runsitenumber"]) {
+ $needed[$k]=true;
+ if ($la["updatetime"]>$aqui["updatetime"]) {
+ $situacao[$j]="atualizar";
+
+
+ if ($la["runanswer"] != "") {
+ $rrr = DBExec($c, "select * from answertable where answernumber=".$la["runanswer"].
+ " and contestnumber=".$la["contestnumber"]);
+ $ans = (DBnLines($rrr)>0)? DBRow($rrr, 0) : null;
+ if ($ans == null) {
+ echo "Problem with the answer table. Unable to send balloon because the answer was " .
+ "not found (run=".$la["runnumber"].", site=".$la["runsite"].", contest=" .
+ $la["contestnumber"].", answer=".$la["runanswer"].").";
+ $yesla = 'x';
+ } else $yesla = $ans["yes"];
+ } else $yesla='f';
+ if ($aqui["runanswer"] != "") {
+ $rrr = DBExec($c, "select * from answertable where answernumber=".$aqui["runanswer"].
+ " and contestnumber=".$aqui["contestnumber"]);
+ $ans = (DBnLines($rrr)>0)? DBRow($rrr, 0) : null;
+ if ($ans == null) {
+ echo "Problem with the answer table. Unable to send balloon because the answer was " .
+ "not found (run=".$aqui["runnumber"].", site=".$aqui["runsite"].", contest=" .
+ $aqui["contestnumber"].", answer=".$aqui["runanswer"].").";
+ $yesaqui = 'x';
+ } else $yesaqui = $ans["yes"];
+ } else $yesaqui='f';
+
+ if ($yesla == 't' && $yesaqui == 'f') {
+ $rrr = DBExec ($c, "select * from sitetable where contestnumber=".$aqui["contestnumber"].
+ " and sitenumber=$localsite");
+ if (DBnLines($rrr)<=0)
+ echo "Site info not found (contest=${aqui["contestnumber"]}, site=$localsite).";
+ else {
+ $b = DBRow($rrr,0);
+ $ti = $b["sitestartdate"];
+ $tempo = time();
+ $ta = $tempo - $ti;
+ $tf = $b["sitelastmileanswer"];
+// if ($ta < $tf) {
+ $rrr = DBExec ($c, "select * from usertable where contestnumber=".
+ $aqui["contestnumber"]." and usersitenumber=$localsite and usernumber=".
+ $aqui["usernumber"]);
+ if (DBnLines($rrr)<=0)
+ echo "User info not found (contest=${aqui["contestnumber"]}, ".
+ "site=$localsite, user=${aqui["runusernumber"]}).";
+ else {
+ $u = DBRow ($rrr,0);
+ $rrr = DBExec ($c, "select * from problemtable where contestnumber=".
+ $aqui["contestnumber"]." and problemnumber=".
+ $aqui["runproblem"]);
+ if (DBnLines($rrr)<=0)
+ echo "Problem info not found (contest=${aqui["contestnumber"]}, ".
+ "problem=${aqui["runproblem"]}).";
+ else {
+ $p = DBRow ($rrr,0);
+ mail("balloon@mainserver", "YES: team=" . $u["username"] .
+ ", problem=" . $p["problemname"],
+ "User ".$u["username"] ." should receive a balloon for ".
+ $p["problemfullname"]."\n");
+ }
+ }
+// }
+ }
+ } else if ($yesla == 'f' && $yesaqui == 't') {
+ $rrr = DBExec ($c, "select * from usertable where contestnumber=".
+ $aqui["contestnumber"]." and usersitenumber=$localsite and usernumber=".
+ $aqui["usernumber"]);
+ if (DBnLines($rrr)<=0)
+ echo "User info not found (contest=${aqui["contestnumber"]}, ".
+ "site=$localsite, user=${aqui["runusernumber"]}).";
+ else {
+ $u = DBRow ($rrr,0);
+ $rrr = DBExec ($c, "select * from problemtable where contestnumber=".
+ $aqui["contestnumber"]." and problemnumber=".
+ $aqui["runproblem"]);
+ if (DBnLines($rrr)<=0)
+ echo "Problem info not found (contest=${aqui["contestnumber"]}, ".
+ "problem=${aqui["runproblem"]}).";
+ else {
+ $p = DBRow ($rrr,0);
+ mail("balloon@mainserver", "NO: team=" . $u["username"] .
+ ", problem=" . $p["problemname"],
+ "Remove the balloon from user ". $u["username"] .
+ " for ".$p["problemfullname"]."\n");
+ }
+ }
+ }
+
+
+ }
+ else
+ $situacao[$j]="ok";
+ break;
+ }
+ }
+ if ($k>=$nn) $situacao[$j]="inserir";
+ }
+ $upd=0; $ins=0;
+ for ($j=0;$j<$n;$j++) {
+ $atual = DBRow($r,$j);
+
+ if ($atual["runjudge"]=="") $atual["runjudge"]="null";
+ if ($atual["runjudgesite"]=="") $atual["runjudgesite"]="null";
+ if ($atual["updatetime"]=="") $atual["updatetime"]=time();
+ if ($situacao[$j]=="atualizar") {
+ $upd++;
+ DBExec ($c, "update runtable set ".
+ "usernumber=".$atual["usernumber"].",".
+ "rundate=".$atual["rundate"].",".
+ "rundatediff=".$atual["rundatediff"].",".
+ "rundatediffans=".$atual["rundatediffans"].",".
+ "runproblem=".$atual["runproblem"].",".
+ "runlangnumber=".$atual["runlangnumber"].",".
+ "runanswer=".$atual["runanswer"].",".
+ "runstatus='".escape_string($atual["runstatus"])."',".
+ "runjudge=".$atual["runjudge"].",".
+ "runjudgesite=".$atual["runjudgesite"].",".
+ "runfilename='".escape_string($atual["runfilename"])."',".
+ "updatetime=".$atual["updatetime"].
+ " where contestnumber=$contest and runsitenumber=".$atual["runsitenumber"].
+ " and runnumber=".$atual["runnumber"]." and updatetime<".$atual["updatetime"]);
+ } else if ($situacao[$j]=="inserir") {
+ $ins++;
+ echo "Run Inserts shouldn't exist (run=".$atual["runnumber"].")...";
+ }
+ }
+ echo " updates=$upd, insertions=$ins\n\n";
+
+ DBExec($c, "commit work");
+ DBClose($t);
+ }
+ DBClose($c);
+}
+
+//fecha a conexao com o banco (isso nao eh realmente necessario, ja que o php/apache cuidam do servico)
+function DBClose($c) {
+ if ($c) pg_close($c);
+}
+//executar instrucao no banco de dados, parando em caso de erro quando $stop=1
+function DBExec($conn,$sql) {
+// echo $sql . "\n";
+ $result = pg_exec ($conn, $sql);
+ if (!$result) {
+ echo "Unable to exec SQL in the database. SQL=(" . $sql . ")," .
+ " Error=(" . pg_errormessage($conn) . ")\n";
+ exit;
+ }
+ return $result;
+}
+//devolve o numero de linhas da consulta
+function DBnlines ($result) {
+ return pg_numrows ($result);
+}
+//pega uma linha da consulta no formato de array
+function DBRow ($r, $i) {
+ return pg_fetch_array ($r, $i);
+}
+function escape_string($s) {
+ return str_replace("'", "''", $s);
+}
+if (getIP()!="UNKNOWN") exit;
+
+$x = DBConnect();
+if ($x==null) exit;
+$y = DBExec($x, "select * from contesttable where contestactive='t'");
+if (DBnLines($y)==0) {
+ echo "Unable to find the active contest in the database.\n";
+ exit;
+}
+$ct = DBRow($y,0);
+DBClose($x);
+GetExternalData($ct["contestnumber"]);
+
+?>
diff --git a/old/getextdata.php b/old/getextdata.php
new file mode 100644
index 0000000..7c9955d
--- /dev/null
+++ b/old/getextdata.php
@@ -0,0 +1,931 @@
+$aqui["updatetime"])
+ $situacao[$j]="atualizar";
+ else
+ $situacao[$j]="ok";
+ break;
+ }
+ }
+ if ($k>=$nn) $situacao[$j]="inserir";
+ }
+ $del=0; $upd=0; $ins=0;
+ for ($k=0; $k<$nn; $k++) {
+ $atual = DBRow($rr, $k);
+ if (!$needed[$k]) {
+ DBExec($c, "delete from answertable where contestnumber=$contest and answernumber=".$atual["answernumber"]);
+ $del++;
+ }
+ }
+ for ($j=0;$j<$n;$j++) {
+ $atual = DBRow($r,$j);
+ if ($atual["updatetime"]=="") $atual["updatetime"]=time();
+ if ($situacao[$j]=="atualizar") {
+ $upd++;
+ DBExec ($c, "update answertable set ".
+ "runanswer='".$atual["runanswer"]."',".
+ "yes='".$atual["yes"]."',".
+ "fake='".$atual["fake"]."',".
+ "updatetime=".$atual["updatetime"].
+ " where contestnumber=$contest and answernumber=".$atual["answernumber"].
+ " and updatetime<".$atual["updatetime"]);
+ } else if ($situacao[$j]=="inserir") {
+ $ins++;
+ DBExec($c,"insert into answertable (contestnumber, answernumber, runanswer, yes, fake, updatetime) values (" .
+ $contest.",".$atual["answernumber"].",'".$atual["runanswer"]."','".$atual["yes"]."',".
+ "'".$atual["fake"]."',".$atual["updatetime"].")");
+ }
+ }
+ echo " deletions=$del, updates=$upd, insertions=$ins\n\n";
+
+ // sincronizando languages
+ $r = DBExec ($t, "select * from langtable where contestnumber=$contest");
+ $rr = DBExec ($c, "select * from langtable where contestnumber=$contest for update");
+ $n = DBnLines ($r);
+ $nn = DBnLines ($rr);
+ echo "languages: external(site=$mainsite, reading=$mainsite)=$n, local=$nn\n";
+ for ($k=0; $k<$nn; $k++) $needed[$k]=false;
+ for ($j=0;$j<$n;$j++) {
+ $la = DBRow($r,$j);
+ for ($k=0; $k<$nn; $k++) {
+ $aqui = DBRow($rr,$k);
+ if ($la["langnumber"]==$aqui["langnumber"] && $la["contestnumber"]==$aqui["contestnumber"]) {
+ $needed[$k]=true;
+ if ($la["updatetime"]>$aqui["updatetime"])
+ $situacao[$j]="atualizar";
+ else
+ $situacao[$j]="ok";
+ break;
+ }
+ }
+ if ($k>=$nn) $situacao[$j]="inserir";
+ }
+ $del=0; $upd=0; $ins=0;
+ for ($k=0; $k<$nn; $k++) {
+ $atual = DBRow($rr, $k);
+ if (!$needed[$k]) {
+ DBExec($c, "delete from langtable where contestnumber=$contest and langnumber=".$atual["langnumber"]);
+ $del++;
+ }
+ }
+ for ($j=0;$j<$n;$j++) {
+ $atual = DBRow($r,$j);
+ if ($atual["updatetime"]=="") $atual["updatetime"]=time();
+ if ($situacao[$j]=="atualizar") {
+ $upd++;
+ DBExec ($c, "update langtable set ".
+ "langname='".escape_string($atual["langname"])."',".
+ "updatetime=".$atual["updatetime"].
+ " where contestnumber=$contest and langnumber=".$atual["langnumber"].
+ " and updatetime<".$atual["updatetime"]);
+ } else if ($situacao[$j]=="inserir") {
+ $ins++;
+ DBExec($c,"insert into langtable (contestnumber, langnumber, langname, updatetime) values ($contest,".$atual["langnumber"].
+ ",'".escape_string($atual["langname"])."',".$atual["updatetime"].")");
+ }
+ }
+ echo " deletions=$del, updates=$upd, insertions=$ins\n\n";
+
+ // sincronizando problems
+ $r = DBExec ($t, "select * from problemtable where contestnumber=$contest");
+ $rr = DBExec ($c, "select * from problemtable where contestnumber=$contest for update");
+ $n = DBnLines ($r);
+ $nn = DBnLines ($rr);
+ echo "problems: external(site=$mainsite, reading=$mainsite)=$n, local=$nn\n";
+ for ($k=0; $k<$nn; $k++) $needed[$k]=false;
+ for ($j=0;$j<$n;$j++) {
+ $la = DBRow($r,$j);
+ for ($k=0; $k<$nn; $k++) {
+ $aqui = DBRow($rr,$k);
+ if ($la["problemnumber"]==$aqui["problemnumber"] && $la["contestnumber"]==$aqui["contestnumber"]) {
+ $needed[$k]=true;
+ if ($la["updatetime"]>$aqui["updatetime"])
+ $situacao[$j]="atualizar";
+ else
+ $situacao[$j]="ok";
+ break;
+ }
+ }
+ if ($k>=$nn) $situacao[$j]="inserir";
+ }
+ $del=0; $upd=0; $ins=0;
+ for ($k=0; $k<$nn; $k++) {
+ $atual = DBRow($rr, $k);
+ if (!$needed[$k]) {
+ DBExec($c, "delete from problemtable where contestnumber=$contest and problemnumber=".$atual["problemnumber"]);
+ $del++;
+ }
+ }
+ for ($j=0;$j<$n;$j++) {
+ $atual = DBRow($r,$j);
+ if ($atual["updatetime"]=="") $atual["updatetime"]=time();
+ if ($situacao[$j]=="inserir") {
+ $ins++; $upd--;
+ DBExec($c,"insert into problemtable (contestnumber, problemnumber, problemname, updatetime) values ($contest,".
+ $atual["problemnumber"].",'".escape_string($atual["problemname"])."', 0)");
+ }
+ if ($situacao[$j]=="atualizar" || $situacao[$j]=="inserir") {
+ $upd++;
+ $p = DBRow($r2, 0);
+ if ($p["probleminputfile"]>0) DB_lo_unlink($c, $p["probleminputfile"]);
+ if ($p["problemsolfile"]>0) DB_lo_unlink($c, $p["problemsolfile"]);
+ DBExec($t, "begin work");
+ if ($atual["probleminputfile"]=="") $inputfile="null";
+ else {
+ $in = DB_lo_open($t, $atual["probleminputfile"], "r");
+ if (!$in) $inputfile="null";
+ else {
+ $inputfile = DB_lo_create ($c);
+ $out = DB_lo_open ($c, $inputfile, "w");
+ while (($buf = DB_lo_read ($in, 100000)) != false)
+ DB_lo_write ($out, $buf);
+ DB_lo_close ($out);
+ DB_lo_close ($in);
+ }
+ }
+ if ($atual["problemsolfile"]=="") $solfile="null";
+ else {
+ $in = DB_lo_open($t, $atual["problemsolfile"], "r");
+ if (!$in) $solfile="null";
+ else {
+ $solfile = DB_lo_create ($c);
+ $out = DB_lo_open ($c, $solfile, "w");
+ while (($buf = DB_lo_read ($in, 100000)) != false)
+ DB_lo_write ($out, $buf);
+ DB_lo_close ($out);
+ DB_lo_close ($in);
+ }
+ }
+ DBExec ($t, "commit work");
+
+ DBExec ($c, "update problemtable set ".
+ "problemname='".escape_string($atual["problemname"])."',".
+ "problemfullname='".escape_string($atual["problemfullname"])."',".
+ "problembasefilename='".escape_string($atual["problembasefilename"])."',".
+ "probleminputfilename='".escape_string($atual["probleminputfilename"])."',".
+ "problemsolfilename='".escape_string($atual["problemsolfilename"])."',".
+ "fake='".$atual["fake"]."',".
+ "probleminputfile=".$inputfile.",".
+ "problemsolfile=".$solfile.",".
+ "updatetime=".$atual["updatetime"].
+ " where contestnumber=$contest and problemnumber=".$atual["problemnumber"].
+ " and updatetime<".$atual["updatetime"]);
+ }
+ }
+ echo " deletions=$del, updates=$upd, insertions=$ins\n\n";
+ DBExec($c, "commit work");
+ }
+
+ }
+
+ $r = DBExec ($c, "select * from sitetable where contestnumber=$contest");
+ $n = DBnlines($r);
+ if ($n == 0) {
+ echo "Unable to find sites in the database.\n";
+ exit;
+ }
+ $st = array();
+ for ($i=0;$i<$n;$i++) {
+ $st[$i] = DBRow($r,$i);
+ }
+
+ for ($i=0; $i$aqui["updatetime"])
+ $situacao[$j]="atualizar";
+ else
+ $situacao[$j]="ok";
+ break;
+ }
+ }
+ if ($k>=$nn) $situacao[$j]="inserir";
+ }
+ $del=0;
+ for ($k=0; $k<$nn; $k++) {
+ $atual = DBRow($rr, $k);
+ if (!$needed[$k]) {
+ DBExec($c, "delete from usertable where contestnumber=$contest and usersitenumber=$site and usernumber=".
+ $atual["usernumber"]);
+ $del++;
+ }
+ }
+ $upd=0; $ins=0;
+ for ($j=0;$j<$n;$j++) {
+ $atual = DBRow($r,$j);
+ if ($atual["userlastlogin"]=="") $atual["userlastlogin"]="null";
+ if ($atual["userlastlogout"]=="") $atual["userlastlogout"]="null";
+ if ($atual["updatetime"]=="") $atual["updatetime"]=time();
+ if ($situacao[$j]=="atualizar") {
+ DBExec ($c, "update usertable set ".
+ "username='".escape_string($atual["username"])."',".
+ "userfullname='".escape_string($atual["userfullname"])."',".
+ "userdesc='".escape_string($atual["userdesc"])."',".
+ "usertype='".escape_string($atual["usertype"])."',".
+ "userenabled='".$atual["userenabled"]."',".
+ "usermultilogin='".$atual["usermultilogin"]."',".
+ "userpassword='".$atual["userpassword"]."',".
+ "userip='".$atual["userip"]."',".
+ "userlastlogin=".$atual["userlastlogin"].",".
+ "userlastlogout=".$atual["userlastlogout"].",".
+ "usersession='".$atual["usersession"]."',".
+ "userpermitip='".$atual["userpermitip"]."',".
+ "updatetime=".$atual["updatetime"].
+ " where contestnumber=$contest and usersitenumber=".$atual["usersitenumber"].
+ " and usernumber=".$atual["usernumber"]." and updatetime<".$atual["updatetime"]);
+ $upd++;
+ } else if ($situacao[$j]=="inserir") {
+ DBExec ($c, "insert into usertable (username, userfullname, userdesc, usertype, userenabled, usermultilogin, ".
+ "userpassword, userip, userlastlogin, userlastlogout, usersession, userpermitip, updatetime, ".
+ "contestnumber, usersitenumber, usernumber) values (".
+ "'".escape_string($atual["username"])."',".
+ "'".escape_string($atual["userfullname"])."',".
+ "'".escape_string($atual["userdesc"])."',".
+ "'".$atual["usertype"]."',".
+ "'".$atual["userenabled"]."',".
+ "'".$atual["usermultilogin"]."',".
+ "'".$atual["userpassword"]."',".
+ "'".$atual["userip"]."',".
+ $atual["userlastlogin"].",".
+ $atual["userlastlogout"].",".
+ "'".$atual["usersession"]."',".
+ "'".$atual["userpermitip"]."',".
+ $atual["updatetime"].",$contest,".$atual["usersitenumber"].",".$atual["usernumber"].")");
+ $ins++;
+ }
+ }
+ echo " deletions=$del, updates=$upd, insertions=$ins\n\n";
+
+ // sincronizando clars
+ $r = DBExec ($t, "select * from clartable where contestnumber=$contest and clarsitenumber=$site");
+ $rr = DBExec ($c, "select * from clartable where contestnumber=$contest and clarsitenumber=$site");
+ $n = DBnLines ($r);
+ $nn = DBnLines ($rr);
+ echo "clars: external(site=$site, reading=$site)=$n, local=$nn\n";
+ for ($k=0; $k<$nn; $k++) $needed[$k]=false;
+ for ($j=0;$j<$n;$j++) {
+ $la = DBRow($r,$j);
+ for ($k=0; $k<$nn; $k++) {
+ $aqui = DBRow($rr,$k);
+ if ($la["clarnumber"]==$aqui["clarnumber"] && $la["contestnumber"]==$aqui["contestnumber"] &&
+ $la["clarsitenumber"]==$aqui["clarsitenumber"]) {
+ $needed[$k]=true;
+ if ($la["updatetime"]>$aqui["updatetime"])
+ $situacao[$j]="atualizar";
+ else
+ $situacao[$j]="ok";
+ break;
+ }
+ }
+ if ($k>=$nn) $situacao[$j]="inserir";
+ }
+ $del=0;
+ for ($k=0; $k<$nn; $k++) {
+ $atual = DBRow($rr, $k);
+ if (!$needed[$k]) {
+ DBExec($c, "delete from clartable where contestnumber=$contest and clarsitenumber=$site and clarnumber=".
+ $atual["clarnumber"]);
+ $del++;
+ }
+ }
+ $upd=0; $ins=0;
+ for ($j=0;$j<$n;$j++) {
+ $atual = DBRow($r,$j);
+ if ($atual["claranswer"]=="") $atual["claranswer"]="null";
+ else $atual["claranswer"]="'".escape_string($atual["claranswer"])."'";
+ if ($atual["clarjudge"]=="") $atual["clarjudge"]="null";
+ if ($atual["clarjudgesite"]=="") $atual["clarjudgesite"]="null";
+ if ($atual["updatetime"]=="") $atual["updatetime"]=time();
+ if ($situacao[$j]=="atualizar") {
+ DBExec ($c, "update clartable set ".
+ "usernumber=".$atual["usernumber"].",".
+ "clardate=".$atual["clardate"].",".
+ "clardatediff=".$atual["clardatediff"].",".
+ "clardatediffans=".$atual["clardatediffans"].",".
+ "clarproblem=".$atual["clarproblem"].",".
+ "clardata='".escape_string($atual["clardata"])."',".
+ "claranswer=".$atual["claranswer"].",".
+ "clarstatus='".escape_string($atual["clarstatus"])."',".
+ "clarjudge=".$atual["clarjudge"].",".
+ "clarjudgesite=".$atual["clarjudgesite"].",".
+ "updatetime=".$atual["updatetime"].
+ " where contestnumber=$contest and clarsitenumber=".$atual["clarsitenumber"].
+ " and clarnumber=".$atual["clarnumber"]." and updatetime<".$atual["updatetime"]);
+ $upd++;
+ } else if($situacao[$j]=="inserir") {
+ DBExec ($c, "insert into clartable (contestnumber, clarsitenumber, clarnumber, usernumber, clardate,".
+ "clardatediff, clardatediffans, clarproblem, clardata, claranswer, clarstatus, clarjudge, clarjudgesite, updatetime) ".
+ "values (".$contest.",".$atual["clarsitenumber"].",".$atual["clarnumber"].",".$atual["usernumber"].",".
+ $atual["clardate"].",".
+ $atual["clardatediff"].",".
+ $atual["clardatediffans"].",".
+ $atual["clarproblem"].",".
+ "'".escape_string($atual["clardata"])."',".
+ $atual["claranswer"].",".
+ "'".escape_string($atual["clarstatus"])."',".
+ $atual["clarjudge"].",".
+ $atual["clarjudgesite"].",".
+ $atual["updatetime"].")");
+ $ins++;
+ }
+ }
+ echo " deletions=$del, updates=$upd, insertions=$ins\n\n";
+
+ // sincronizando clars
+ $r = DBExec ($t, "select * from clartable where contestnumber=$contest and clarsitenumber=$localsite");
+ $rr = DBExec ($c, "select * from clartable where contestnumber=$contest and clarsitenumber=$localsite");
+ $n = DBnLines ($r);
+ $nn = DBnLines ($rr);
+ echo "clars: external(site=$site, reading=$localsite)=$n, local=$nn\n";
+ for ($k=0; $k<$nn; $k++) $needed[$k]=false;
+ for ($j=0;$j<$n;$j++) {
+ $la = DBRow($r,$j);
+ for ($k=0; $k<$nn; $k++) {
+ $aqui = DBRow($rr,$k);
+ if ($la["clarnumber"]==$aqui["clarnumber"] && $la["contestnumber"]==$aqui["contestnumber"] &&
+ $la["clarsitenumber"]==$aqui["clarsitenumber"]) {
+ $needed[$k]=true;
+ if ($la["updatetime"]>$aqui["updatetime"])
+ $situacao[$j]="atualizar";
+ else
+ $situacao[$j]="ok";
+ break;
+ }
+ }
+ if ($k>=$nn) $situacao[$j]="inserir";
+ }
+ $upd=0; $ins=0;
+ for ($j=0;$j<$n;$j++) {
+ $atual = DBRow($r,$j);
+ if ($atual["claranswer"]=="") $atual["claranswer"]="null";
+ else $atual["claranswer"]="'".escape_string($atual["claranswer"])."'";
+ if ($atual["clarjudge"]=="") $atual["clarjudge"]="null";
+ if ($atual["clarjudgesite"]=="") $atual["clarjudgesite"]="null";
+ if ($atual["updatetime"]=="") $atual["updatetime"]=time();
+ if ($situacao[$j]=="atualizar") {
+ DBExec ($c, "update clartable set ".
+ "usernumber=".$atual["usernumber"].",".
+ "clardate=".$atual["clardate"].",".
+ "clardatediff=".$atual["clardatediff"].",".
+ "clardatediffans=".$atual["clardatediffans"].",".
+ "clarproblem=".$atual["clarproblem"].",".
+ "clardata='".escape_string($atual["clardata"])."',".
+ "claranswer=".$atual["claranswer"].",".
+ "clarstatus='".escape_string($atual["clarstatus"])."',".
+ "clarjudge=".$atual["clarjudge"].",".
+ "clarjudgesite=".$atual["clarjudgesite"].",".
+ "updatetime=".$atual["updatetime"].
+ " where contestnumber=$contest and clarsitenumber=".$atual["clarsitenumber"].
+ " and clarnumber=".$atual["clarnumber"]." and updatetime<".$atual["updatetime"]);
+ $upd++;
+ } else if($situacao[$j]=="inserir") {
+ $ins++;
+ echo "Clar inserts shouldn't exist (clarnumber=".$atual["clarnumber"].")...\n";
+ }
+ }
+ echo " updates=$upd, insertions=$ins\n\n";
+
+ // sincronizando runs
+ $r = DBExec ($t, "select * from runtable where contestnumber=$contest and runsitenumber=$site");
+ $rr = DBExec ($c, "select * from runtable where contestnumber=$contest and runsitenumber=$site");
+ $n = DBnLines ($r);
+ $nn = DBnLines ($rr);
+ echo "runs: external(site=$site, reading=$site)=$n, local=$nn\n";
+ for ($k=0; $k<$nn; $k++) $needed[$k]=false;
+ for ($j=0;$j<$n;$j++) {
+ $la = DBRow($r,$j);
+ for ($k=0; $k<$nn; $k++) {
+ $aqui = DBRow($rr,$k);
+ if ($la["runnumber"]==$aqui["runnumber"] && $la["contestnumber"]==$aqui["contestnumber"] &&
+ $la["runsitenumber"]==$aqui["runsitenumber"]) {
+ $needed[$k]=true;
+ if ($la["updatetime"]>$aqui["updatetime"]) {
+ $situacao[$j]="atualizar";
+ }
+ else
+ $situacao[$j]="ok";
+ break;
+ }
+ }
+ if ($k>=$nn) $situacao[$j]="inserir";
+ }
+ $del=0;
+ for ($k=0; $k<$nn; $k++) {
+ $atual = DBRow($rr, $k);
+ if (!$needed[$k]) {
+ $del++;
+ DBExec($c, "delete from runtable where contestnumber=$contest and runsitenumber=$site and runnumber=".
+ $atual["runnumber"]);
+ }
+ }
+ $upd=0; $ins=0;
+ for ($j=0;$j<$n;$j++) {
+ $atual = DBRow($r,$j);
+/*
+ $r2 = DBExec ($c,"select * from runtable where contestnumber=$contest and runsitenumber=".$atual["runsitenumber"].
+ " and runnumber=".$atual["runnumber"]." for update");
+ if (DBnLines($r2)>0) {
+ $p = DBRow($r2, 0);
+ DB_lo_unlink($c, $p["rundata"]);
+ }
+*/
+ if ($atual["runjudge"]=="") $atual["runjudge"]="null";
+ if ($atual["runjudgesite"]=="") $atual["runjudgesite"]="null";
+ if ($atual["updatetime"]=="") $atual["updatetime"]=time();
+ if ($situacao[$j]=="atualizar") {
+ $upd++;
+ DBExec ($c, "update runtable set ".
+ "usernumber=".$atual["usernumber"].",".
+ "rundate=".$atual["rundate"].",".
+ "rundatediff=".$atual["rundatediff"].",".
+ "rundatediffans=".$atual["rundatediffans"].",".
+ "runproblem=".$atual["runproblem"].",".
+ "runlangnumber=".$atual["runlangnumber"].",".
+ "runanswer=".$atual["runanswer"].",".
+ "runstatus='".escape_string($atual["runstatus"])."',".
+ "runjudge=".$atual["runjudge"].",".
+ "runjudgesite=".$atual["runjudgesite"].",".
+ "runfilename='".escape_string($atual["runfilename"])."',".
+ "updatetime=".$atual["updatetime"].
+ " where contestnumber=$contest and runsitenumber=".$atual["runsitenumber"].
+ " and runnumber=".$atual["runnumber"]." and updatetime<".$atual["updatetime"]);
+ } else if ($situacao[$j]=="inserir") {
+ $ins++;
+ DBExec($t, "begin work");
+ $in = DB_lo_open($t, $atual["rundata"], "r");
+ if (!$in) $o="0";
+ else {
+ $o = DB_lo_create ($c);
+ $out = DB_lo_open ($c, $o, "w");
+ while (($buf = DB_lo_read ($in, 1000)) != false)
+ DB_lo_write ($out, $buf);
+ DB_lo_close ($out);
+ DB_lo_close ($in);
+
+ $in = DB_lo_open($t, $atual["rundata"], "r");
+ if (!$in) {
+ $o="0";
+ LOGLevel("Run not saved as file (run=".$atual["runnumber"].",site=".$atual["runsitenumber"].
+ ",contest=$contest", 1);
+ } else {
+ $sitess=$atual["runsitenumber"];
+ $nss=$atual["runnumber"];
+ $user=$atual["usernumber"];
+ $problem=$atual["runproblem"];
+ $filename=escape_string($atual["runfilename"]);
+ $ttimet=$atual["rundate"];
+ $fp = fopen("/tmp/boca/contest${contest}.site${sitess}.run${nss}.user${user}.".
+ "problem${problem}.time${ttimet}.${filename}", "w");
+ if ($fp) {
+ while (($buf = DB_lo_read ($in, 1000)) != false)
+ fwrite ($fp, $buf);
+ fclose ($fp);
+ $fp = fopen("/tmp/check/contest${contest}.site${sitess}.run${nss}.user${user}.".
+ "problem${problem}.time${ttimet}.${filename}.check", "w");
+ if ($fp) {
+ fwrite($fp, "1");
+ fclose ($fp);
+ }
+ else
+ LOGLevel("Run not saved as check file (run=".$atual["runnumber"].",site=".$atual["runsitenumber"].
+ ",contest=$contest", 1);
+ } else
+ LOGLevel("Run not saved as file (run=".$atual["runnumber"].",site=".$atual["runsitenumber"].
+ ",contest=$contest", 1);
+ DB_lo_close ($out);
+ }
+
+ }
+ DBExec ($c, "insert into runtable (contestnumber, runsitenumber, runnumber, usernumber, rundate,".
+ "rundatediff, rundatediffans, runproblem, runfilename, rundata, runanswer, runstatus, runjudge,".
+ "runjudgesite, runlangnumber, updatetime) ".
+ "values (".$contest.",".$atual["runsitenumber"].",".$atual["runnumber"].",".$atual["usernumber"].",".
+ $atual["rundate"].",".
+ $atual["rundatediff"].",".
+ $atual["rundatediffans"].",".
+ $atual["runproblem"].",".
+ "'".escape_string($atual["runfilename"])."',$o,".
+ $atual["runanswer"].",".
+ "'".escape_string($atual["runstatus"])."',".
+ $atual["runjudge"].",".
+ $atual["runjudgesite"].",".
+ $atual["runlangnumber"].",".
+ $atual["updatetime"].")");
+ DBExec ($t, "commit work");
+ }
+ }
+ echo " deletions=$del, updates=$upd, insertions=$ins\n\n";
+
+ // sincronizando runs
+ $r = DBExec ($t, "select * from runtable where contestnumber=$contest and runsitenumber=$localsite");
+ $rr = DBExec ($c, "select * from runtable where contestnumber=$contest and runsitenumber=$localsite");
+ $n = DBnLines ($r);
+ $nn = DBnLines ($rr);
+ echo "runs: external(site=$site, reading=$localsite)=$n, local=$nn\n";
+ for ($k=0; $k<$nn; $k++) $needed[$k]=false;
+ for ($j=0;$j<$n;$j++) {
+ $la = DBRow($r,$j);
+ for ($k=0; $k<$nn; $k++) {
+ $aqui = DBRow($rr,$k);
+ if ($la["runnumber"]==$aqui["runnumber"] && $la["contestnumber"]==$aqui["contestnumber"] &&
+ $la["runsitenumber"]==$aqui["runsitenumber"]) {
+ $needed[$k]=true;
+ if ($la["updatetime"]>$aqui["updatetime"]) {
+ $situacao[$j]="atualizar";
+
+
+ if ($la["runanswer"] != "") {
+ $rrr = DBExec($c, "select * from answertable where answernumber=".$la["runanswer"].
+ " and contestnumber=".$la["contestnumber"]);
+ $ans = (DBnLines($rrr)>0)? DBRow($rrr, 0) : null;
+ if ($ans == null) {
+ echo "Problem with the answer table. Unable to send balloon because the answer was " .
+ "not found (run=".$la["runnumber"].", site=".$la["runsite"].", contest=" .
+ $la["contestnumber"].", answer=".$la["runanswer"].").";
+ $yesla = 'x';
+ } else $yesla = $ans["yes"];
+ } else $yesla='f';
+ if ($aqui["runanswer"] != "") {
+ $rrr = DBExec($c, "select * from answertable where answernumber=".$aqui["runanswer"].
+ " and contestnumber=".$aqui["contestnumber"]);
+ $ans = (DBnLines($rrr)>0)? DBRow($rrr, 0) : null;
+ if ($ans == null) {
+ echo "Problem with the answer table. Unable to send balloon because the answer was " .
+ "not found (run=".$aqui["runnumber"].", site=".$aqui["runsite"].", contest=" .
+ $aqui["contestnumber"].", answer=".$aqui["runanswer"].").";
+ $yesaqui = 'x';
+ } else $yesaqui = $ans["yes"];
+ } else $yesaqui='f';
+
+ if ($yesla == 't' && $yesaqui == 'f') {
+ $rrr = DBExec ($c, "select * from sitetable where contestnumber=".$aqui["contestnumber"].
+ " and sitenumber=$localsite");
+ if (DBnLines($rrr)<=0)
+ echo "Site info not found (contest=${aqui["contestnumber"]}, site=$localsite).";
+ else {
+ $b = DBRow($rrr,0);
+ $ti = $b["sitestartdate"];
+ $tempo = time();
+ $ta = $tempo - $ti;
+ $tf = $b["sitelastmileanswer"];
+// if ($ta < $tf) {
+ $rrr = DBExec ($c, "select * from usertable where contestnumber=".
+ $aqui["contestnumber"]." and usersitenumber=$localsite and usernumber=".
+ $aqui["usernumber"]);
+ if (DBnLines($rrr)<=0)
+ echo "User info not found (contest=${aqui["contestnumber"]}, ".
+ "site=$localsite, user=${aqui["runusernumber"]}).";
+ else {
+ $u = DBRow ($rrr,0);
+ $rrr = DBExec ($c, "select * from problemtable where contestnumber=".
+ $aqui["contestnumber"]." and problemnumber=".
+ $aqui["runproblem"]);
+ if (DBnLines($rrr)<=0)
+ echo "Problem info not found (contest=${aqui["contestnumber"]}, ".
+ "problem=${aqui["runproblem"]}).";
+ else {
+ $p = DBRow ($rrr,0);
+ mail("balloon@mainserver", "YES: team=" . $u["username"] .
+ ", problem=" . $p["problemname"],
+ "User ".$u["username"] ." should receive a balloon for ".
+ $p["problemfullname"]."\n");
+ }
+ }
+// }
+ }
+ } else if ($yesla == 'f' && $yesaqui == 't') {
+ $rrr = DBExec ($c, "select * from usertable where contestnumber=".
+ $aqui["contestnumber"]." and usersitenumber=$localsite and usernumber=".
+ $aqui["usernumber"]);
+ if (DBnLines($rrr)<=0)
+ echo "User info not found (contest=${aqui["contestnumber"]}, ".
+ "site=$localsite, user=${aqui["runusernumber"]}).";
+ else {
+ $u = DBRow ($rrr,0);
+ $rrr = DBExec ($c, "select * from problemtable where contestnumber=".
+ $aqui["contestnumber"]." and problemnumber=".
+ $aqui["runproblem"]);
+ if (DBnLines($rrr)<=0)
+ echo "Problem info not found (contest=${aqui["contestnumber"]}, ".
+ "problem=${aqui["runproblem"]}).";
+ else {
+ $p = DBRow ($rrr,0);
+ mail("balloon@mainserver", "NO: team=" . $u["username"] .
+ ", problem=" . $p["problemname"],
+ "Remove the balloon from user ". $u["username"] .
+ " for ".$p["problemfullname"]."\n");
+ }
+ }
+ }
+
+
+ }
+ else
+ $situacao[$j]="ok";
+ break;
+ }
+ }
+ if ($k>=$nn) $situacao[$j]="inserir";
+ }
+ $upd=0; $ins=0;
+ for ($j=0;$j<$n;$j++) {
+ $atual = DBRow($r,$j);
+
+ if ($atual["runjudge"]=="") $atual["runjudge"]="null";
+ if ($atual["runjudgesite"]=="") $atual["runjudgesite"]="null";
+ if ($atual["updatetime"]=="") $atual["updatetime"]=time();
+ if ($situacao[$j]=="atualizar") {
+ $upd++;
+ DBExec ($c, "update runtable set ".
+ "usernumber=".$atual["usernumber"].",".
+ "rundate=".$atual["rundate"].",".
+ "rundatediff=".$atual["rundatediff"].",".
+ "rundatediffans=".$atual["rundatediffans"].",".
+ "runproblem=".$atual["runproblem"].",".
+ "runlangnumber=".$atual["runlangnumber"].",".
+ "runanswer=".$atual["runanswer"].",".
+ "runstatus='".escape_string($atual["runstatus"])."',".
+ "runjudge=".$atual["runjudge"].",".
+ "runjudgesite=".$atual["runjudgesite"].",".
+ "runfilename='".escape_string($atual["runfilename"])."',".
+ "updatetime=".$atual["updatetime"].
+ " where contestnumber=$contest and runsitenumber=".$atual["runsitenumber"].
+ " and runnumber=".$atual["runnumber"]." and updatetime<".$atual["updatetime"]);
+ } else if ($situacao[$j]=="inserir") {
+ $ins++;
+ echo "Run Inserts shouldn't exist (run=".$atual["runnumber"].")...";
+ }
+ }
+ echo " updates=$upd, insertions=$ins\n\n";
+
+ DBExec($c, "commit work");
+ DBClose($t);
+ }
+ DBClose($c);
+}
+
+//fecha a conexao com o banco (isso nao eh realmente necessario, ja que o php/apache cuidam do servico)
+function DBClose($c) {
+ if ($c) pg_close($c);
+}
+//executar instrucao no banco de dados, parando em caso de erro quando $stop=1
+function DBExec($conn,$sql) {
+// echo $sql . "\n";
+ $result = pg_exec ($conn, $sql);
+ if (!$result) {
+ echo "Unable to exec SQL in the database. SQL=(" . $sql . ")," .
+ " Error=(" . pg_errormessage($conn) . ")\n";
+ exit;
+ }
+ return $result;
+}
+//devolve o numero de linhas da consulta
+function DBnlines ($result) {
+ return pg_numrows ($result);
+}
+//pega uma linha da consulta no formato de array
+function DBRow ($r, $i) {
+ return pg_fetch_array ($r, $i);
+}
+function escape_string($s) {
+ return str_replace("'", "''", $s);
+}
+if (getIP()!="UNKNOWN") exit;
+
+$x = DBConnect();
+if ($x==null) exit;
+$y = DBExec($x, "select * from contesttable where contestactive='t'");
+if (DBnLines($y)==0) {
+ echo "Unable to find the active contest in the database.\n";
+ exit;
+}
+$ct = DBRow($y,0);
+DBClose($x);
+GetExternalData($ct["contestnumber"]);
+
+?>
diff --git a/old/import-system.txt b/old/import-system.txt
new file mode 100644
index 0000000..7a23479
--- /dev/null
+++ b/old/import-system.txt
@@ -0,0 +1,78 @@
+import-system.txt
+-----------------
+Last modified 20/aug/2007 by cassio@ime.usp.br
+
+************************************
+OUTDATED INFORMATION. PLEASE WAIT FOR A NEW VERSION OF THIS FILE.
+FOR MORE DETAILS, SEE THE EXAMPLE FILE: bits/import.txt
+************************************
+
+
+
+It's possible to create a language file
+(or use the same user file for it, putting the
+languages at the end). Following are some language
+examples, but it is recommended to insert the
+languages by the web pages directly. See the files
+run.sh and compare.sh for compiling/running script and
+comparing script respectively.
+
+
+[language]
+langnumber=1
+langname=C
+langscript=runscriptforlang1.sh
+#!/bin/bash
+echo este eh o runscript 1...
+exit 1
+***END***
+langcompscript=compscriptforlang1.sh
+#!/bin/bash
+echo este eh o compscript 1...
+exit 1
+***END***
+
+langnumber=2
+langname=C++
+langscript=runscriptforlang2.sh
+#!/bin/bash
+echo este eh o runscript 2...
+exit 2
+***END***
+langcompscript=compscriptforlang2.sh
+#!/bin/bash
+echo este eh o compscript 2...
+exit 2
+***END***
+
+langnumber=3
+langname=Java
+langscript=runscriptforlang3.sh
+#!/bin/bash
+echo este eh o runscript 3...
+exit 3
+***END***
+langcompscript=compscriptforlang3.sh
+#!/bin/bash
+echo este eh o compscript 3...
+exit 3
+***END***
+
+
+
+Contacts and Copyrights
+-----------------------
+BOCA Copyright (c) 2003- Cassio Polpo de Campos (cassio@ime.usp.br)
+http://www.ime.usp.br/~cassio/boca
+
+This software may be distributed under the terms of the Q Public
+License version 1.0. A copy of the license can be found with this
+software or at http://www.opensource.org/licenses/qtpl.php
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER
+OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR
+CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/old/import.php b/old/import.php
new file mode 100644
index 0000000..45dd4bd
--- /dev/null
+++ b/old/import.php
@@ -0,0 +1,280 @@
+Starting to create the contest
";
+ $asep = trim($ar[0]);
+ $i=1;
+
+ for (; $iContest $nc created
";
+
+ for (; $i";
+ }
+
+ for (; $iSearching for answers
\n";
+ $x = trim($ar[$i]);
+ if (strpos($x, "answ") !== false && strpos($x, "answ") == 0) {
+ unset($answnumber);
+ unset($answname);
+ unset($answyes);
+ while (strpos($x, "answ") !== false && strpos($x, "answ") == 0) {
+ $tmp = explode ("=", $x, 2);
+ switch (trim($tmp[0])) {
+ case "answernumber": $answnumber =trim($tmp[1]); break;
+ case "answername": $answname =trim($tmp[1]); break;
+ case "answeryes": $answyes =trim($tmp[1]); break;
+ }
+ $i++;
+ if ($i>=count($ar)) break;
+ $x = trim($ar[$i]);
+ }
+ if (isset($answnumber) && is_numeric($answnumber) && isset($answname)) {
+ DBNewAnswer ($nc, $answnumber, $answname, $answyes);
+ echo "Answer $answnumber created
";
+ }
+ }
+ }
+
+ for (; $iSearching for languages
\n";
+ $x = trim($ar[$i]);
+ if (strpos($x, "lang") !== false && strpos($x, "lang") == 0) {
+ unset($langnumber);
+ unset($langname);
+ unset($langproblem);
+ unset($script);
+ unset($compscript);
+ unset($langscript);
+ unset($langcompscript);
+ unset($langscripthash);
+ unset($langcompscripthash);
+ while (strpos($x, "lang") !== false && strpos($x, "lang") == 0) {
+ $tmp = explode ("=", $x, 2);
+ switch (trim($tmp[0])) {
+ case "langnumber": $langnumber =trim($tmp[1]); break;
+ case "langname": $langname =trim($tmp[1]); break;
+ case "langproblem": $langproblem =trim($tmp[1]); break;
+ case "langscripthash": $langscripthash =trim($tmp[1]); break;
+ case "langscript": $langscript =trim($tmp[1]);
+ $i++;
+ for ($j=1; trim($ar[$i]) != "***$asep***"; $j++) {
+ if(substr($langscript,0,7)!="base64:") $script .= $ar[$i];
+ else $script .= trim($ar[$i]);
+ $i++;
+ }
+ if(substr($langscript,0,7)=="base64:") {
+ $langscript = substr($langscript,7);
+ $script = base64_decode($script);
+ }
+ if(trim($langscripthash) != "" && myshorthash($script) != trim($langscripthash))
+ echo "ERROR: Hash of $langscript does not match $langscripthash, ".myshorthash($script)."
\n";
+ break;
+ case "langcompscripthash": $langcompscripthash=trim($tmp[1]); break;
+ case "langcompscript": $langcompscript =trim($tmp[1]);
+ $i++;
+ for ($j=1; trim($ar[$i]) != "***$asep***"; $j++) {
+ if(substr($langcompscript,0,7)!="base64:") $compscript .= $ar[$i];
+ else $compscript .= trim($ar[$i]);
+ $i++;
+ }
+ if(substr($langcompscript,0,7)=="base64:") {
+ $langcompscript = substr($langcompscript,7);
+ $compscript = base64_decode($compscript);
+ }
+ if(trim($langcompscripthash) != "" && myshorthash($compscript) != trim($langcompscripthash))
+ echo "ERROR: Hash of $langcompscript does not match
\n";
+ break;
+ }
+ $i++;
+ if ($i>=count($ar)) break;
+ $x = trim($ar[$i]);
+ }
+ if (isset($langnumber) && is_numeric($langnumber) && isset($langname)) {
+ DBNewLanguage ($nc,
+ $langnumber, $langname, $langproblem, '', '',
+ $langshowingoutput, $script, $langscript, $compscript, $langcompscript, 1, 1);
+ echo "Language $langnumber created
";
+ }
+ }
+ }
+
+ for (; $iSearching for problems
\n";
+ $x = trim($ar[$i]);
+ if (strpos($x, "prob") !== false && strpos($x, "prob") == 0) {
+ unset($probnumber);
+ unset($probname);
+ unset($probfullname);
+ unset($probbasename);
+ unset($probinputfile);
+ unset($probinputfilehash);
+ unset($probinputfilepath);
+ unset($probsolfile);
+ unset($probsolfilehash);
+ unset($probsolfilepath);
+ unset($probdescfile);
+ unset($probdescfilehash);
+ unset($probdescfilepath);
+ unset($probtimelimit);
+ unset($probcolorname);
+ unset($probcolor);
+ while (strpos($x, "prob") !== false && strpos($x, "prob") == 0) {
+ $tmp = explode ("=", $x, 2);
+ switch (trim($tmp[0])) {
+ case "probnumber": $probnumber =trim($tmp[1]); break;
+ case "probname": $probname =trim($tmp[1]); break;
+ case "probfullname": $probfullname =trim($tmp[1]); break;
+ case "probbasename": $probbasename =trim($tmp[1]); break;
+ case "probtimelimit": $probtimelimit =trim($tmp[1]); break;
+ case "probcolorname": $probcolorname =trim($tmp[1]); break;
+ case "probcolor": $probcolor =trim($tmp[1]); break;
+ case "probinputfilehash": $probinputfilehash =trim($tmp[1]); break;
+ case "probinputfile": $probinputfile =trim($tmp[1]);
+ $i++;
+ for ($j=1; trim($ar[$i]) != "***$asep***"; $j++) {
+ if(substr($probinputfile,0,7)!="base64:") $probinputfilepath .= $ar[$i];
+ else $probinputfilepath .= trim($ar[$i]);
+ $i++;
+ }
+ if(substr($probinputfile,0,7)=="base64:") {
+ $probinputfile = substr($probinputfile,7);
+ $probinputfilepath = base64_decode($probinputfilepath);
+ }
+ if(trim($probinputfilehash) != "" && myshorthash($probinputfilepath) != trim($probinputfilehash))
+ echo "ERROR: Hash of $probinputfile does not match
\n";
+ break;
+ case "probsolfilehash": $probsolfilehash =trim($tmp[1]); break;
+ case "probsolfile": $probsolfile =trim($tmp[1]);
+ $i++;
+ for ($j=1; trim($ar[$i]) != "***$asep***"; $j++) {
+ if(substr($probsolfile,0,7)!="base64:") $probsolfilepath .= $ar[$i];
+ else $probsolfilepath .= trim($ar[$i]);
+ $i++;
+ }
+ if(substr($probsolfile,0,7)=="base64:") {
+ $probsolfile = substr($probsolfile,7);
+ $probsolfilepath = base64_decode($probsolfilepath);
+ }
+ if(trim($probsolfilehash) != "" && myshorthash($probsolfilepath) != trim($probsolfilehash))
+ echo "ERROR: Hash of $probsolfile does not match
\n";
+ break;
+ case "probdescfilehash": $probdescfilehash=trim($tmp[1]); break;
+ case "probdescfile": $probdescfile =trim($tmp[1]);
+ $i++;
+ for ($j=1; trim($ar[$i]) != "***$asep***"; $j++) {
+ if(substr($probdescfile,0,7)!="base64:") $probdescfilepath .= $ar[$i];
+ else $probdescfilepath .= trim($ar[$i]);
+ $i++;
+ }
+ if(substr($probdescfile,0,7)=="base64:") {
+ $probdescfile = substr($probdescfile,7);
+ $probdescfilepath = base64_decode($probdescfilepath);
+ }
+ if(trim($probdescfilehash) != "" && myshorthash($probdescfilepath) != trim($probdescfilehash))
+ echo "ERROR: Hash of $probdescfile does not match
\n";
+ break;
+ }
+ $i++;
+ if ($i>=count($ar)) break;
+ $x = trim($ar[$i]);
+ }
+ if (isset($probnumber) && is_numeric($probnumber) && isset($probname) &&
+ isset($probfullname) && isset($probbasename) &&
+ isset($probtimelimit) && isset($probcolorname) && isset($probcolor)) {
+ DBNewProblem ($nc,
+ $probnumber, $probname, $probfullname, $probbasename, $probinputfile,
+ $probinputfilepath, $probsolfile, $probsolfilepath, 'f', $probdescfile, $probdescfilepath,
+ $probtimelimit, $probcolorname, $probcolor, 1, 1, 1);
+ echo "Problem $probnumber created
";
+ }
+ }
+ }
+ }
+ echo "