@echo off
if "%1" == "" (
    exit       
)

for %%i in (.) do (
    set problem_name=%%~ni
)


if NOT "%2" == "" (
    if EXIST %problem_name%_%1.exe   goto compiled
    if EXIST %problem_name%_%1.class goto compiled
)


:compiled


if "%2" == "" (    
    for %%i in (tests\??) do (        
        call docheck %1 %%i
    )
    call clean
) else (
    echo Running on test: %2
    copy %2 %problem_name%.in > nul
    if EXIST %problem_name%_%1.exe run -t 2 -m 64M %problem_name%_%1.exe
    if EXIST %problem_name%_%1.class run -Xtfce -t 2 java -ea %problem_name%_%1
    check %problem_name%.in %problem_name%.out %2.a
)