Language: C++

#!/bin/bash
all_ac=true

try() {
    input="$1"
    expected="$2"

    actual="$(echo $input | ./main)"

    if [ "$actual" != "$expected" ]; then
        echo "WA"
        echo "expected:"
        echo "$expected"
        echo
        echo "actual:"
        echo "$actual"
        echo

        all_ac=false
        return
    fi
    echo "AC"
    echo
}

# test cases
echo "[Sample1]"
input1="$(cat << EOS
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
EOS
)"
expected1="$(cat << EOS
2 2

EOS
)"
try "$input1" "$expected1"

echo "[Sample2]"
input2="$(cat << EOS
100000 3
7777 AC
7777 AC
7777 AC
EOS
)"
expected2="$(cat << EOS
1 0

EOS
)"
try "$input2" "$expected2"

echo "[Sample3]"
input3="$(cat << EOS
6 0
EOS
)"
expected3="$(cat << EOS
0 0
EOS
)"
try "$input3" "$expected3"

echo "[Sample4]"
input4="$(cat << EOS
6 1
1 WA
EOS
)"
expected4="$(cat << EOS
0 0
EOS
)"
try "$input4" "$expected4"

echo "[Result]"
if ! $all_ac; then
    echo "WA"
    echo
    exit 1
fi
echo "All AC"


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #!
    1 | #!/bin/bash
      |  ^
a.cc:26:3: error: invalid preprocessing directive #test
   26 | # test cases
      |   ^~~~
a.cc:28:8: warning: missing terminating " character
   28 | input1="$(cat << EOS
      |        ^
a.cc:28:8: error: missing terminating " character
   28 | input1="$(cat << EOS
      |        ^~~~~~~~~~~~~
a.cc:36:2: warning: missing terminating " character
   36 | )"
      |  ^
a.cc:36:2: error: missing terminating " character
a.cc:37:11: warning: missing terminating " character
   37 | expected1="$(cat << EOS
      |           ^
a.cc:37:11: error: missing terminating " character
   37 | expected1="$(cat << EOS
      |           ^~~~~~~~~~~~~
a.cc:41:2: warning: missing terminating " character
   41 | )"
      |  ^
a.cc:41:2: error: missing terminating " character
a.cc:45:8: warning: missing terminating " character
   45 | input2="$(cat << EOS
      |        ^
a.cc:45:8: error: missing terminating " character
   45 | input2="$(cat << EOS
      |        ^~~~~~~~~~~~~
a.cc:51:2: warning: missing terminating " character
   51 | )"
      |  ^
a.cc:51:2: error: missing terminating " character
a.cc:52:11: warning: missing terminating " character
   52 | expected2="$(cat << EOS
      |           ^
a.cc:52:11: error: missing terminating " character
   52 | expected2="$(cat << EOS
      |           ^~~~~~~~~~~~~
a.cc:56:2: warning: missing terminating " character
   56 | )"
      |  ^
a.cc:56:2: error: missing terminating " character
a.cc:60:8: warning: missing terminating " character
   60 | input3="$(cat << EOS
      |        ^
a.cc:60:8: error: missing terminating " character
   60 | input3="$(cat << EOS
      |        ^~~~~~~~~~~~~
a.cc:63:2: warning: missing terminating " character
   63 | )"
      |  ^
a.cc:63:2: error: missing terminating " character
a.cc:64:11: warning: missing terminating " character
   64 | expected3="$(cat << EOS
      |           ^
a.cc:64:11: error: missing terminating " character
   64 | expected3="$(cat << EOS
      |           ^~~~~~~~~~~~~
a.cc:67:2: warning: missing terminating " character
   67 | )"
      |  ^
a.cc:67:2: error: missing terminating " character
a.cc:71:8: warning: missing terminating " character
   71 | input4="$(cat << EOS
      |        ^
a.cc:71:8: error: missing terminating " character
   71 | input4="$(cat << EOS
      |        ^~~~~~~~~~~~~
a.cc:75:2: warning: missing terminating " character
   75 | )"
      |  ^
a.cc:75:2: error: missing terminating " character
a.cc:76:11: warning: missing terminating " character
   76 | expected4="$(cat << EOS
      |           ^
a.cc:76:11: error: missing terminating " character
   76 | expected4="$(cat << EOS
      |           ^~~~~~~~~~~~~
a.cc:79:2: warning: missing terminating " character
   79 | )"
      |  ^
a.cc:79:2: error: missing terminating " character
a.cc:2:1: error: 'all_ac' does not name a type
    2 | all_ac=true
      | ^~~~~~
a.cc:27:1: error: 'echo' does not name a type
   27 | echo "[Sample1]"
      | ^~~~
a.cc:83:15: error: 'then' does not name a type
   83 | if ! $all_ac; then
      |               ^~~~