# Cofiguration Files for Competitive Programming
## `~/.vimrc`
```vim=
syn on
se ai nu rnu ru cul mouse=a
se cin et ts=4 sw=4 sts=4
colo monokai
set autochdir
no <F2> :w<CR>:!~/run.sh %:p:t<CR>
no h b
no l w
inoremap {<CR> {<CR>}<Esc>ko
no <C-s> :w<CR>
inoremap <C-s> <ESC>:w<CR>a
inoremap <C-z> <ESC>ui
```
## `run.sh`
```bash=
#!/bin/sh
clear
PrintUsage() {
echo "Usage: ./run.sh CODEFILE"
echo
echo "The input files should be under \"testcases\" directory."
echo "The \"testcases\" directory should share the same path with CODEFILE. (Or you can modify the path in run.sh by yourself)"
echo "The input files should be named in the following manner: 1.txt 2.txt ... etc."
echo
echo
}
if [ $# -ne 1 ] ; then
PrintUsage
exit 1
elif ! [ -e "${1}" ] ; then
echo [CODEFILE NOT EXIST]
echo
PrintUsage
exit 1
fi
println() {
if [ "$1" = "bold" ] ; then
echo =======================================
elif [ "$1" = "thin" ] ; then
echo ---------------------------------------
else
echo
fi
}
codeFileName="$( basename "${1}" )"
codePath="$( dirname "${1}" )"
#echo ${codeFileName}
#echo ${codePath}
#exit 0
RunTest() {
startTime="$( date +%s%N )"
inputFile=$1
inputFilePath="$( dirname "${inputFile}" )"
if ! [ -e "${inputFile}" ] ; then
return 1
fi
inputFileName="$( basename "${inputFile}" )"
println thin
echo "[RUNNING ${inputFileName}]"
println
println
echo "########## INPUT ###########"
cat "${inputFile}"
"${codePath}"/"${codeFileName}".out < "${inputFile}" > "${inputFilePath}"/output"${inputFileName}".txt
testResult=$?
if [ $testResult -eq 0 ] ; then
println
echo "########## OUTPUT ##########"
cat "${inputFilePath}"/output"${inputFileName}".txt
fi
println
endTime="$( date +%s%N )"
delta=$(( "${endTime}" - "${startTime}" ))
delta=$(( "${delta}" / 1000000 ))
println
echo "(Time: ${delta}ms | Return Value: ${testResult})"
#println thin
for i in $(seq 0 7) ; do
println
done
return 0
}
echo Code File: "${1}"
println
#println bold
echo [START COMPILE]
println
g++ -std=c++17 -o "${codePath}"/"${codeFileName}".out -O2 -Wall -Wextra -g -fsanitize=address "${1}"
compileResult=$?
println
echo [DONE COMPILE]
#println bold
println
println
println
if [ $compileResult -ne 0 ] ; then
println
println
echo [COMPILE ERROR]
echo I will not run any test since your code is buggy.
println
println bold
exit 1
fi
runResult=0
testIndex=1
while [ $runResult -eq 0 ] ; do
# Specify the folder of input files here.
RunTest "${codePath}"/testcases/"${testIndex}".txt
runResult=$?
testIndex=$(( testIndex + 1 ))
done
```