Language: C++

#!/bin/sh

FILENAME="$1"

HTML="/tmp/$$.html"

if [ "x$FILENAME" == "x" ]; then
  cat > "$HTML"
elif [ -f "$FILENAME" ]; then
  cat "$FILENAME" > "$HTML"
else
  curl "$FILENAME" > "$HTML" || exit 1
fi

i=1

cat "$HTML" |
  tr -d '\r' |
  sed -ne '/入力例/,/Score/p' |
  grep -v '</div>' |
  grep -v '</span>' |
  grep -v '<div ' |
  grep -v '<hr />' |
  grep -v '<p>' |
  grep -v '<section>' |
  grep -v '<span ' |
  sed -e 's!</section>!!' |
  sed -e 's!<h3>[^<]*</h3>!!' |
  sed -ne '
/<pre[^>]*>/ {
  :loop
  N
  /<\/pre>/! b loop
  p
}
' |
  grep -v '</pre>' |
  while read a; do
    if echo "$a" | grep '<pre[^>]*>' > /dev/null 2>&1; then
      i=`expr $i + 1`
      if echo "$i" | grep '[02468]$' > /dev/null 2>&1; then
        filename="sample`expr $i / 2`.txt"
      else
        filename="answer`expr $i / 2`.txt"
      fi
      rm -f "$filename"
    fi
    echo "$a" | sed -e 's!<pre[^>]*>!!' -e 's/&lt;/</g' -e 's/&gt;/>/g' >> "$filename"
  done

rm -f "$HTML"

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #!
    1 | #!/bin/sh
      |  ^
a.cc:19:11: warning: multi-character literal with 20 characters exceeds 'int' size of 4 bytes
   19 |   sed -ne '/入力例/,/Score/p' |
      |           ^~~~~~~~~~~~~~~~~~~
a.cc:20:11: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
   20 |   grep -v '</div>' |
      |           ^~~~~~~~
a.cc:21:11: warning: multi-character literal with 7 characters exceeds 'int' size of 4 bytes
   21 |   grep -v '</span>' |
      |           ^~~~~~~~~
a.cc:22:11: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
   22 |   grep -v '<div ' |
      |           ^~~~~~~
a.cc:23:11: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
   23 |   grep -v '<hr />' |
      |           ^~~~~~~~
a.cc:24:11: warning: multi-character character constant [-Wmultichar]
   24 |   grep -v '<p>' |
      |           ^~~~~
a.cc:25:11: warning: multi-character literal with 9 characters exceeds 'int' size of 4 bytes
   25 |   grep -v '<section>' |
      |           ^~~~~~~~~~~
a.cc:26:11: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
   26 |   grep -v '<span ' |
      |           ^~~~~~~~
a.cc:27:10: warning: multi-character literal with 14 characters exceeds 'int' size of 4 bytes
   27 |   sed -e 's!</section>!!' |
      |          ^~~~~~~~~~~~~~~~
a.cc:28:10: warning: multi-character literal with 18 characters exceeds 'int' size of 4 bytes
   28 |   sed -e 's!<h3>[^<]*</h3>!!' |
      |          ^~~~~~~~~~~~~~~~~~~~
a.cc:29:11: warning: missing terminating ' character
   29 |   sed -ne '
      |           ^
a.cc:29:11: error: missing terminating ' character
a.cc:33:5: error: stray '\' in program
   33 |   /<\/pre>/! b loop
      |     ^
a.cc:36:1: warning: missing terminating ' character
   36 | ' |
      | ^
a.cc:36:1: error: missing terminating ' character
   36 | ' |
      | ^~~
a.cc:37:11: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
   37 |   grep -v '</pre>' |
      |           ^~~~~~~~
a.cc:39:25: warning: multi-character literal with 10 characters exceeds 'int' size of 4 bytes
   39 |     if echo "$a" | grep '<pre[^>]*>' > /dev/null 2>&1; then
      |                         ^~~~~~~~~~~~
a.cc:40:9: error: stray '`' in program
   40 |       i=`expr $i + 1`
      |         ^
a.cc:40:21: error: stray '`' in program
   40 |       i=`expr $i + 1`
      |                     ^
a.cc:41:27: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   41 |       if echo "$i" | grep '[02468]$' > /dev/null 2>&1; then
      |                           ^~~~~~~~~~
a.cc:48:24: warning: multi-character literal with 14 characters exceeds 'int' size of 4 bytes
   48 |     echo "$a" | sed -e 's!<pre[^>]*>!!' -e 's/&lt;/</g' -e 's/&gt;/>/g' >> "$filename"
      |                        ^~~~~~~~~~~~~~~~
a.cc:48:44: warning: multi-character literal with 10 characters exceeds 'int' size of 4 bytes
   48 |     echo "$a" | sed -e 's!<pre[^>]*>!!' -e 's/&lt;/</g' -e 's/&gt;/>/g' >> "$filename"
      |                                            ^~~~~~~~~~~~
a.cc:48:60: warning: multi-character literal with 10 characters exceeds 'int' size of 4 bytes
   48 |     echo "$a" | sed -e 's!<pre[^>]*>!!' -e 's/&lt;/</g' -e 's/&gt;/>/g' >> "$filename"
      |                                                            ^~~~~~~~~~~~
a.cc:3:1: error: 'FILENAME' does not name a type; did you mean '__FILE_NAME__'?
    3 | FILENAME="$1"
      | ^~~~~~~~
      | __FILE_NAME__
a.cc:7:29: error: 'then' does not name a type
    7 | if [ "x$FILENAME" == "x" ]; then
      |                             ^~~~
a.cc:9:26: error: 'then' does not name a type
    9 | elif [ -f "$FILENAME" ]; then
      |                          ^~~~
a.cc:37:3: error: 'grep' does not name a type
   37 |   grep -v '</pre>' |
      |   ^~~~
a.cc:38:17: error: expected unqualified-id before 'do'
   38 |   while read a; do
      |                 ^~
a.cc:39:56: error: 'then' does not name a type
   39 |     if echo "$a" | grep '<pre[^>]*>' > /dev/null 2>&1; then
      |                                                        ^~~~
a.cc:41:56: error: 'then' does not name a type
   41 |       if echo "$i" | grep '[02468]$' > /dev/null 2>&1; then
      |                                                        ^~~~